3

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.

blazej
  • 1,678
  • 3
  • 19
  • 41
  • Can you explain why you want this? It seems a bit like a misuse of the mixed-effects framework. Anyway, it might be appropriate to submit a bug report to the lmerTest maintainer. – Roland Jan 23 '18 at 11:52
  • Why would that be a misuse of mixed effects framework? Books I know (Finch(2014), Zuur(2009)) specify such models and don't mention any misuse while doing so. – blazej Jan 23 '18 at 12:23
  • They probably specify them as reference models to compare against. I wouldn't use such a model to get a p-value for the estimate of the population mean. – Roland Jan 23 '18 at 13:47
  • 1
    `lmer` intentionally leaves out p-values because calculating the df for multilevel models isn't that straightforward. I believe `lmerTest` only computes p-values for fixed effects other than the intercept (because the intercept is usually not a value of interest) hence it doesn't report a p-value. You can compute the p-value yourself from the t-value and the df (observations - groups) like nlme does – Niek Jan 23 '18 at 13:50
  • I know `lmer` leaves out p-values and I read `lmer` authors explanations. I just can't see any reason why computing p values with `lmerTest` drops an error when a null model is specified (everything works well for non `null` models). Don't want to call bugs here, but it does not seem logical to exclude `p value` from a `null` model on purpose – blazej Jan 23 '18 at 14:44

2 Answers2

2

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

1

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.

RolandASc
  • 3,863
  • 1
  • 11
  • 30