goldfeld_quandt {skedastic} | R Documentation |
Goldfeld-Quandt Tests for Heteroskedasticity in a Linear Regression Model
Description
This function implements the two methods (parametric and nonparametric) of Goldfeld and Quandt (1965) for testing for heteroskedasticity in a linear regression model.
Usage
goldfeld_quandt(
mainlm,
method = c("parametric", "nonparametric"),
deflator = NA,
prop_central = 1/3,
group1prop = 1/2,
alternative = c("greater", "less", "two.sided"),
prob = NA,
twosidedmethod = c("doubled", "kulinskaya"),
restype = c("ols", "blus"),
statonly = FALSE,
...
)
Arguments
mainlm |
Either an object of |
method |
A character indicating which of the two tests derived in Goldfeld and Quandt (1965) should be implemented. Possible values are "parametric" and "nonparametric". Default is "parametric". It is acceptable to specify only the first letter. |
deflator |
Either a character specifying a column name from the
design matrix of |
prop_central |
A double specifying the proportion of central
observations to exclude from the F test (when |
group1prop |
A double specifying the proportion of remaining
observations (after excluding central observations) to allocate
to the first group. The default value of |
alternative |
A character specifying the form of alternative
hypothesis. If it is suspected that the
error variance is positively associated with the deflator variable,
|
prob |
A vector of probabilities corresponding to values of the test
statistic (number of peaks) from 0 to |
twosidedmethod |
A character indicating the method to be used to compute
two-sided |
restype |
A character specifying which residuals to use: |
statonly |
A logical. If |
... |
Optional further arguments to pass to |
Details
The parametric test entails putting the data rows in increasing
order of some specified deflator (one of the explanatory variables). A
specified proportion of the most central observations (under this
ordering) is removed, leaving a subset of lower observations and a subset
of upper observations. Separate OLS regressions are fit to these two
subsets of observations (using all variables from the original model).
The test statistic is the ratio of the sum of squared residuals from the
'upper' model to the sum of squared residuals from the 'lower' model.
Under the null hypothesis, the test statistic is exactly F-distributed
with numerator and denominator degrees of freedom equal to
(n-c)/2 - p
where n
is the number of observations in the
original regression model, c
is the number of central observations
removed, and p
is the number of columns in the design matrix (number of
parameters to be estimated, including intercept).
The nonparametric test entails putting the residuals of the linear model in
increasing order of some specified deflator (one of the explanatory
variables). The test statistic is the number of peaks, with the j
th
absolute residual |e_j|
defined as a peak if |e_j|\ge|e_i|
for all i<j
. The first observation does not constitute a peak. If
the number of peaks is large relative to the distribution of peaks under
the null hypothesis, this constitutes evidence for heteroskedasticity.
Value
An object of class
"htest"
. If object is
not assigned, its attributes are displayed in the console as a
tibble
using tidy
.
References
Goldfeld SM, Quandt RE (1965). “Some Tests for Homoscedasticity.” Journal of the American Statistical Association, 60(310), 539–547.
See Also
lmtest::gqtest
, another implementation
of the Goldfeld-Quandt Test (parametric method only).
Examples
mtcars_lm <- lm(mpg ~ wt + qsec + am, data = mtcars)
goldfeld_quandt(mtcars_lm, deflator = "qsec", prop_central = 0.25)
# This is equivalent to lmtest::gqtest(mtcars_lm, fraction = 0.25, order.by = mtcars$qsec)
goldfeld_quandt(mtcars_lm, deflator = "qsec", method = "nonparametric",
restype = "blus")
goldfeld_quandt(mtcars_lm, deflator = "qsec", prop_central = 0.25, alternative = "two.sided")
goldfeld_quandt(mtcars_lm, deflator = "qsec", method = "nonparametric",
restype = "blus", alternative = "two.sided")