Bartlett Test for Homogeneity of Variances of Z-Residual
Source:R/test.var.bartl.R
test.var.bartl.RdPerforms Bartlett's test to assess whether the variance of Z-residuals differs across levels of a covariate. Numeric covariates with many distinct values are binned, and small or empty bins are removed before testing.
Details
The function handles covariates as follows:
If
fitted.valueis a factor or has fewer thank.blunique values, it is treated as categorical.Otherwise, numeric covariates are binned into
k.blbins.Bins with fewer than 3 observations are removed.
If insufficient bins remain, the covariate is log-transformed and binned again.
Bartlett's test is then applied to the Z-residuals grouped by the factor or binned covariate.