horn {skedastic} | R Documentation |
Horn's Test for Heteroskedasticity in a Linear Regression Model
Description
This function implements the nonparametric test of Horn (1981) for testing for heteroskedasticity in a linear regression model.
Usage
horn(
mainlm,
deflator = NA,
restype = c("ols", "blus"),
alternative = c("two.sided", "greater", "less"),
exact = (nres <= 10),
statonly = FALSE,
...
)
Arguments
mainlm |
Either an object of |
deflator |
Either a character specifying a column name from the
design matrix of |
restype |
A character specifying which residuals to use: |
alternative |
A character specifying the form of alternative
hypothesis; one of |
exact |
A logical. Should exact |
statonly |
A logical. If |
... |
Optional further arguments to pass to |
Details
The test entails specifying a 'deflator', an explanatory variable
suspected of being related to the error variance. Residuals are ordered
by the deflator and the nonparametric trend statistic
D=\sum (R_i - i)^2
proposed by
Lehmann (1975) is
then computed on the absolute residuals and used to test for an
increasing or decreasing trend, either of which would correspond to
heteroskedasticity. Exact probabilities for the null distribution of
D
can be obtained from functions dDtrend
and
pDtrend
, but since computation time increases rapidly with
n
, use of a normal approximation is recommended for n>10
.
Lehmann (1975) proves that D
is
asymptotically normally distributed and the approximation of the
statistic Z=(D-E(D))/\sqrt{V(D)}
to the standard normal
distribution is already quite good for n=11
.
The expectation and variance of D
(when ties are absent) are
respectively E(D)=\frac{n^3-n}{6}
and
V(D)=\frac{n^2(n+1)^2(n-1)}{36}
; see
Lehmann (1975) for E(D)
and V(D)
when ties are present. When ties are absent, a continuity correction
is used to improve the normal approximation. When
exact distribution is used, two-sided p
-value is computed by
doubling the one-sided p
-value, since the distribution of D
is symmetric. The function does not support the exact distribution of
D
in the presence of ties, so in this case the normal approximation
is used regardless of n
.
Value
An object of class
"htest"
. If object is
not assigned, its attributes are displayed in the console as a
tibble
using tidy
.
References
Horn P (1981).
“Heteroscedasticity of Residuals: A Non-Parametric Alternative to the Goldfeld-Quandt Peak Test.”
Communications in Statistics - Theory and Methods, 10(8), 795–808.
Lehmann EL (1975).
Nonparametrics: Statistical Methods Based on Ranks.
Holden-Day, San Francisco.
Examples
mtcars_lm <- lm(mpg ~ wt + qsec + am, data = mtcars)
horn(mtcars_lm, deflator = "qsec")
horn(mtcars_lm, deflator = "qsec", restype = "blus")