# NOT RUN {
# load data
data(classData)
data(PCGroups)
x <- classData$Exp
y <- classData$Label
PC.Human <- getPCGroups(Groups = PCGroups, Organism = "Human",
Type = "GeneSymbol")
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 PCLasso2 model
fit.PCLasso2 <- PCLasso2(x = x.train, y = y.train, group = PC.Human,
penalty = "grLasso", family = "binomial")
# predict risk scores of samples in x.test
s <- predict(object = fit.PCLasso2, x = x.test, type="link",
lambda=fit.PCLasso2$fit$lambda)
# predict classes of samples in x.test
s <- predict(object = fit.PCLasso2, x = x.test, type="class",
lambda=fit.PCLasso2$fit$lambda[10])
# Nonzero coefficients
sel.groups <- predict(object = fit.PCLasso2, type="groups",
lambda = fit.PCLasso2$fit$lambda)
sel.ngroups <- predict(object = fit.PCLasso2, type="ngroups",
lambda = fit.PCLasso2$fit$lambda)
sel.vars.unique <- predict(object = fit.PCLasso2, type="vars.unique",
lambda = fit.PCLasso2$fit$lambda)
sel.nvars.unique <- predict(object = fit.PCLasso2, type="nvars.unique",
lambda = fit.PCLasso2$fit$lambda)
sel.vars <- predict(object = fit.PCLasso2, type="vars",
lambda=fit.PCLasso2$fit$lambda)
sel.nvars <- predict(object = fit.PCLasso2, type="nvars",
lambda=fit.PCLasso2$fit$lambda)
# For values of lambda not in the sequence of fitted models,
# linear interpolation is used.
sel.groups <- predict(object = fit.PCLasso2, type="groups",
lambda = c(0.1, 0.05))
sel.ngroups <- predict(object = fit.PCLasso2, type="ngroups",
lambda = c(0.1, 0.05))
sel.vars.unique <- predict(object = fit.PCLasso2, type="vars.unique",
lambda = c(0.1, 0.05))
sel.nvars.unique <- predict(object = fit.PCLasso2, type="nvars.unique",
lambda = c(0.1, 0.05))
sel.vars <- predict(object = fit.PCLasso2, type="vars",
lambda=c(0.1, 0.05))
sel.nvars <- predict(object = fit.PCLasso2, type="nvars",
lambda=c(0.1, 0.05))
# }
Run the code above in your browser using DataLab