Re: [R] glht after lmer with "$S4class-" and "missing model.matrix-" errors

From: Douglas Bates <bates_at_stat.wisc.edu>
Date: Fri, 25 Jul 2008 08:24:23 -0500

You have a mismatch between glht and the model fit by lmer. A model fit by lmer is an object of an S4 class (that's what the "4" in the package name "lme4" is to indicate). The glht function, or possibly a default method for that generic, is treating the model as an S3 class object.

Also, you should pay attention to that warning about the estimate of the variance-covariance matrix of the random effects being singular. You need to reconsider the model before trying to do multiple comparisons.

On Fri, Jul 25, 2008 at 4:27 AM, Anna Radtke <annaradtke2309_at_googlemail.com> wrote:
> Hello everybody.
> In my case, calculating multiple comparisons (Tukey) after lmer
> produced the following two errors:
>
>> sv.mc <- glht(model.sv,linfct=mcp(comp="Tukey"))
> Error in x$terms : $ operator not defined for this S4 class
> Error in factor_contrasts(model) :
> no 'model.matrix' method for 'model' found!
>
> What I have done before:
>
>> sv.growth <- groupedData(length~meas|box_id,outer=~comp,data=sv.growth)
>> model.sv <- lmer(length~comp+(meas|box_id),data=sv.growth)
> Warning message:
> In .local(x, ..., value) :
> Estimated variance-covariance for factor 'box_id' is singular
>> summary(model.sv)
> Linear mixed-effects model fit by REML
> Formula: length ~ comp + (meas | box_id)
> Data: sv.growth
> AIC BIC logLik MLdeviance REMLdeviance
> 1587 1606 -786.4 1605 1573
> Random effects:
> Groups Name Variance Std.Dev. Corr
> box_id (Intercept) 466698.1 683.153
> meas 230733.7 480.347 -1.000
> Residual 9138.3 95.595
> number of obs: 120, groups: box_id, 40
> Fixed effects:
> Estimate Std. Error t value
> (Intercept) 600.90 21.31 28.196
> comproot -124.84 30.14 -4.142
> compshoot -167.36 30.14 -5.553
> compxfull -375.13 30.14 -12.446
> Correlation of Fixed Effects:
> (Intr) comprt cmpsht
> comproot -0.707
> compshoot -0.707 0.500
> compxfull -0.707 0.500 0.500
>
> Thanks for youR help in advance.
> Anna
>
> ______________________________________________
> R-help_at_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_at_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. Received on Fri 25 Jul 2008 - 13:39:12 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 25 Jul 2008 - 14:32:31 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive