ncvMLM {CR2} | R Documentation |
Testing for nonconstant variance (ncv)
Description
Function to detect heteroscedasticity in two-level random intercept models.
Uses a generalization of the Breusch-Pagan-type (using squared residuals)
and Levene-type test (using the absolute value of residuals). Note: this will
not tell you if including random slopes are warranted (for that, use the
robust_mixed
) function and compare differences in model-based and
robust standard errors.
Usage
ncvMLM(mx, bp = TRUE)
Arguments
mx |
The |
bp |
Computes a Breusch-Pagan-type test ( |
Value
A p-value (p < .05 suggests heteroskedasticity).
References
Huang, F., Wiedermann, W., & Zhang, B. (2022). Accounting for Heteroskedasticity Resulting from Between-group Differences in Multilevel Models. Multivariate Behavioral Research.
Examples
require(lme4)
data(sch25)
ncvMLM(lmer(math ~ byhomewk + male + ses + (1|schid), data = sch25)) #supported
ncvMLM(lmer(math ~ byhomewk + male + ses + minority + (1|schid), data = sch25)) #hetero
[Package CR2 version 0.2.1 Index]