predict_glmlasso: Prediction of Lasso logistics regression

Description Usage Arguments Value Examples

View source: R/Lasso-function.R

Description

Prediction of Lasso logistics regression

Usage

1
predict_glmlasso(fit, newdata, type = "response", threshold = 0.5)

Arguments

fit

fitted object from glmlasso

newdata

a data frame in which to look for variables with which to predict.

type

the type of prediction required. The default is on the scale of the response variable. type="class" gives the predicted classification result

threshold

Threshold values decided for classification

Value

if type="class" a vector of predicted class will be returned. Otherwise return a vector of raw probability.

Examples

1
2
3
4
5
6
7
8
9
set.seed(1232)
Nz = 500
pz = 10
Xz = scale(matrix(rnorm(Nz*pz), ncol=pz))
bz = c(.5, -.5, .25, -.25, .125, -.125, rep(0, pz-6))
yz = rbinom(Nz,1,exp(Xz %*% bz)/(1+exp(Xz %*% bz)))
lambda = .1
fit1 <- glmlasso(Xz,yz,lambda,tol=1e-12)
pred <- predict_glmlasso(fit1,newdata = Xz)

lcw68/G3proj documentation built on Dec. 21, 2021, 9:46 a.m.