Learn R Programming

gencve (version 0.3)

yhat_step: Backward Stagewise Regression with AIC or BIC

Description

Fits a subset regression model using backward stagewise regression to training data and computes the predictions for the test data.

Usage

yhat_step(dfTrain, dfTest, ic = c("BIC", "AIC"))

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.
ic
Information criterion to use to select the number of components. Default is BIC.

Value

Examples

Run this code
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_step(trdf, tedf)

Run the code above in your browser using DataLab