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

Douglas Bates bates at stat.wisc.edu
Fri Jul 25 15:24:23 CEST 2008


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.
>



More information about the R-help mailing list