CVlm {DAAG}  R Documentation 
CrossValidation for Linear Regression
Description
This function gives internal and crossvalidation measures of predictive
accuracy for multiple linear regression. (For binary logistic
regression, use the CVbinary
function.) The data are
randomly assigned to a number of ‘folds’.
Each fold is removed, in turn, while the remaining data is used
to refit the regression model and to predict at the deleted observations.
Usage
CVlm(data = DAAG::houseprices, form.lm = formula(sale.price ~ area),
m = 3, dots = FALSE, seed = 29, plotit = c("Observed","Residual"),
col.folds=NULL,
main="Small symbols show crossvalidation predicted values",
legend.pos="topleft",
printit = TRUE, ...)
cv.lm(data = DAAG::houseprices, form.lm = formula(sale.price ~ area),
m = 3, dots = FALSE, seed = 29, plotit = c("Observed","Residual"),
col.folds=NULL,
main="Small symbols show crossvalidation predicted values",
legend.pos="topleft", printit = TRUE, ...)
Arguments
data 
a data frame 
form.lm 
a formula or 
m 
the number of folds 
dots 
uses pch=16 for the plotting character 
seed 
random number generator seed 
plotit 
This can be one of the text strings 
col.folds 
Per fold color settings 
main 
main title for graph 
legend.pos 
position of legend: one of

printit 
if TRUE, output is printed to the screen 
... 
Other arguments, to be passed through to the function 
Details
When plotit="Residual"
and there is more than one explanatory
variable, the fitted lines that are shown for the individual folds
are approximations.
Value
The input data frame is returned, with additional columns
Predicted
(Predicted values using all observations)
and cvpred
(crossvalidation predictions). The
crossvalidation residual sum of squares (ss
) and
degrees of freedom (df
) are returned as attributes of
the data frame.
Author(s)
J.H. Maindonald
See Also
Examples
CVlm()
## Not run:
CVlm(data=nihills, form.lm=formula(log(time)~log(climb)+log(dist)),
plotit="Observed")
CVlm(data=nihills, form.lm=formula(log(time)~log(climb)+log(dist)),
plotit="Residual")
out < CVlm(data=nihills, form.lm=formula(log(time)~log(climb)+log(dist)),
plotit="Observed")
out[c("ms","df")]
## End(Not run)