Learn R Programming

timereg (version 1.5-0)

surv.lars: Fits LASSO model for additive hazards model by Lars algorithm

Description

Fits the LASSO estimator for the additive risk model based on the least squares fitting criterion

$$L(\beta,S,s) = \beta^T S \beta - 2 \beta^T s$$ where $S=\int Z H Z dt$ and $s=\int Z H dN$.

This is equivalent to an appropriate normal least squares problem on least squares data.

Much quicker implementaion in ahaz package that is recommended.

Usage

surv.lars(S, s, n, l1.weights = NULL, ...)

Arguments

S
the S matrix defined above.
s
the s vector defined above.
n
number of subjects, used in lars to decide dimension.
l1.weights
NOT WORKING yet. specifies the weights for the L1 penalty.
...
unused arguments - for S3 compatibility

Value

  • see lars.

Details

Modified version of standard lars program in the LARS package. Essentially all scalings are removed from the lars program.

The matrices S and S can be computed using the aalen() function.

References

Martinussen and Scheike, Model selection for the the additive risks hazards model, Scandinavian Journal of Statistics, 2008, pages .

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

LARS, Efron et al.

Examples

Run this code
## makes data for pbc complete case
data(mypbc)
pbc<-mypbc
pbc$time<-pbc$time+runif(418)*0.1; pbc$time<-pbc$time/365
pbc<-subset(pbc,complete.cases(pbc)); 
covs<-as.matrix(pbc[,-c(1:3,6)])
covs<-cbind(covs[,c(1:6,16)],log(covs[,7:15]))
covs<-scale(covs); 

## computes the matrices needed for the least squares 
## criterion 

out<-aalen(Surv(time,status>=1)~const(covs),data=pbc,robust=0)
S<-out$intZHZ; s<-out$intZHdN
n<-nrow(pbc)

## lasso for survival data 
if (require(lars)) {
fit<-surv.lars(S,s,n)
plot(fit)

cv<-surv.lars.cv(Surv(time,status>=1)~ const(covs),data=pbc)
beta<-mypredict.lars(fit,cv$cv.frac,type="coefficients",mode = "fraction")$coef
c(beta)

## fitting survival model with these coefficients
out<-aalen(Surv(time,status>=1)~ const(covs),data=pbc,robust=0,gamma=beta)
pout<-predict(out,Z=covs[1:20,],uniform=0,se=0)
plot(pout,multiple=1,se=0,uniform=0,main="Lars survival predictions"); 

full<-fit$beta[nrow(fit$beta),] # least squares solution
c(full)
}

Run the code above in your browser using DataLab