customPenalized: Penalized regression using the 'penalized' R package

Description Usage Arguments Value Author(s) References See Also Examples

Description

Ridge or Lasso penalized regression. Usually, this function is not called directly but embedded in a call to customSurv from the main package survHD (see examples).

Usage

1
customPenalized(Xlearn, Ylearn, learnind, ...)

Arguments

Xlearn

Gene expression data (a data.frame)

Ylearn

Survival Response, an object of class Surv.

learnind

An index vector specifying the observations that belong to the learning set. May be missing; in that case, the learning set consists of all observations and predictions are made on the learning set.

...

Further arguments to be passed to function penalized:

penalty

Type of penalization: "ridge", "lasso", or "elasticnet".

unpenalizedvarnames

Character vector which is a subset of colnames(X), naming variables which will be unpenalized.

...

Additional arguments that shall be passed to downstream functions. Potential downstream functions include optL1, optL2, and penalized from the penalized package, and opt2D from the pensim package. If lambda is not specified in the ..., then a tuning will be performed using penalized:optL1 (lasso), penalized:optL2 (ridge), or pensim:opt2D. For ridge or lasso, lambda (if specified at all) should be a single numeric value. For elasticnet, lambda (if specified at all) should be a numeric vector of length two. Whether or not tuning is performed, regression for the final model is performed using the penalized function from the penalized R package.

Value

An object of class ModelLearned.

Author(s)

Levi Waldron lwaldron@hsph.harvard.edu Christoph Bernau bernau@ibe.med.uni-muenchen.de Martin Slawski ms@cs.uni-sb.de Anne-Laure Boulesteix boulesteix@ibe.med.uni-muenchen.de

References

Goeman, J.J. (2010) L1 Penalized Estimation in the Cox Proportional Hazards Model, Biometrical Journal, 52, 70-84

See Also

learnSurvival, penalized

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
##load example data
if(require(pensim)){
require(survHD)
require(survHDExtra)
data(beer.exprs,package="pensim")
data(beer.survival,package="pensim")
##create Surv object (y)
beerY <- with(beer.survival,Surv(os,status))
##create mini X matrix (only using first 200 genes)
beerX <- t(as.matrix(beer.exprs))
beerX <- beerX[,1:200]
colnames(beerX) <- make.names(colnames(beerX),unique=TRUE)
##scale everything for testing.
beerX <- scale(beerX)
##define training and test sets:
set.seed(4)
allind <- 1:nrow(beerX)
learnind <- sample(allind,size=round(length(allind)*9/10))
testind <- allind[-learnind]
##fit a model with ridge regression, and with L2 penalty equal to 100:
fit.penalized <- customSurv(X=beerX,y=beerY, learnind=learnind, penalty="ridge", lambda=100,customSurvModel=customPenalized)
##linear risk score
predict(fit.penalized@model,newdata=beerX[testind,],type='lp')
##survival probabilities at each uncensored time
mytimegrid <- sort(c(0.0,beerY[beerY[,2]==1,1]))
SurvivalProbs <- predict(fit.penalized,beerX[testind,],type='SurvivalProbs',timegrid=mytimegrid,gbm=TRUE)@SurvivalProbs
plot(SurvivalProbs,xlab="Time", ylab="Probability of Survival")
}

bernau/survHDExtra documentation built on May 12, 2019, 4:22 p.m.