Search This Blog

Tuesday, March 27, 2012

R: Cross-Validation for Linear Regression


cv.lm {DAAG}R Documentation

Cross-Validation for Linear Regression

Description

This function gives internal and cross-validation measures of predictive accuracy for ordinary linear regression. The data are randomly assigned to a number of `folds'. Each fold is removed, in turn, while the remaining data is used to re-fit the regression model and to predict at the deleted observations.

Usage

cv.lm(df = houseprices, m = 3, form.lm = formula(sale.price ~ area), dots = FALSE,
 seed = 29)

Arguments

df a data frame
m the number of folds
form.lm a formula object
dots uses pch=16 for the plotting character
seed random number generator seed

Value

For each fold, a table listing








the residuals
ms = the overall mean square of prediction error

Author(s)

J.H. Maindonald

See Also

lm

Examples

data(houseprices)
cv.lm()

No comments:

Post a Comment

Thank you