# Residual mean life (restricted)

### Description

Fits a semiparametric model for the residual life (estimator=1):

*
E( \min(Y,τ) -t | Y>=t) = h_1( g(t,x,z) )
*

or cause specific years lost of Andersen (2012) (estimator=3)

*
E( τ- \min(Y_j,τ) | Y>=0) = \int_0^t (1-F_j(s)) ds = h_2( g(t,x,z) )
*

where *Y_j = ∑_j Y I(ε=j) + ∞ * I(ε=0)*
or (estimator=2)

*
E( τ- \min(Y_j,τ) | Y<τ, ε=j) = h_3( g(t,x,z) ) = h_2(g(t,x,z)) F_j(τ,x,z)
*

where
*F_j(s,x,z) = P(Y<τ, ε=j | x,z )*
for a known link-function *h()*
and known prediction-function *g(t,x,z)*

Uses the IPCW for the score equations based on

*
w(t) Δ(τ)/P(Δ(τ)=1| T,ε,X,Z) ( Y(t) - h_1(t,X,Z))
*

and where
*Δ(τ)* is the at-risk indicator given data and requires a IPCW model.

### Usage

1 2 3 4 | ```
res.mean(formula,data=sys.parent(),cause=1,restricted=NULL,times=NULL,Nit=50,
clusters=NULL,gamma=0,n.sim=0,weighted=0,model="additive",detail=0,interval=0.01,
resample.iid=1,cens.model="KM",cens.formula=NULL,time.pow=NULL,time.pow.test=NULL,
silent=1,conv=1e-6,estimator=1,cens.weights=NULL,conservative=1,weights=NULL)
``` |

### Arguments

`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 ‘Event’ function. The status indicator is not important here. Time-invariant regressors are specified by the wrapper const(), and cluster variables (for computing robust variances) by the wrapper cluster(). |

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

`cause` |
For competing risk models specificies which cause we consider. |

`restricted` |
gives a possible restriction times for means. |

`times` |
specifies the times at which the estimator is considered. Defaults to all the times where an event of interest occurs, with the first 10 percent or max 20 jump points removed for numerical stability in simulations. |

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

`clusters` |
specifies cluster structure, for backwards compability. |

`gamma` |
starting value for constant effects. |

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

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

`model` |
"additive", "prop"ortional. |

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

`interval` |
specifies that we only consider timepoints where the Kaplan-Meier of the censoring distribution is larger than this value. |

`resample.iid` |
to return the iid decomposition, that can be used to construct confidence bands for predictions |

`cens.model` |
specified which model to use for the ICPW, KM is Kaplan-Meier alternatively it may be "cox" or "aalen" model for further flexibility. |

`cens.formula` |
specifies the regression terms used for the regression model for chosen regression model. When cens.model is specified, the default is to use the same design as specified for the competing risks model. "KM","cox","aalen","weights". "weights" are user specified weights given is cens.weight argument. |

`time.pow` |
specifies that the power at which the time-arguments is transformed, for each of the arguments of the const() terms, default is 1 for the additive model and 0 for the proportional model. |

`time.pow.test` |
specifies that the power the time-arguments is transformed for each of the arguments of the non-const() terms. This is relevant for testing if a coefficient function is consistent with the specified form A_l(t)=beta_l t^time.pow.test(l). Default is 1 for the additive model and 0 for the proportional model. |

`silent` |
if 0 information on convergence problems due to non-invertible derviates of scores are printed. |

`conv` |
gives convergence criterie in terms of sum of absolute change of parameters of model |

`estimator` |
specifies what that is estimated. |

`cens.weights` |
censoring weights for estimating equations. |

`conservative` |
for slightly conservative standard errors. |

`weights` |
weights for estimating equations. |

### Details

Since timereg version 1.8.4. the response must be specified with the
`Event`

function instead of the `Surv`

function and the arguments.

### Value

returns an object of type 'comprisk'. With the following arguments:

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

`var.cum` |
pointwise variances estimates. |

`gamma` |
estimate of proportional odds parameters of model. |

`var.gamma` |
variance for gamma. |

`score` |
sum of absolute value of scores. |

`gamma2` |
estimate of constant effects based on the non-parametric estimate. Used for testing of constant effects. |

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

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

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

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

`B.iid` |
list of iid decomposition of non-parametric effects. |

`gamma.iid` |
matrix of iid decomposition of parametric effects. |

`test.procBeqC` |
observed test process for testing of time-varying effects |

`sim.test.procBeqC` |
50 resample processes for for testing of time-varying effects |

`conv` |
information on convergence for time points used for estimation. |

### Author(s)

Thomas Scheike

### References

Andersen (2013), Decomposition of number of years lost according to causes of death, Statistics in Medicine, 5278-5285.

Scheike, and Cortese (2015), Regression Modelling of Cause Specific Years Lost,

Scheike, Cortese and Holmboe (2015), Regression Modelling of Restricted Residual Mean with Delayed Entry,

### Examples

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 30 31 32 33 34 35 36 37 38 39 40 41 42 | ```
data(bmt);
tau <- 100
### residual restricted mean life
out<-res.mean(Event(time,cause>=1)~factor(tcell)+factor(platelet),data=bmt,cause=1,
times=0,restricted=tau,n.sim=0,model="additive",estimator=1);
summary(out)
out<-res.mean(Event(time,cause>=1)~factor(tcell)+factor(platelet),data=bmt,cause=1,
times=seq(0,90,5),restricted=tau,n.sim=0,model="additive",estimator=1);
par(mfrow=c(1,3))
plot(out)
### restricted years lost given death
out21<-res.mean(Event(time,cause)~factor(tcell)+factor(platelet),data=bmt,cause=1,
times=0,restricted=tau,n.sim=0,model="additive",estimator=2);
summary(out21)
out22<-res.mean(Event(time,cause)~factor(tcell)+factor(platelet),data=bmt,cause=2,
times=0,restricted=tau,n.sim=0,model="additive",estimator=2);
summary(out22)
### total restricted years lost
out31<-res.mean(Event(time,cause)~factor(tcell)+factor(platelet),data=bmt,cause=1,
times=0,restricted=tau,n.sim=0,model="additive",estimator=3);
summary(out31)
out32<-res.mean(Event(time,cause)~factor(tcell)+factor(platelet),data=bmt,cause=2,
times=0,restricted=tau,n.sim=0,model="additive",estimator=3);
summary(out32)
### delayed entry
nn <- nrow(bmt)
entrytime <- rbinom(nn,1,0.5)*(bmt$time*runif(nn))
bmt$entrytime <- entrytime
bmtw <- prep.comp.risk(bmt,times=tau,time="time",entrytime="entrytime",cause="cause")
out<-res.mean(Event(time,cause>=1)~factor(tcell)+factor(platelet),data=bmtw,cause=1,
times=0,restricted=tau,n.sim=0,model="additive",estimator=1,
cens.model="weights",weights=bmt$cw,cens.weights=1/bmtw$weights);
summary(out)
``` |

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker. Vote for new features on Trello.