Learn R Programming

timereg (version 2.0.1)

cum.residuals: Model validation based on cumulative residuals

Description

Computes cumulative residuals and approximative p-values based on resampling techniques.

Usage

cum.residuals(
  object,
  data = parent.frame(),
  modelmatrix = 0,
  cum.resid = 1,
  n.sim = 500,
  weighted.test = 0,
  max.point.func = 50,
  weights = NULL
)

Arguments

object

an object of class 'aalen', 'timecox', 'cox.aalen' where the residuals are returned ('residuals=1')

data

data frame based on which residuals are computed.

modelmatrix

specifies a grouping of the data that is used for cumulating residuals. Must have same size as data and be ordered in the same way.

cum.resid

to compute residuals versus each of the continuous covariates in the model.

n.sim

number of simulations in resampling.

weighted.test

to compute a variance weighted version of the test-processes used for testing constant effects of covariates.

max.point.func

limits the amount of computations, only considers a max of 50 points on the covariate scales.

weights

weights for sum of martingale residuals, now for cum.resid=1.

Value

returns an object of type "cum.residuals" with the following arguments:

cum

cumulative residuals versus time for the groups specified by modelmatrix.

var.cum

the martingale based pointwise variance estimates.

robvar.cum

robust pointwise variances estimates of cumulatives.

obs.testBeq0

observed absolute value of supremum of cumulative components scaled with the variance.

pval.testBeq0

p-value covariate effects based on supremum test.

sim.testBeq0

resampled supremum value.

conf.band

resampling based constant to construct robust 95% uniform confidence bands for cumulative residuals.

obs.test

absolute value of supremum of observed test-process.

pval.test

p-value for supremum test statistic.

sim.test

resampled absolute value of supremum cumulative residuals.

proc.cumz

observed cumulative residuals versus all continuous covariates of model.

sim.test.proccumz

list of 50 random realizations of test-processes under model for all continuous covariates.

References

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

Examples

Run this code
# NOT RUN {
data(sTRACE)
# Fits Aalen model and returns residuals
fit<-aalen(Surv(time,status==9)~age+sex+diabetes+chf+vf,
           data=sTRACE,max.time=7,n.sim=0,residuals=1)

# constructs and simulates cumulative residuals versus age groups
fit.mg<-cum.residuals(fit,data=sTRACE,n.sim=100,
modelmatrix=model.matrix(~-1+factor(cut(age,4)),sTRACE))

par(mfrow=c(1,4))
# cumulative residuals with confidence intervals
plot(fit.mg);
# cumulative residuals versus processes under model
plot(fit.mg,score=1); 
summary(fit.mg)

# cumulative residuals vs. covariates Lin, Wei, Ying style 
fit.mg<-cum.residuals(fit,data=sTRACE,cum.resid=1,n.sim=100)

par(mfrow=c(2,4))
plot(fit.mg,score=2)
summary(fit.mg)

# }

Run the code above in your browser using DataLab