5
$\begingroup$

I'm fitting a model with a 2-level categorical and a numerical predictor. As far as I'm concerned, I cannot use car::LeveneTest() to assess homoscedasticity since I have a numerical predictor, right? What should I use instead to assess homoscedasticity on both numerical and categorical predictors?

  • expected error:
car::leveneTest(lmer(SCORE ~ EXAM_GRADE * TASK_TYPE + (1|ID), data = dfModels1, REML = F))

Error in leveneTest.default(lmer(SCORE ~ EXAM_GRADE  * TASK_TYPE + (1 |  : 
  lmer(SCORE ~ EXAM_GRADE  * TASK_TYPE + (1 | ID), data = dfModels1, REML = F) is not a numeric variable
  • head(dfModels1):

Each ID has a SCORE on two different TASKs. They also have a score on another Exam Grade. The basic idea is that Exam Grade predicts SCORE independenly of the task type.

ID      SCORE    EXAM_GRADE    TASK_TYPE    
  <chr>  <dbl>    <dbl>            <fct>         
1 1_101   7.1      100             A          
2 1_101   4.92     100             N   
1 2_101   7.4      36              A         
2 2_101   7        36              N   
  • Maybe the Breusch-Pagan test (such as performance::check_heteroscedasticity() does?)

  • Obs: I'm aware that I should prefer visual inspection instead, I'm also doing that, but I'd like to find a way to assess the assumption numerically as well just in case.

$\endgroup$
5
  • $\begingroup$ Of what? The features don’t need equal variance. $\endgroup$
    – Dave
    Commented Nov 21, 2022 at 19:20
  • $\begingroup$ hi, @Dave , what do you mean? I meant checking for homoscedasticity for lmers/lms by a test as an additional to checking the plots... $\endgroup$ Commented Nov 22, 2022 at 15:39
  • $\begingroup$ Checking what for homoskedasticity? $\endgroup$
    – Dave
    Commented Nov 22, 2022 at 15:43
  • $\begingroup$ yes, checking if I met the assumption. I know how to interpret a residual versus fitted plot for that, but I'm wondering about a test for that too, such as Levene's $\endgroup$ Commented Nov 22, 2022 at 15:48
  • $\begingroup$ Checking what for homoskedasticity? $\endgroup$
    – Dave
    Commented Nov 22, 2022 at 16:31

1 Answer 1

6
$\begingroup$

"Detecting heteroscedasticity" is a kind of magical thinking.

As you might expect, there's only one way that variance can be homoscedastic in a sample, but there are infinite ways it may be heteroscedastic. The assumption that heteroscedasticity would be apparent in measured covariates is tenuous enough. More realistically, there are exogenous trends that don't show up in the covariates but do impact analyses.

Add the issue of calibrating an actual hypothesis test and identifying a suitable number of subgroups, it quickly slips out of hand. Consider the large sample size dilemma - at large enough $N$ virtually every assumption-based test fails, but this barely precludes the value of the analysis. Essentially, you punish yourself for having good data.

I often find I can simulate data with a known failure of assumptions yet with standard parametric models, I obtain reasonable precise estimates, well conserved interval estimates, and powerful and well calibrated tests.

Does this mean one should not assess their assumptions? Clearly not. But somehow in the statistics pedagogy, "assessing assumptions" has been equated to conducting tests, which apropos of nothing we can't rely on those $p$-values at all.

Infinitely more valuable are the residual plots - residual versus covariate, and residual versus fitted, residual versus leverage, and so on. Correlation between sites or over time can be compared using the ICC or variograms (note: correlation functionally is similar to heteroscedasticity). On the chance that variance does depend on any such feature, a visual or quantitative summary should suffice. I've never had to report the actual results in the form of a statistical test for any published research manuscript.

If the goal of model fitting is inference rather than prediction, the robust variance estimate, also called Huber White or Sandwich variance errors, provide accurate 95% CIs and p-values even in the presence of heteroscedasticity, at barely any impact to power. I would say that this issue has been almost completely resolved as a consequence of these error estimators. In stata, you enter , robust=TRUE. In R, using the sandwich and lmtest package, you can enter waldtest with vcov=VCOVHC to obtain robust errors.

$\endgroup$
3
  • $\begingroup$ Do you know any references for this issue with equality of variance tests? Ive seen this as well, where large samples flag even miniscule deviations in normality or heteroscedascity, but I do wonder about being asked this by journal editors some day $\endgroup$ Commented Nov 21, 2022 at 19:42
  • 1
    $\begingroup$ @ShawnHemelstrand there's no citation that I know of. As I said there's a billion forms of model deviations, hence a billion tests calibrated to detect a specific form of deviation. The paper from Lumley, "The importance of the normality assumption in large public health data sets" is an illuminating read on the subject of assumptions tests. In my experience, when it comes up from a reviewer (rarely), I respond that we fit extensive plots and are confident the data are suitable to the proposed model. Alternately, I use sandwich errors for almost every analysis I do. $\endgroup$
    – AdamO
    Commented Nov 21, 2022 at 19:49
  • $\begingroup$ That makes sense. Thanks and I will check out that article. $\endgroup$ Commented Nov 21, 2022 at 19:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.