blazej
blazej

Reputation: 1788

Computing p-values for a null random effect model in lm4/lmerTest

Edit1: as reported by @RolandASc below there appears to be a bug in lmerTest. I already wrote an e-mail to the maintainer of the package reporting the issue.
Edit2: Maintainer response: "we are working on an update, where such issues hopefully will be dealt with in better ways…"

I'm trying to get p.values for a null random effect model using lme4 / lmerTest but can't figure out why they are not computed for a null model.

Using sleepstudy data I define the model as follows:

library(lmerTest)
lmer0 <- lmer(Reaction ~ 1 + (1|Subject), data = sleepstudy)

I'd expect that a call to summary(lmer0) would print a p.value for the intercept in fixed effects - but lmerTest fails doing so and actually calling a summary from lme4:

> summary(lmer0)
summary from lme4 is returned
some computational error has occurred in lmerTest
Linear mixed model fit by REML ['lmerMod']
Formula: Reaction ~ 1 + (1 | Subject)
   Data: sleepstudy

REML criterion at convergence: 1904.3

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-2.4983 -0.5501 -0.1476  0.5123  3.3446 

Random effects:
 Groups   Name        Variance Std.Dev.
 Subject  (Intercept) 1278     35.75   
 Residual             1959     44.26   
Number of obs: 180, groups:  Subject, 18

Fixed effects:
            Estimate Std. Error t value
(Intercept)   298.51       9.05   32.98

If I where to use nlme for same model everything looks right:

library(nlme)
lme0 <- lme(Reaction ~ 1, random = ~1|Subject, data = sleepstudy)
summary(nlme0)
Linear mixed-effects model fit by REML
 Data: df 
       AIC      BIC    logLik
  1910.327 1919.889 -952.1633

Random effects:
 Formula: ~1 | Subject
        (Intercept) Residual
StdDev:    35.75385 44.25907

Fixed effects: Reaction ~ 1 
               Value Std.Error  DF  t-value p-value
(Intercept) 298.5079  9.049936 162 32.98453       0

Standardized Within-Group Residuals:
       Min         Q1        Med         Q3        Max 
-2.4983313 -0.5501348 -0.1475698  0.5122894  3.3445880 

Number of Observations: 180
Number of Groups: 18 

P.S. If this question better fits CrossValidated, please let me know, and I'll move it there. Thank you.

Upvotes: 3

Views: 997

Answers (2)

Rune H Christensen
Rune H Christensen

Reputation: 136

As one of the lmerTest developers I can confirm that this is indeed a bug.

It is also fixed in the development version on GitHub (https://github.com/runehaubo/lmerTest) which you may install with

library("devtools")
install_github("runehaubo/lmerTest")

Please raise potential future bugs on GitHub as well.

Br Rune

Upvotes: 2

RolandASc
RolandASc

Reputation: 3923

It is a bug in lmerTest:::calcSummary.

It is expecting result to be a matrix, which in your case is however reduced to a vector.

Looks like a fairly simple fix.

Upvotes: 1

Related Questions