ridge.cv: Ridge Regression.

Description Usage Arguments Value Author(s) See Also Examples

Description

This function computes the optimal ridge regression model based on cross-validation.

Usage

1
ridge.cv(X, y, lambda, scale = TRUE, k = 10, plot.it = FALSE)

Arguments

X

matrix of input observations. The rows of X contain the samples, the columns of X contain the observed variables

y

vector of responses. The length of y must equal the number of rows of X

lambda

Vector of penalty terms.

scale

Scale the columns of X? Default is scale=TRUE.

k

Number of splits in k-fold cross-validation. Default value is k=10.

plot.it

Plot the cross-validation error as a function of lambda? Default is FALSE.

Value

intercept

cross-validation optimal intercept

coefficients

cross-validation optimal regression coefficients

lambda.opt

optimal value of lambda.

Author(s)

Nicole Kraemer

See Also

ridge.net

Examples

1
2
3
4
5
n<-100 # number of observations
p<-60 # number of variables
X<-matrix(rnorm(n*p),ncol=p) 
y<-rnorm(n)
ridge.object<-ridge.cv(X,y)

Example output

Loading required package: MASS
Loading required package: glmnet
Loading required package: Matrix
Loading required package: foreach
Loaded glmnet 2.0-12

Loading required package: ppls
Loading required package: splines
Loading required package: Epi

Attaching package: 'Epi'

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

    merge.data.frame

Loading required package: GeneNet
Loading required package: corpcor
Loading required package: longitudinal
Loading required package: fdrtool

parcor documentation built on May 1, 2019, 9:10 p.m.