predict.cv.PCLasso {PCLassoReg} | R Documentation |
Make predictions from a cross-validated PCLasso model
Description
Similar to other predict methods, this function returns
predictions from a fitted cv.PCLasso
object, using the optimal value
chosen for lambda
.
Usage
## S3 method for class 'cv.PCLasso'
predict(
object,
x = NULL,
type = c("link", "response", "survival", "median", "norm", "coefficients", "vars",
"nvars", "vars.unique", "nvars.unique", "groups", "ngroups"),
lambda,
...
)
Arguments
object |
Fitted |
x |
Matrix of values at which predictions are to be made. The features
(genes/proteins) contained in |
type |
Type of prediction: "link" returns the linear predictors; "response" gives the risk (i.e., exp(link)); "vars" returns the indices for the nonzero coefficients; "vars.unique" returns unique features (genes/proteins) with nonzero coefficients (If a feature belongs to multiple groups and multiple groups are selected, the feature will be repeatedly selected. Compared with "var", "var.unique" will filter out repeated features.); "groups" returns the groups with at least one nonzero coefficient; "nvars" returns the number of nonzero coefficients; "nvars.unique" returens the number of unique features (genes/proteins) with nonzero coefficients; "ngroups" returns the number of groups with at least one nonzero coefficient; "norm" returns the L2 norm of the coefficients in each group."survival" returns the estimated survival function; "median" estimates median survival times. |
lambda |
Values of the regularization parameter |
... |
Arguments to be passed to |
Value
The object returned depends on type
.
See Also
Examples
# load data
data(survivalData)
data(PCGroups)
x <- survivalData$Exp
y <- survivalData$survData
PC.Human <- getPCGroups(Groups = PCGroups, Organism = "Human",
Type = "EntrezID")
set.seed(20150122)
idx.train <- sample(nrow(x), round(nrow(x)*2/3))
x.train <- x[idx.train,]
y.train <- y[idx.train,]
x.test <- x[-idx.train,]
y.test <- y[-idx.train,]
# fit cv.PCLasso model
cv.fit1 <- cv.PCLasso(x = x.train,
y = y.train,
group = PC.Human,
nfolds = 5)
# predict risk scores of samples in x.test
s <- predict(object = cv.fit1, x = x.test, type="link",
lambda=cv.fit1$cv.fit$lambda.min)
# Nonzero coefficients
sel.groups <- predict(object = cv.fit1, type="groups",
lambda = cv.fit1$cv.fit$lambda.min)
sel.ngroups <- predict(object = cv.fit1, type="ngroups",
lambda = cv.fit1$cv.fit$lambda.min)
sel.vars.unique <- predict(object = cv.fit1, type="vars.unique",
lambda = cv.fit1$cv.fit$lambda.min)
sel.nvars.unique <- predict(object = cv.fit1, type="nvars.unique",
lambda = cv.fit1$cv.fit$lambda.min)
sel.vars <- predict(object = cv.fit1, type="vars",
lambda=cv.fit1$cv.fit$lambda.min)
sel.nvars <- predict(object = cv.fit1, type="nvars",
lambda=cv.fit1$cv.fit$lambda.min)