rackauskas_zuokas {skedastic} | R Documentation |
Rackauskas-Zuokas Test for Heteroskedasticity in a Linear Regression Model
Description
This function implements the two methods of
Rackauskas and Zuokas (2007) for testing for heteroskedasticity
in a linear regression model.
Usage
rackauskas_zuokas(
mainlm,
alpha = 0,
pvalmethod = c("data", "sim"),
R = 2^14,
m = 2^17,
sqZ = FALSE,
seed = 1234,
statonly = FALSE
)
Arguments
mainlm |
Either an object of class "lm"
(e.g., generated by lm ), or
a list of two objects: a response vector and a design matrix. The objects
are assumed to be in that order, unless they are given the names
"X" and "y" to distinguish them. The design matrix passed
in a list must begin with a column of ones if an intercept is to be
included in the linear model. The design matrix passed in a list should
not contain factors, as all columns are treated 'as is'. For tests that
use ordinary least squares residuals, one can also pass a vector of
residuals in the list, which should either be the third object or be
named "e" .
|
alpha |
A double such that 0≤α<1/2 ; a hyperparameter
of the test. Defaults to 0.
|
pvalmethod |
A character, either "data" or "sim" ,
determining which method to use to compute the empirical
p -value. If "data" , the dataset T_alpha
consisting of pre-generated Monte Carlo replicates from the
asymptotic null distribution of the test statistic is loaded and used to
compute empirical p -value. This is only available for certain
values of alpha , namely i/32 where i=0,1,…,15 .
If "sim" , Monte Carlo replicates are generated from the
asymptotic null distribution. Partial matching is used.
|
R |
An integer representing the number of Monte Carlo replicates to
generate, if pvalmethod == "sim" . Ignored if
pvalmethod == "data" .
|
m |
An integer representing the number of standard normal variates to
use when generating the Brownian Bridge for each replicate, if
pvalmethod == "sim" . Ignored if pvalmethod == "data" . If
number of observations is small,
Rackauskas and Zuokas (2007) recommends using m=n .
The dataset T_alpha used m=217 which is
computationally intensive.
|
sqZ |
A logical. If TRUE , the standard normal variates used
in the Brownian Bridge when generating from the asymptotic null
distribution are first squared, i.e. transformed to χ2(1)
variates. This is recommended by
Rackauskas and Zuokas (2007) when the number of
observations is small. Ignored if pvalmethod == "data" .
|
seed |
An integer representing the seed to be used for pseudorandom
number generation when simulating values from the asymptotic null
distribution. This is to provide reproducibility of test results.
Ignored if pvalmethod == "data" . If user does not wish to set
the seed, pass NA .
|
statonly |
A logical. If TRUE , only the test statistic value
is returned, instead of an object of class
"htest" . Defaults to FALSE .
|
Details
Rackauskas and Zuokas propose a class of tests that entails
determining the largest weighted difference in variance of estimated
error. The asymptotic behaviour of their test statistic
Tn,α
is studied using the empirical polygonal process
constructed from partial sums of the squared residuals. The test is
right-tailed.
Value
An object of class
"htest"
. If object is
not assigned, its attributes are displayed in the console as a
tibble
using tidy
.
References
Rackauskas A, Zuokas D (2007).
“New Tests of Heteroskedasticity in Linear Regression Model.”
Lithuanian Mathematical Journal, 47(3), 248–265.
Examples
mtcars_lm <- lm(mpg ~ wt + qsec + am, data = mtcars)
rackauskas_zuokas(mtcars_lm)
rackauskas_zuokas(mtcars_lm, alpha = 7 / 16)
n <- length(mtcars_lm$residuals)
rackauskas_zuokas(mtcars_lm, pvalmethod = "sim", m = n, sqZ = TRUE)
[Package
skedastic version 2.0.2
Index]