Performs Cox regression with some special attractions, especially sampling of risksets and the weird bootstrap.
coxreg(formula = formula(data), data = parent.frame(), weights, subset, t.offset, na.action = getOption("na.action"), init = NULL, method = c("efron", "breslow", "mppl", "ml"), control = list(eps = 1e08, maxiter = 25, trace = FALSE), singular.ok = TRUE, model = FALSE, center = NULL, x = FALSE, y = TRUE, hazards = NULL, boot = FALSE, efrac = 0, geometric = FALSE, rs = NULL, frailty = NULL, max.survs = NULL, coxph = TRUE)
formula  a formula object, with the response on the left of a ~ operator, and the terms on the right. The response must be a survival object as returned by the Surv function. 

data  a data.frame in which to interpret the variables named in the formula. 
weights  Case weights; timefixed or timevarying. 
subset  An optional vector specifying a subset of observations to be used in the fitting process. 
t.offset  Case offsets; timevarying. 
na.action  a missingdata filter function, applied to the model.frame,
after any subset argument has been used. Default is

init  vector of initial values of the iteration. Default initial value is zero for all variables. 
method  Method of treating ties, "efron" (default), "breslow", "mppl" (maximum partial partial likelihood), or "ml" (maximum likelihood). 
control  a list with components 
singular.ok  Not used 
model  Not used 
center  deprecated. See Details. 
x  Return the design matrix in the model object? 
y  return the response in the model object? 
hazards  deprecated. Was: Calculate baseline hazards? Default is TRUE. Calculating hazards is better done separately, after fitting. In most cases. 
boot  Number of boot replicates. Defaults to FALSE, no boot samples. 
efrac  Upper limit of fraction failures in 'mppl'. 
geometric  If TRUE, forces an 'ml' model with constant riskset probability. Default is FALSE. 
rs  Risk set? 
frailty  Grouping variable for frailty analysis. Not in use (yet). 
max.survs  Sampling of risk sets? If given, it should be (the upper limit of) the number of survivors in each risk set. 
coxph  Logical, defaults to 
A list of class c("coxreg", "coxph")
with components
Fitted parameter estimates.
Covariance matrix of the estimates.
Vector of length two; first component is the value at the initial parameter values, the second component is the maximized value.
The score test statistic (at the initial value).
The estimated linear predictors.
The martingale residuals.
The estimated baseline hazards, calculated at the value zero of the covariates (rather, columns of the design matrix). Is a list, with one component per stratum. Each component is a matrix with two columns, the first contains risk times, the second the corresponding hazard atom.
Means of the columns of
the design matrix corresponding to covariates, if center = TRUE
.
Columns corresponding to factor levels gice a zero in the corresponding
position in means
. If center = FALSE
, means
are all
zero.
Weighted (against exposure time) means of covariates; weighted relative frequencies of levels of factors.
Number of spells in indata (possibly after removal of cases with NA's).
Number of events in data.
Used by extractor functions.
Used by extractor functions.
The Surv vector.
Logical vector indicating the covariates that are factors.
The covariates.
Total Time at Risk.
List of levels of factors.
The calling formula.
The (matrix of) bootstrap replicates, if requested on input. It is up to the user to do whatever desirable with this sample.
The estimated standard errors of the bootstrap replicates.
The call.
The method.
Number of strata.
Did the optimization converge?
Did the optimization fail? (Is NULL
if not).
The default method, efron
, and the alternative, breslow
, are
both the same as in coxph
in package
survival
. The methods mppl
and ml
are maximum
likelihood, discretemodel, based.
This function starts by creating risksets, if no riskset is supplied
via rs
, with the aid of risksets
. Supplying output from
risksets
via rs
fails if there are any NA's in the data! Note
also that it depends on stratification, so rs
contains information
about stratification. Giving another strata variable in the formula is an
error. The same is ok, for instance to supply stratum interactions.
The use of rs
is dangerous, see note. It can
however speed up computing time considerably for huge data sets.
Broström, G. and Lindkvist, M. (2008). Partial partial likelihood. Communications in Statistics: Simulation and Computation 37:4, 679686.
Göran Broström
dat < data.frame(time= c(4, 3,1,1,2,2,3), status=c(1,1,1,0,1,1,0), x= c(0, 2,1,1,1,0,0), sex= c(0, 0,0,0,1,1,1)) coxreg( Surv(time, status) ~ x + strata(sex), data = dat) #stratified model#> Call: #> coxreg(formula = Surv(time, status) ~ x + strata(sex), data = dat) #> #> Covariate Mean Coef Rel.Risk S.E. Wald p #> x 0.625 0.802 2.231 0.822 0.329 #> #> Events 5 #> Total time at risk 16 #> Max. log. likelihood 3.3277 #> LR test statistic 1.09 #> Degrees of freedom 1 #> Overall pvalue 0.297117# Same as: rs < risksets(Surv(dat$time, dat$status), strata = dat$sex) coxreg( Surv(time, status) ~ x, data = dat, rs = rs) #stratified model#> Call: #> coxreg(formula = Surv(time, status) ~ x, data = dat, rs = rs) #> #> Covariate Mean Coef Rel.Risk S.E. Wald p #> x 0.625 0.802 2.231 0.822 0.329 #> #> Events 5 #> Total time at risk 16 #> Max. log. likelihood 3.3277 #> LR test statistic 1.09 #> Degrees of freedom 1 #> Overall pvalue 0.297117