This might be a better post for "Cross Validated" so I will post it there too, so I apologize if this is out of the scope of this discussion board.
I am working with the lme4
package and would like to test the significance of the random effect. I am using the RLRsim
package to generate an estimate of the p-value, consistent with recommendations in the documentation for lme4
. Within RLRsim
, I will use the exactRLRT
to test the significance of a random slope.
First, I estimated the full model:
data(sleepstudy, package = "lme4")
x <- lme4::lmer(Reaction ~ I(Days-4.5) + (I(Days-4.5)|Subject),
data = sleepstudy)
Next, I want to test the significance of the random effect on I(Days-4.5)
m0 <- update(x, . ~ . -(I(Days-4.5)|Subject) + (1|Subject))
m.slope <- update(x, . ~ . - (I(Days-4.5)|Subject) + (0 + I(Days-4.5)|Subject))
#test for subject specific slopes:
exactRLRT(m.slope, x, m0)
However, this leads to an error message Random effects not independent - covariance(s) set to 0 under H0. exactRLRT can only test a single variance.
So evidently I cannot use this method when the random effects are not independent. I can re-specify the model:
mA <- lme4::lmer(Reaction ~ I(Days-4.5) + (1|Subject) + (0 + I(Days-4.5)|Subject),
data = sleepstudy)
m0 <- update(mA, . ~ . - (0 + I(Days-4.5)|Subject))
m.slope <- update(mA, . ~ . - (1|Subject))
#test for subject specific slopes:
exactRLRT(m.slope, mA, m0)
and this is able to give me an estimate. However, my understanding is that running the random effects as independent is a fundamentally different model than the one I originally estimated, so I am certain this p-value from the output is not valid.
I am not sure what I can do (if anything) to test the significance of the random effect if they are not assumed to be independent. I am using the sleepstudy
data here as an example, but my actual dataset runs into convergence problems when I estimate the random effects as independent.
Any insight on this would be greatly appreciated!
Update
Here is a link to the question I posted on "Cross Validated".