yhat_gel: Elastic Net Regression Prediction

Description Usage Arguments Value Author(s) Examples

View source: R/yhat_gel.R

Description

Fit regression using 10-fold CV with the 1 standard deviation rule and compute predictions.

Usage

1
yhat_gel(dfTrain, dfTest, alpha = 1)

Arguments

dfTrain

Data frame for training data. Last column must be the output variable.

dfTest

Data frame for test data. Last column must be the output variable.

alpha

Must be in [0,1], alpha=1 for LASSO (default), alpha=0 for ridge regression. Another recommended choice is alpha=0.5.

Value

The predictions for the test sample

Author(s)

A. I. McLeod

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
Xy <- prostate
X <- prostate[,-9]
y <- prostate[,9]
n <- length(y)
d <- 10
set.seed(777513)
iTe <- sample(n, size=d)
iTr <- (1:n)[!match(1:n, iTe, nomatch = 0) > 0]
trdf <- data.frame(X[iTr,], y=y[iTr]) #X, y already defined
tedf <- data.frame(X[iTe,], y=y[iTe])
yhat_gel(trdf, tedf)

gencve documentation built on May 29, 2017, 7:12 p.m.