Learn R Programming

eha (version 1.2-18)

toBinary: Transforms a "survival" data frame into a data frame suitable for binary (logistic) regression

Description

The result of the transformation can be used to do survival analysis via logistic regression. If the cloglog link is used, this corresponds to a discrete time analogue to Cox's proportional hazards model.

Usage

toBinary(dat, surv = c("enter", "exit", "event"),
strats, max.survs = NROW(dat))

Arguments

dat
A data frame with three variables representing the survival response. The default is that they are named enter, exit, and event
surv
A character string with the names of the three variables representing survival.
strats
An eventual stratification variable.
max.survs
Maximal numger of survivors per risk set. If set to a (small) number, survivors are sampled from the risk sets.

Value

  • Returns a data frame expanded risk set by risk set. The three "survival variables" are replaced by a variable named event (which overwrites an eventual variable by that name in the input). Two more variables are created, riskset and orig.row.
  • eventIndicates an event in the corresponding risk set.
  • risksetFactor (with levels 1, 2, ...) indicating risk set.
  • risktimeThe 'risktime' (age) in the corresponding riskset.
  • orig.rowThe row number for this item in the original data frame.

Details

toBinary calls risksets in the eha package.

References

~put references to the literature/web site here ~

See Also

coxreg, glm.

Examples

Run this code
enter <- rep(0, 4)
exit <- 1:4
event <- rep(1, 4)
z <- rep(c(-1, 1), 2)
dat <- data.frame(enter, exit, event, z)
binDat <- toBinary(dat)
dat
binDat
coxreg(Surv(enter, exit, event) ~ z, method = "ml", data = dat)
## Same as:
summary(glm(event ~ z + riskset, data = binDat, family = binomial(link = cloglog)))

Run the code above in your browser using DataLab