I'm curious about how lmerTest package in R, specifically the "rand" function, handles tests of random effects. Consider the example from the lmerTest pdf on CRAN that uses the built in "carrots" data set:
#import lme4 package and lmerTest package
library(lmerTest)
#lmer model with correlation between intercept and slopes
#in the random part
m <- lmer(Preference ~ sens2+Homesize+(1+sens2|Consumer), data=carrots)
# table with p-values for the random effects
rand(m)
The model specifies two random variances (the intercept and "sens2"), both nested in "Consumer," and the covariance between the intercept and "sens2." Output (not provided in the pdf) for the random components from the lmer run follows:
Random effects:
Groups Name Variance Std.Dev. Corr
Consumer (Intercept) 0.195168 0.44178
sens2 0.002779 0.05271 0.18
Residual 1.070441 1.03462
Number of obs: 1233, groups: Consumer, 103
Which is expected given the model specification. The output from the rand function follows:
Analysis of Random effects Table:
Chi.sq Chi.DF p.value
sens2:Consumer 6.99 2 0.03 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Given the random effects table, I think lmerTest is evaluating the random slope for "sens2" but it might also be the covariance between the slope and intercept. The test for the random intercept is not included. I estimated another model with only the random intercept (no random slope or covariance), and got the following from the "rand" statement:
Analysis of Random effects Table:
Chi.sq Chi.DF p.value
Consumer 79.6 1 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
The test for the random variance associated with the intercept is provided here. So, does anyone know what the test of the random variance components from the first model is testing? Is there a way that I can't see from the documentation to test all three of the random components? I should mention the page for the rand test at inside-R.org has the following confusing description (which I don't see in the pdf on CRAN):
Values
Produces a data frame with tests for the random terms being non-significant.
Note
If the effect has random slopes, then first the correlations between itercept [sic] and slopes are checked for significance
Is it possible the "Values" description has it backwards and that only significant effects are reported? I ran the "step" procedure and it wasn't clear if all three random variance components were considered in the run.
Any insight on the matter is greatly appreciated.
Joe
EDIT: The plot thickens a bit. It dawned on me to check a "diagonal" covariance structure (no covariance between the random intercept and slope) by using the following (based on this excellent post):
m2 <- lmer(Preference ~ sens2+Homesize+(1|Consumer)+(0+sens2|Consumer), data=carrots)
The lmer output for the random variances, using VarCorr, is as follows:
Groups Name Std.Dev.
Consumer (Intercept) 0.441807
Consumer.1 sens2 0.052719
Residual 1.034618
Which correctly omits the covariance (correlation) between the random slope and intercept. Running the "rand" function from lmerTest produces the following output:
Analysis of Random effects Table:
Chi.sq Chi.DF p.value
Consumer 84.4 1 <2e-16 ***
sens2:Consumer 6.3 1 0.01 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
So it will test the two variance components for this model. But the question remains regarding the first model with the random covariance. What is lmerTest testing?