View source: R/simonoff_tsai.R
simonoff_tsai | R Documentation |
This function implements the modified profile likelihood ratio test and score test of \insertCiteSimonoff94;textualskedastic for testing for heteroskedasticity in a linear regression model.
simonoff_tsai( mainlm, auxdesign = NA, method = c("mlr", "score"), hetfun = c("mult", "add", "logmult"), basetest = c("koenker", "cook_weisberg"), bartlett = TRUE, optmethod = "Nelder-Mead", statonly = FALSE, ... )
mainlm |
Either an object of |
auxdesign |
A |
method |
A character specifying which of the tests proposed in
\insertCiteSimonoff94;textualskedastic to implement. |
hetfun |
A character describing the form of w(\cdot), the error
variance function under the heteroskedastic alternative. Possible values
are |
basetest |
A character specifying the base test statistic which is
robustified using the added term described in Details. |
bartlett |
A logical specifying whether a Bartlett correction should be
made, as per \insertCiteFerrari04;textualskedastic, to improve the
fit of the test statistic to the asymptotic null distribution. This
argument is only applicable where |
optmethod |
A character specifying the optimisation method to use with
|
statonly |
A logical. If |
... |
Optional arguments to pass to |
The Simonoff-Tsai Likelihood Ratio Test involves a modification of
the profile likelihood function so that the nuisance parameter will be
orthogonal to the parameter of interest. The maximum likelihood estimate
of λ (called δ in
\insertCiteSimonoff94;textualskedastic) is computed from the modified
profile log-likelihood function using the Nelder-Mead algorithm in
optim
. Under the null hypothesis of
homoskedasticity, the distribution of the test statistic is
asymptotically chi-squared with q degrees of freedom. The test is
right-tailed.
The Simonoff-Tsai Score Test entails adding a term to either the score
statistic of \insertCiteCook83;textualskedastic (a test implemented
in cook_weisberg
) or to that of
\insertCiteKoenker81;textualskedastic (a test implemented in
breusch_pagan
with argument koenker
set to
TRUE
), in order to improve the robustness of these respective
tests in the presence of non-normality. This test likewise has a test
statistic that is asymptotically χ^2(q)-distributed and the test
is likewise right-tailed.
The assumption of underlying both tests is that \mathrm{Cov}(ε)=ω W, where W is an n\times n diagonal matrix with ith diagonal element w_i=w(Z_i, λ). Here, Z_i is the ith row of an n \times q nonstochastic auxiliary design matrix Z. Note: Z as defined here does not have a column of ones, but is concatenated to a column of ones when used in an auxiliary regression. λ is a q-vector of unknown parameters, and w(\cdot) is a real-valued, twice-differentiable function having the property that there exists some λ_0 for which w(Z_i,λ_0)=0 for all i=1,2,…,n. Thus, the null hypothesis of homoskedasticity may be expressed as λ=λ_0.
In the score test, the added term in the test statistic is of the form
∑_{j=1}^{q} ≤ft(∑_{i=1}^{n} h_{ii} t_{ij}\right) τ_j
, where t_{ij} is the (i,j)th element of the Jacobian matrix J evaluated at λ=λ_0:
t_{ij}=≤ft.\frac{\partial w(Z_i, λ)}{\partial λ_j}\right|_{λ=λ_0}
, and τ=(\bar{J}'\bar{J})^{-1}\bar{J}'d, where d is the n-vector whose ith element is e_i^2\bar{ω}^{-1}, \bar{ω}=n^{-1}e'e, and \bar{J}=(I_n-1_n 1_n'/n)J.
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) simonoff_tsai(mtcars_lm, method = "score") simonoff_tsai(mtcars_lm, method = "score", basetest = "cook_weisberg") simonoff_tsai(mtcars_lm, method = "mlr") simonoff_tsai(mtcars_lm, method = "mlr", bartlett = FALSE) ## Not run: simonoff_tsai(mtcars_lm, auxdesign = data.frame(mtcars$wt, mtcars$qsec), method = "mlr", hetfun = "logmult") ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.