[R] cv.glm and "longer object length is not a multiple of shorter object length" error
ehlers at ucalgary.ca
Fri Jul 22 13:31:48 CEST 2011
On 2011-07-21 17:29, askantik wrote:
> I've done some searching where others have had trouble with this error (or
> "warning" actually), but I'm unable to solve my problem. I have a data
> sheet with 13 columns and 36 rows. Each column has exactly the same number
> of rows. I've created glms and now want to do cross-validation on 2 of
> them. Please be gentle-- I'm new to R (and statistics, too, for that
> matter). Any help is greatly appreciated. Here's my code:
> cv13.err<- cv.glm(nests,glm13)
> cv13.err.5<- cv.glm(nests,glm13,K=5)
> cv18.err<- cv.glm(nests,glm18)
> cv18.err.5<- cv.glm(nests,glm18,K=5)/
> I get errors starting with the glm18 part. glm13 is
> *total_species~RH+elev+RH*elev* and glm18 is *total_species~per_cover+RH*
> Does it have something to do with the two glms having different numbers of
> parameters? I'm not sure why it seems okay with what I've done for glm13,
> but not glm18. Thanks again for any help.
> *Warning messages:
> 1: In y - yhat :
> longer object length is not a multiple of shorter object length*
My guess is that per_cover contains at least one missing value.
You could try
I tried glm(..., na.action = na.exclude) but cv.glm() appears not (yet)
to be coded to handle padding of missing values.
> View this message in context: http://r.789695.n4.nabble.com/cv-glm-and-longer-object-length-is-not-a-multiple-of-shorter-object-length-error-tp3685622p3685622.html
> Sent from the R help mailing list archive at Nabble.com.
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help