Perform Harvey test for multiplicative heteroscedasticity¶
Source: man/performHarveyTest.Rd · Help: ?performHarveyTest
Harvey's (1976) Lagrange multiplier test, which regresses log(residuals^2) on a set of variance regressors.
Usage¶
Arguments¶
model- an object of class
lm. data- optional data frame the model was fitted to. When
NULL, the default, the model frame ofmodelis used. The statistic is computed from the residuals, fitted values and model matrix ofmodel, sodatadoes not change the result; it is accepted so that every test takes(model, data, ...). Before 0.15.0 the second argument wasauxiliaryand the thirdstudentize: a string passed second by position, and a logical value after it, are still read as those two, with a warning that shows the new call; that form stops working in 1.0.0. auxiliary- character scalar choosing the variance regressors.
"regressors"(the default) uses the model's own explanatory variables, the specification in Harvey (1976)."fitted"uses the fitted values and their square, which was the behaviour of releases before 0.7.0. studentize- logical; if
FALSE(the default) the chi-square statistic \(\mathrm{ESS} / (\pi^2 / 2)\) is reported, otherwise the auxiliary regression F statistic.
Value¶
An object of class htest containing the test statistic, its degrees of freedom and the p-value.
Details¶
Harvey (1976) models the error variance as \(\sigma_i^2 = \exp(z_i^\top \gamma)\) and tests \(\gamma = 0\) through the auxiliary regression of \(\log \hat{e}_i^2\) on \(z_i\). Under the null the auxiliary error behaves like a centred \(\log \chi^2_1\) variate with variance \(\pi^2 / 2 \approx 4.9348\), so the classical statistic is \(\mathrm{ESS} / (\pi^2 / 2)\), asymptotically chi-square with \(q\) degrees of freedom.
Setting studentize = TRUE replaces the fixed constant \(\pi^2 / 2\) with the auxiliary residual mean square and refers the overall F statistic to an F distribution. The two forms are asymptotically equivalent under normal errors; the studentized form is more reliable when normality is doubtful, because \(\pi^2 / 2\) is the null variance of \(\log \hat{e}^2\) only for Gaussian errors.
Degrees of freedom are taken from the realised rank of the auxiliary design, so a rank-deficient variance model is not credited with degrees of freedom for aliased columns.
Since 0.18.0 the test refuses an auxiliary regression that fits the log squared residuals exactly, by the rule and with the class of performKoenkerTest() (see its Exact fit): the classical statistic is then the total sum of squares over \(\pi^2 / 2\), a function of their spread alone, and the studentized F infinite. On 30 subjects of two observations, lm(y ~ treat + subject), whose squared residuals are equal in each pair, the regressors gave 63.07 on 30 degrees of freedom and the studentized form an infinite F. Only a fit the design forces is refused; one the data make exact gives a value, as up to 0.17.0.
Validation¶
The default statistic reproduces an independent reconstruction of Harvey (1976) to within 1e-8; see tests/testthat/test-pass-a-reference.R. Simulated size and power are recorded in inst/validation/pass-a-size-power.csv.
Supported models¶
It accepts an lm and a glm with the Gaussian family and the identity link, unweighted
or with positive weights, a fitWLS() fit and, since 0.16.0, a rank-deficient fit, which it
tests on the estimable part of its design: it gives the value of the same model fitted without the
aliased columns. It refuses a glm of another family or link, a survey::svyglm() fit, a
fit with a zero weight, a coefficient that is not finite for another reason, and data that
lack rows or variables of the fit. Since 0.16.0 it is built on the model context, and also refuses
a multivariate lm ("needs a model with one response"), a fit whose coefficients, residuals or
weights were changed after the fit, and a fit with model = FALSE whose model frame, rebuilt
from the data it was fitted to, no longer holds its response, because those data changed after the
fit, with or without data. A fit with model = FALSE whose data are gone is tested on
data that give its response and fitted values, and refused without them. The test reads
nothing from data, and since 0.16.0 matches it to the observations of the fit as every
test does: data with row names of their own in any order, data that number their rows (a tibble,
a data.table) in the order of the fit; other numbered data, rows in front of those of the fit and
repeated row names are refused, where it gave the value of the fit. Which model each test
accepts, and why, is set out in
test_results, under Supported models.
References¶
Harvey, A. C. (1976). Estimating regression models with multiplicative heteroscedasticity. Econometrica, 44(3), 461–465. doi:10.2307/1913974
Greene, W. H. (2018). Econometric Analysis (8th ed.). Pearson. Section 9.5 derives the \(\mathrm{ESS} / 4.9348\) form of the statistic.
See also¶
performParkTest, performGlejserTest, performBPTest