glmPenaltyPred: Predict the generalized linear model with a vector of penalty...

Description Usage Arguments Examples

View source: R/elnglm.R

Description

Predict the generalized linear model with a vector of penalty parameters.

Usage

1
glmPenaltyPred(object, xnew, type = c("response", "probability", "link"))

Arguments

object

the vector of the response variable.

xnew

the matrix of the predictors.

type

string. One of the response families, "response", "probability" or "link".

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# Generate data of continuous response
trueb0 <- 1
trueact <- c(1, 1, 1, 0, 0, 0, 0, 0, 0, 0)
trueb <- runif(10, -1, 1)*10
trueb[which(trueact == 0)] <- 0
df <- glmDataGen(n = 500, d = 10, family = "gaussian", trueb0, trueb, s = 0.5, seed = 1)

# Run cross-validation
mdlcv <- glmPenaltyCV(y = df$y, x = df$x, family = "gaussian", lambdaLength = 200,
                      minLambdaRatio = 1e-3, maxit = 1e5, tol = 1e-7, alpha = 0.5, nfolds = 10, ver = "arma")
# Predict for new data
xnew <- matrix(rnorm(10), 1, 10)
yp <- glmPenaltyPred(mdlcv, xnew)
yp[,mdlcv$lambdaBestId]

PingYangChen/elnglm documentation built on Jan. 6, 2022, 5:50 a.m.