Hi:
You need the second variable in D1 to be named fGRAZE - the variable names
in the newdata data frame (D1) have to be the same as the variable names on
the RHS of the model formula, in this case L.AREA and fGRAZE.
HTH,
Dennis
On Thu, Mar 3, 2011 at 7:43 AM, Heike Schmitz
<schmitzh@uni-bremen.de>wrote:
> Dear R- Community,
>
> to learn i reanalysed some data provided and analysed by Zuur et. al. in
> their book "Mixed effect models and Extensions in Ecology with
R". When i
> run the last command i get a warning message i dont understand.
>
>
> Loyn<- read.table(file = "loyn.txt",header = TRUE)
> Loyn$L.AREA<- log10(Loyn$AREA)
> fGRAZE <-factor(Loyn$GRAZE)
>
> M0<- lm(ABUND~ L.AREA + fGRAZE, data = Loyn)
> summary(M0)
>
> plot(x = Loyn$L.AREA, y = Loyn$ABUND,
> xlab = "Log transformed AREA",
> ylab = "Bird Abundance")
>
> D1<- data.frame(L.AREA= Loyn$L.AREA[Loyn$GRAZE==1], fGraze =
"1")
> P1<- predict(M0,newdata = D1)
>
> Warning message:
> Error in model.frame.default(Terms, newdata, na.action = na.action, xlev
> object$xlevels) :
> variable lengths differ (found for 'fGRAZE')
> In addition: Warning message:
> 'newdata' had 13 rows but variable(s) found have 56 rows
>
> I hope anyone has an idea.
> Thank you in advance.
> Heike
>
> --
> Heike Schmitz- Diaspero
> Population Ecology and Evolutionary Ecology Lab, FB2
> University of Bremen
> Leobener Strasse, Nw2, Room B4050
> D-28359 Bremen
> Germany
> fon ++49-421-218-62937
> email: heike.schmitz@uni-bremen.de
>
> http://www.popecol.uni-bremen.de
>
> ______________________________________________
> 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.
>
[[alternative HTML version deleted]]