Fits an Cox-Aalen survival model. Time dependent variables and counting process data (multiple events per subject) are possible.
cox.aalen(
formula = formula(data),
data = parent.frame(),
beta = NULL,
Nit = 20,
detail = 0,
start.time = 0,
max.time = NULL,
id = NULL,
clusters = NULL,
n.sim = 500,
residuals = 0,
robust = 1,
weighted.test = 0,
covariance = 0,
resample.iid = 1,
weights = NULL,
rate.sim = 1,
beta.fixed = 0,
max.clust = 1000,
exact.deriv = 1,
silent = 1,
max.timepoint.sim = 100,
basesim = 0,
offsets = NULL,
strata = NULL,
propodds = 0,
caseweight = NULL
)
a formula object with the response on the left of a '~' operator, and the independent terms on the right as regressors. The response must be a survival object as returned by the `Surv' function. Terms with a proportional effect are specified by the wrapper prop(), and cluster variables (for computing robust variances) by the wrapper cluster().
a data.frame with the variables.
starting value for relative risk estimates.
number of iterations for Newton-Raphson algorithm.
if 0 no details is printed during iterations, if 1 details are given.
start of observation period where estimates are computed.
end of observation period where estimates are computed. Estimates thus computed from [start.time, max.time]. Default is max of data.
For timevarying covariates the variable must associate each record with the id of a subject.
cluster variable for computation of robust variances.
number of simulations in resampling.
to returns residuals that can be used for model validation in the function cum.residuals. Estimated martingale increments (dM) and corresponding time vector (time). When rate.sim=1 returns estimated martingales, dM_i(t) and if rate.sim=0, returns a matrix of dN_i(t).
to compute robust variances and construct processes for resampling. May be set to 0 to save memory and time, in particular for rate.sim=1.
to compute a variance weighted version of the test-processes used for testing time-varying effects.
to compute covariance estimates for nonparametric terms rather than just the variances.
to return i.i.d. representation for nonparametric and parametric terms. based on counting process or martingale resduals (rate.sim).
weights for weighted analysis.
rate.sim=1 such that resampling of residuals is based on estimated martingales and thus valid in rate case, rate.sim=0 means that resampling is based on counting processes and thus only valid in intensity case.
option for computing score process for fixed relative risk parameter
sets the total number of i.i.d. terms in i.i.d. decompostition. This can limit the amount of memory used by coarsening the clusters. When NULL then all clusters are used. Default is 1000 to save memory and time.
if 1 then uses exact derivative in last iteration, if 2 then uses exact derivate for all iterations, and if 0 then uses approximation for all computations and there may be a small bias in the variance estimates. For Cox model always exact and all options give same results.
if 1 then opppresses some output.
considers only this resolution on the time scale for simulations, see time.sim.resolution argument
1 to get simulations for cumulative baseline, including tests for contant effects.
offsets for analysis on log-scale. RR=exp(offsets+ x beta).
future option for making strata in a different day than through X design in cox-aalen model (~-1+factor(strata)).
if 1 will fit the proportional odds model. Slightly less efficient than prop.odds() function but much quicker, for large data this also works.
these weights have length equal to number of jump times, and are multiplied all jump times dN. Useful for getting the program to fit for example the proportional odds model or frailty models.
returns an object of type "cox.aalen". With the following arguments:
cumulative timevarying regression coefficient estimates are computed within the estimation interval.
the martingale based pointwise variance estimates.
robust pointwise variances estimates.
estimate of parametric components of model.
variance for gamma sandwhich estimator based on optional variation estimator of score and 2nd derivative.
robust variance for gamma.
list with residuals.
observed absolute value of supremum of cumulative components scaled with the variance.
p-value for covariate effects based on supremum test.
resampled supremum values.
observed absolute value of supremum of difference between observed cumulative process and estimate under null of constant effect.
p-value based on resampling.
resampled supremum values.
observed integrated squared differences between observed cumulative and estimate under null of constant effect.
p-value based on resampling.
resampled supremum values.
resampling based constant to construct robust 95% uniform confidence bands.
observed test-process of difference between observed cumulative process and estimate under null of constant effect over time.
list of 50 random realizations of test-processes under null based on resampling.
covariances for nonparametric terms of model.
Resample processes for nonparametric terms of model.
Resample processes for parametric terms of model.
approximate log-likelihood for model, similar to Cox's partial likelihood. Only computed when robust=1.
inverse of the derivative of the score function.
value of score for final estimates.
observed score process for proportional part of model.
variance of score process (optional variation estimator for beta.fixed=1 and robust estimator otherwise).
p-value based on resampling.
re-sampled absolute supremum values.
list of 50 random realizations of test-processes for proportionality under the model based on resampling.
$$ \lambda_{i}(t) = Y_i(t) ( X_{i}^T(t) \alpha(t) ) \exp(Z_{i}^T \beta ) $$
The model thus contains the Cox's regression model as special case.
To fit a stratified Cox model it is important to parametrize the baseline apppropriately (see example below).
Resampling is used for computing p-values for tests of time-varying effects. Test for proportionality is considered by considering the score processes for the proportional effects of model.
The modelling formula uses the standard survival modelling given in the survival package.
The data for a subject is presented as multiple rows or 'observations', each of which applies to an interval of observation (start, stop]. For counting process data with the )start,stop] notation is used, the 'id' variable is needed to identify the records for each subject. The program assumes that there are no ties, and if such are present random noise is added to break the ties.
Martinussen and Scheike, Dynamic Regression Models for Survival Data, Springer (2006).
# NOT RUN {
library(timereg)
data(sTRACE)
# Fits Cox model
out<-cox.aalen(Surv(time,status==9)~prop(age)+prop(sex)+
prop(vf)+prop(chf)+prop(diabetes),data=sTRACE)
# makes Lin, Wei, Ying test for proportionality
summary(out)
par(mfrow=c(2,3))
plot(out,score=1)
# Fits stratified Cox model
out<-cox.aalen(Surv(time,status==9)~-1+factor(vf)+ prop(age)+prop(sex)+
prop(chf)+prop(diabetes),data=sTRACE,max.time=7,n.sim=100)
summary(out)
par(mfrow=c(1,2)); plot(out);
# Same model, but needs to invert the entire marix for the aalen part: X(t)
out<-cox.aalen(Surv(time,status==9)~factor(vf)+ prop(age)+prop(sex)+
prop(chf)+prop(diabetes),data=sTRACE,max.time=7,n.sim=100)
summary(out)
par(mfrow=c(1,2)); plot(out);
# Fits Cox-Aalen model
out<-cox.aalen(Surv(time,status==9)~prop(age)+prop(sex)+
vf+chf+prop(diabetes),data=sTRACE,max.time=7,n.sim=100)
summary(out)
par(mfrow=c(2,3))
plot(out)
# }
Run the code above in your browser using DataLab