Last data update: 2014.03.03

R: predict function for LDCA
predict.LDCAR Documentation

predict function for LDCA

Description

predict function for LDCA

Usage

## S3 method for class 'LDCA'
predict(object, newx, s = NULL, type = c("link", "response", "coefficients", "nonzero", "class"), exact = FALSE, offset, ...)

Arguments

object

an LDCA object

newx

new data matrix

s

lambda value at which the prediction is returned.

type

Type of prediction required. Type "link" gives the linear predictors for "binomial", "multinomial", "poisson" or "cox" models; for "gaussian" models it gives the fitted values. Type "response" gives the fitted probabilities for "binomial" or "multinomial", fitted mean for "poisson" and the fitted relative-risk for "cox"; for "gaussian" type "response" is equivalent to type "link". Type "coefficients" computes the coefficients at the requested values for s. Note that for "binomial" models, results are returned only for the class corresponding to the second level of the factor response. Type "class" applies only to "binomial" or "multinomial" models, and produces the class label corresponding to the maximum probability. Type "nonzero" returns a list of the indices of the nonzero coefficients for each value of s.

exact

By default (exact=FALSE) the predict function uses linear interpolation to make predictions for values of s that do not coincide with those used in the fitting algorithm. Currently exact=TRUE is not implemented, but prints an error message telling the user how to achieve the exact predictions. This is done my rerunning the algorithm with the desired values interspersed (in order) with the values used in the original fit. This is easily achieved via the R command lamba=sort(c(object$lambda, new.lambda))

offset

If an offset is used in the fit, then one must be supplied for making predictions (except for type="coefficients" or type="nonzero")

...

other arguments.

Author(s)

Xiaolin Yang, Han Liu

Examples

library(glmnet)
x=matrix(rnorm(50*20),50,20)
y=rbinom(50,1,0.5)
cvfit=cv.LDCA(x,y,nfolds=5)
predict(cvfit,x[1:10,],s="lambda.min")

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(BigTSP)
Loading required package: glmnet
Loading required package: Matrix
Loading required package: foreach
Loaded glmnet 2.0-5

Loading required package: tree
Loading required package: randomForest
randomForest 4.6-12
Type rfNews() to see new features/changes/bug fixes.
Loading required package: gbm
Loading required package: survival
Loading required package: lattice
Loading required package: splines
Loading required package: parallel
Loaded gbm 2.1.1
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/BigTSP/predict.LDCA.Rd_%03d_medium.png", width=480, height=480)
> ### Name: predict.LDCA
> ### Title: predict function for LDCA
> ### Aliases: predict.LDCA
> ### Keywords: ~kwd1 ~kwd2
> 
> ### ** Examples
> 
> library(glmnet)
> x=matrix(rnorm(50*20),50,20)
> y=rbinom(50,1,0.5)
> cvfit=cv.LDCA(x,y,nfolds=5)
> predict(cvfit,x[1:10,],s="lambda.min")
         1
 [1,] 0.54
 [2,] 0.54
 [3,] 0.54
 [4,] 0.54
 [5,] 0.54
 [6,] 0.54
 [7,] 0.54
 [8,] 0.54
 [9,] 0.54
[10,] 0.54
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>