Re: [R] cv.glm and "longer object length is not a multiple of shorter object length" error

2011-07-22 Thread Peter Ehlers

On 2011-07-21 17:29, askantik wrote:

Hi,

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:

/library(boot)
n<-length(total_species)
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

 cv.glm(na.omit(nests), glm18)

I tried glm(..., na.action = na.exclude) but cv.glm() appears not (yet)
to be coded to handle padding of missing values.

Peter Ehlers



--
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@r-project.org 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.


__
R-help@r-project.org 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.


[R] cv.glm and "longer object length is not a multiple of shorter object length" error

2011-07-21 Thread askantik
Hi,

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:

/library(boot)
n<-length(total_species)
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*

--
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@r-project.org 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.