Skip to content

Rank-based permutation heteroscedasticity test

Source: R/modern_diagnostics.R ยท Help: ?performRankPermutationTest

Performs a non-parametric permutation test based on the rank correlation between absolute residuals and a chosen ordering variable. Significant correlations imply systematic changes in residual spread.

Usage

performRankPermutationTest(
  model,
  data = NULL,
  order_by = NULL,
  B = 999,
  progress = interactive()
)

Arguments

model
A fitted stats::lm object describing the mean structure whose residual variance is to be assessed.
data
A base::data.frame (or compatible object) containing the variables referenced in model. The data must include all observations used to fit model and should not contain unresolved missing values. When NULL, the default, the model frame of model is used. It holds the terms of the model rather than its variables (log(x) rather than x), so a model that transforms a variable needs data, as does a model with an offset() term, and so may a fit whose weights or offset argument is a column of the data, which the model frame holds as (weights) or (offset).
order_by
Optional name of a predictor variable used to rank the observations. Defaults to the first non-intercept term in the model matrix.
B
Number of permutation replications used to approximate the null distribution. Defaults to 999, the default of every resampling test in the package.
progress
Logical toggle for progress reporting during permutations.

Value

An htest object containing the observed Spearman correlation and a permutation-based p-value.

References

Hollander, M., Wolfe, D. A., & Chicken, E. (2013). Nonparametric Statistical Methods (3rd ed.). Wiley.

Examples

data(mtcars)
model <- lm(mpg ~ wt + hp, data = mtcars)
set.seed(42)
performRankPermutationTest(model, mtcars, B = 199, progress = FALSE)