# Figured out models but issues with object not being found and dredge command

After some amazing help, especially from @jbowman, I was ready to get into my models but have hit a snag that I don't understand. I decided to try package MuMIn as it works with lme4 so that I am able to do all the models in once shot rather than running them each one at a time. However apart from loading it and then loading lme4 I have not had a chance to use it as I am getting an error and not sure why. Could someone please look at the code and see what I am doing wrong? My original post is here https://stats.stackexchange.com/questions/24971/mixed-effects-model-equations

It is basically telling me that it cannot find "Feeding" but when I type in the name of the df it lists all columns. So I tried to enter it as a factor (not as.factor) as you can see with no effect. I would like to attach my .csv file but I don't see an option to do this. :(

Here is what I am getting

> local({pkg <- select.list(sort(.packages(all.available = TRUE)),graphics=TRUE)
+ if(nchar(pkg)) library(pkg, character.only=TRUE)})
Warning message:
package ‘MuMIn’ was built under R version 2.14.1
> local({pkg <- select.list(sort(.packages(all.available = TRUE)),graphics=TRUE)
+ if(nchar(pkg)) library(pkg, character.only=TRUE)})

Attaching package: ‘Matrix’

The following object(s) are masked from ‘package:base’:

det

Attaching package: ‘lme4’

The following object(s) are masked from ‘package:stats’:

AIC, BIC

> ABMtest.df$Brood<-as.factor(ABMtest.df$Brood)
> ABMtest.df$Site<-as.factor(ABMtest.df$Site)
> ABMtest.df$Age.class<-as.factor(ABMtest.df$Age.class)
> ABMtest.df$MF.vs.OF<-as.factor(ABMtest.df$MF.vs.OF)
> ABMtest.df$tide.h.l<-as.factor(ABMtest.df$tide.h.l)
> fm2test<-lmer(Feeding~MF.vs.OF+Age.class+tide.h.l+Site+HDp+(1|Brood))
> ABMtest.df$Feeding<-factor(ABMtest.df$Feeding)
> fm2test<-lmer(Feeding~MF.vs.OF+Age.class+tide.h.l+Site+HDp+(1|Brood))
>


Last time after I listed everything I finally got it to run (but not sure how because i cannot replicate this. But last time I then typed the code:

ms2test<-dredge(fm2test, trace=TRUE, rank="AICc", REML=FALSE)


Which is supposed to give me the ranks of all the models using AICc and allows me to list the models etc. but it says something like not being able to find class "mer" with fixef. I have no idea.

If someone could see why Feeding is not recognised, or is this because I didn't list first? And then anyone who is familiar with the dredge command help with that then it would greatly appreciated.

• I just got it to work as I added ,data=ABMtest.df after (1|brood). Could adding the Feeding as a factor (not as.factor) have cause harm though? However I am still having an issue: > fm2test<-lmer(Feeding~MF.vs.OF+Age.class+tide.h.l+Site+HDp+(1|Brood), data=ABMtest.df) > ms2test<-dredge(fm2test, trace=TRUE, rank="AICc", REML=FALSE) 1 : lmer(formula = Feeding ~ (1 | Brood), data = ABMtest.df) Error in UseMethod("fixef") : no applicable method for 'fixef' applied to an object of class "mer" – Dragonwalker Mar 23 '12 at 20:40
• Technically I could run all the models by hand, but as I have about 10 factors for each it would take forever. :( – Dragonwalker Mar 23 '12 at 20:45

fm2test<-lmer(Feeding~MF.vs.OF+Age.class+tide.h.l+Site+HDp+(1|Brood), data=ABMtest.df)

• As in my comments, I had fixed that but then I got the mer error. I then re ran the whole thing again and just named the data frame ABMtest rather than ABMtest.df and everything ran fine. Is that an issue? All the examples just use a name not .df – Dragonwalker Mar 24 '12 at 0:36
• There are two options: fm1 <- lm(y ~ ., data = Cement) ms1 <- dredge(fm1) plot(ms1) model.avg(ms1, subset = delta < 4) confset.95p <- get.models(ms1, cumsum(weight) <= .95) avgmod.95p <- model.avg(confset.95p) summary(avgmod.95p) confint(avgmod.95p) But would this work with lmer? OR – Dragonwalker Mar 24 '12 at 1:10
• #Model-averaging mixed models library(nlme) data(Orthodont, package = "nlme") # Fit model by REML fm2 <- lme(distance ~ Sex*age, data = Orthodont, random = ~ 1 | Subject, method = "REML") # Model selection: ranking by AICc using ML ms2 <- dredge(fm2, trace = TRUE, rank = "AICc", REML = FALSE) (attr(ms2, "rank.call")) # Get the models (fitted by REML, as in the global model) fmList <- get.models(ms2, 1:4) # Because the models originate from ’dredge(..., rank = AICc, REML = FALSE)’, # the default weights in ’model.avg’ are ML based: summary(model.avg(fmList)) – Dragonwalker Mar 24 '12 at 1:10