[R] There might be something wrong with cv.lm(DAAG)

From: 李俊杰 <klijunjie_at_gmail.com>
Date: Sat, 12 May 2007 11:01:00 +0800


Hi, everyone

When I was using cv.lm(DAAG) , I found there might be something wrong with it. The problem is that we can't use it to deal with a linear model with more than one predictor variable. But the usage documentation hasn't informed us about this.

You can find it by excuting the following code:

xx=matrix(rnorm(20*3),ncol=3)
bb=c(1,2,0)
yy=xx%*%bb+rnorm(20,0,10)

data=data.frame(y=yy,x=xx)
myformula=formula("y ~ x.1 + x.2 + x.3") cv.lm(data,myformula,m=10,plotit=F, printit=TRUE) myformula=formula("y ~ x.1 + x.2")
cv.lm(data,myformula,m=10,plotit=F, printit=TRUE) myformula=formula("y ~ x.1 ")
cv.lm(data,myformula,m=10,plotit=F, printit=TRUE)

What happened? they give three equal mss(mean squared error). Or you can just check the code of function cv.lm(DAAG), then you will find the residues are all derived from a model with only one predictor, but the coefficient of that only one predictor can be calculated from a model with more than one predictors which you've set in the formula term in cv.lm(DAAG),

-- 
Junjie Li,                  klijunjie_at_gmail.com
Undergranduate in DEP of Tsinghua University,

	[[alternative HTML version deleted]]

______________________________________________
R-help_at_stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Sat 12 May 2007 - 03:11:28 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 21 May 2007 - 03:31:33 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.