On 14-02-25 08:46 PM, Michael Williamson wrote:
Good Morning, I?ve been trying to get some predictive values put f my model using a code my colleague gave me. We have similar sets of data but ti doesn?t seem to be working for me and I?m getting the same error.
I'm taking the liberty of sending this to the r-sig-mixed-models list, which is probably a better forum.
My model codes is quite simple and is LongDiveTrModAtt <- lmer(Log10LagTime ~ Depth+AttBoatPhs+(1|FocalID), data=LongDiveTr,na.action=na.omit). I then run the following code using a dataset I?ve already created (Graph_LDAtt) which has a column for AttBoatPhs (with 5 types of boatphase) and Depth (with an average depth for each boat phase). PredictLogDive <- predict(LongDiveTrModAtt, Graph_LDAtt, level=0) But I get this error Error in factor(FocalID) : object 'FocalID' not found In addition: Warning message: In predict.merMod(LongDiveTrModAtt, Graph_LDAtt, level = 0) : unused arguments ignored I thought by putting level=0 that should take account of the random effect of the FocalID. It?s working for my colleague and neither of su are sure why it is not working here.
You seem to be mixing the syntax for predict.lme, from the nlme package, with the syntax for predict.merMod, from the lme4 package. lme uses level=[integer], because lme is largely restricted to fitting models where there are discretely definable levels (i.e., nested random effects). predict.merMod instead uses a REform argument (switched to re.form in the development version) which can be specified as NA or ~0 to predict at the population level. (This is also why you get a warning about unused arguments being ignored ...) It's hard for me to see how this could be working correctly for your colleague ... unless they're using lme instead of lmer, in which case their model would have to be quite different: lme(Log10LagTime ~ Depth+AttBoatPhs, random= ~1|FocalID, data=LongDiveTr,na.action=na.omit) Ben Bolker