Description Usage Arguments Details Value Author(s) References Examples

View source: R/new.cox-aalen.r

Fits an Cox-Aalen survival model. Time dependent variables and counting process data (multiple events per subject) are possible.

1 2 3 4 5 6 7 | ```
cox.aalen(formula = formula(data), data = sys.parent(), 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)
``` |

`formula` |
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(). |

`data` |
a data.frame with the variables. |

`beta` |
starting value for relative risk estimates. |

`Nit` |
number of iterations for Newton-Raphson algorithm. |

`detail` |
if 0 no details is printed during iterations, if 1 details are given. |

`start.time` |
start of observation period where estimates are computed. |

`max.time` |
end of observation period where estimates are computed. Estimates thus computed from [start.time, max.time]. Default is max of data. |

`id` |
For timevarying covariates the variable must associate each record with the id of a subject. |

`clusters` |
cluster variable for computation of robust variances. |

`n.sim` |
number of simulations in resampling. |

`residuals` |
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). |

`robust` |
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. |

`weighted.test` |
to compute a variance weighted version of the test-processes used for testing time-varying effects. |

`covariance` |
to compute covariance estimates for nonparametric terms rather than just the variances. |

`resample.iid` |
to return i.i.d. representation for nonparametric and parametric terms. based on counting process or martingale resduals (rate.sim). |

`weights` |
weights for weighted analysis. |

`rate.sim` |
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. |

`beta.fixed` |
option for computing score process for fixed relative risk parameter |

`max.clust` |
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. |

`exact.deriv` |
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. |

`silent` |
if 1 then opppresses some output. |

`max.timepoint.sim` |
considers only this resolution on the time scale for simulations, see time.sim.resolution argument |

`basesim` |
1 to get simulations for cumulative baseline, including tests for contant effects. |

`offsets` |
offsets for analysis on log-scale. RR=exp(offsets+ x beta). |

`strata` |
future option for making strata in a different day than through X design in cox-aalen model (~-1+factor(strata)). |

`propodds` |
if 1 will fit the proportional odds model. Slightly less efficient than prop.odds() function but much quicker, for large data this also works. |

`caseweight` |
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. |

* λ_{i}(t) = Y_i(t) ( X_{i}^T(t) α(t) ) \exp(Z_{i}^T β )
*

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.

returns an object of type "cox.aalen". With the following arguments:

`cum` |
cumulative timevarying regression coefficient estimates are computed within the estimation interval. |

`var.cum` |
the martingale based pointwise variance estimates. |

`robvar.cum` |
robust pointwise variances estimates. |

`gamma` |
estimate of parametric components of model. |

`var.gamma` |
variance for gamma sandwhich estimator based on optional variation estimator of score and 2nd derivative. |

`robvar.gamma` |
robust variance for gamma. |

`residuals` |
list with residuals. |

`obs.testBeq0` |
observed absolute value of supremum of cumulative components scaled with the variance. |

`pval.testBeq0` |
p-value for covariate effects based on supremum test. |

`sim.testBeq0` |
resampled supremum values. |

`obs.testBeqC` |
observed absolute value of supremum of difference between observed cumulative process and estimate under null of constant effect. |

`pval.testBeqC` |
p-value based on resampling. |

`sim.testBeqC` |
resampled supremum values. |

`obs.testBeqC.is` |
observed integrated squared differences between observed cumulative and estimate under null of constant effect. |

`pval.testBeqC.is` |
p-value based on resampling. |

`sim.testBeqC.is` |
resampled supremum values. |

`conf.band` |
resampling based constant to construct robust 95% uniform confidence bands. |

`test.procBeqC` |
observed test-process of difference between observed cumulative process and estimate under null of constant effect over time. |

`sim.test.procBeqC` |
list of 50 random realizations of test-processes under null based on resampling. |

`covariance` |
covariances for nonparametric terms of model. |

`B.iid` |
Resample processes for nonparametric terms of model. |

`gamma.iid` |
Resample processes for parametric terms of model. |

`loglike` |
approximate log-likelihood for model, similar to Cox's partial likelihood. Only computed when robust=1. |

`D2linv` |
inverse of the derivative of the score function. |

`score` |
value of score for final estimates. |

`test.procProp` |
observed score process for proportional part of model. |

`var.score` |
variance of score process (optional variation estimator for beta.fixed=1 and robust estimator otherwise). |

`pval.Prop` |
p-value based on resampling. |

`sim.supProp` |
re-sampled absolute supremum values. |

`sim.test.procProp` |
list of 50 random realizations of test-processes for proportionality under the model based on resampling. |

Thomas Scheike

Martinussen and Scheike, Dynamic Regression Models for Survival Data, Springer (2006).

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | ```
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)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.