dufour_etal | R Documentation |
This function implements the method of \insertCiteDufour04;textualskedastic for testing for heteroskedasticity in a linear regression model.
dufour_etal(
mainlm,
hettest,
R = 1000L,
alternative = c("greater", "less", "two.sided"),
errorgen = stats::rnorm,
errorparam = list(),
seed = 1234,
...
)
mainlm |
Either an object of |
hettest |
A character specifying the name of a function
that implements a heteroskedasticity test on a linear regression model.
The function is called with the |
R |
An integer specifying the number of Monte Carlo replicates to
generate. Defaults to |
alternative |
The tailedness of the test whose statistic is computed by
|
errorgen |
A function, or a character specifying the name of a
function, from which the random errors are to be generated. The function
should correspond to a continuous probability distribution that has (or
at least can have) a mean of 0. Defaults to |
errorparam |
An optional list of parameters to pass to |
seed |
An integer specifying a seed to pass to
|
... |
Additional arguments to pass to function with name |
The test implements a Monte Carlo procedure as follows. (1) The
observed value of the test statistic T_0
is computed using function
with name hettest
. (2) R
replications of the random error
vector are generated from the distribution specified using
errorgen
. (3) R
replications of the test statistic,
T_1,T_2,\ldots,T_R
, are computed from the generated error vectors.
(4) The empirical p
-value is computed as
\frac{\hat{G}_R(T_0)+1}{R+1}
, where
\hat{G}_R(x)=\sum_{j=1}^{R} 1_{T_j \ge x}
, 1_{\bullet}
being the indicator function. The test is right-tailed, regardless of the
tailedness of hettest
. Note that the heteroskedasticity
test implemented by hettest
must have a test statistic that is
continuous and that is invariant with respect to nuisance parameters
(\omega
and \beta
). Note further that if hettest
is goldfeld_quandt
with method
argument
"parametric"
, the replicated Goldfeld-Quandt F
statistics
are computed directly within this function rather than by calling
goldfeld_quandt
, due to some idiosyncratic features of this test.
Note that, if alternative
is set to "two.sided"
, the
one-sided p
-value is doubled (twosidedpval
cannot
be used in this case).
An object of class
"htest"
. If object
is not assigned, its attributes are displayed in the console as a
tibble
using tidy
.
mtcars_lm <- lm(mpg ~ wt + qsec + am, data = mtcars)
dufour_etal(mtcars_lm, hettest = "breusch_pagan")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.