bailsofhay — Nov 25, 2013, 5:58 PM
data=read.table("http://www.stat.lsu.edu/exstweb/statlab/datasets/KNNLData/CH09PR10.txt")
names(data)=c("y","x1","x2","x3","x4")
fit=lm(y~x1+x2+x3+x4, data=data)
fit
Call:
lm(formula = y ~ x1 + x2 + x3 + x4, data = data)
Coefficients:
(Intercept) x1 x2 x3 x4
-124.3818 0.2957 0.0483 1.3060 0.5198
library(DAAG)
Warning: package 'DAAG' was built under R version 3.0.2
Loading required package: lattice
cv=cv.lm(data,fit,25,printit=FALSE)
Warning:
As there is >1 explanatory variable, cross-validation
predicted values for a fold are not a linear function
of corresponding overall predicted values. Lines that
are shown for the different folds are approximate
Warning: unimplemented pch value '26'
Warning: unimplemented pch value '26'
Warning: unimplemented pch value '26'
Warning: unimplemented pch value '26'
Warning: unimplemented pch value '26'
Warning: unimplemented pch value '26'
Warning: unimplemented pch value '26'
Warning: unimplemented pch value '26'
Warning: unimplemented pch value '26'
Warning: unimplemented pch value '26'
Warning: unimplemented pch value '26'
Warning: unimplemented pch value '26'
Warning: unimplemented pch value '26'
Warning: unimplemented pch value '26'
Warning: unimplemented pch value '26'
Warning: unimplemented pch value '26'
Warning: unimplemented pch value '26'
Warning: unimplemented pch value '26'
Warning: unimplemented pch value '26'
Warning: unimplemented pch value '26'
Warning: unimplemented pch value '26'
Warning: unimplemented pch value '26'
Warning: unimplemented pch value '26'
Warning: unimplemented pch value '26'
Warning: unimplemented pch value '26'
Warning: unimplemented pch value '26'
Warning: unimplemented pch value '26'
press=sum((data$y-cv$cvpred)^2)
press
[1] 519
SSE=sum((data$y-cv$Predicted)^2)
SSE
[1] 336
# SSE is much smaller than PRESS which would indicate that it is assuming there is
# less unexpected error within the model, which would mean the the MSE validity is
# less accurate at predicting the predictive ability of the model compared to PRESS.