predict.lar: Prediction and coefficient functions for least angle...

Description Usage Arguments Value Author(s) Examples

View source: R/funs.lar.R

Description

Make predictions or extract coefficients from a least angle regression object

Usage

1
2
3
4
## S3 method for class 'lar'
predict(object, newx, s, mode=c("step","lambda"), ...)
## S3 method for class 'lar'
coef(object, s, mode=c("step","lambda"), ...)

Arguments

object

Object returned by a call to lar function (not the lars function!)

newx

Matrix of x values at which the predictions are desired. If NULL, the x values from least angle regression fitting are used

s

Step number(s) or lambda value(s) at which predictions or coefficients are desired

mode

Either "step" or "lambda", determining the role of s (above)

...

Additional arguments

Value

Either a vector/matrix of predictions, or a vector/matrix of coefficients.

Author(s)

Ryan Tibshirani, Rob Tibshirani, Jonathan Taylor, Joshua Loftus, Stephen Reid

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
set.seed(33)
n = 200
p = 20
sigma = 1
x = matrix(rnorm(n*p),n,p)
beta = c(rep(3,10),rep(0,p-10))
y = x%*%beta + sigma*rnorm(n)

# run lar and predict functions
obj = lar(x,y)
fit = predict(obj,x,s=3)

Example output

Loading required package: glmnet
Loading required package: Matrix
Loading required package: foreach
Loaded glmnet 2.0-16

Loading required package: intervals

Attaching package: 'intervals'

The following object is masked from 'package:Matrix':

    expand

Loading required package: survival

selectiveInference documentation built on Sept. 7, 2019, 9:02 a.m.