diblasi_bowman {skedastic}R Documentation

Diblasi and Bowman's Test for Heteroskedasticity in a Linear Regression Model

Description

This function implements the nonparametric test of Diblasi and Bowman (1997) for testing for heteroskedasticity in a linear regression model.

Usage

diblasi_bowman(
  mainlm,
  distmethod = c("moment.match", "bootstrap"),
  H = 0.08,
  ignorecov = TRUE,
  B = 500L,
  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".

distmethod

A character specifying the method by which to estimate the p-values, either "moment.match" or "bootstrap".

H

A hyperparameter denoting the bandwidth matrix in the kernel function used for weights in nonparametric smoothing. If a double of length 1 (the default), H is set to h I_{p^\prime} where h is the scalar bandwidth value entered and I_{p^\prime} is the p^\prime \times p^\prime identity matrix (where p^\prime is the number of columns in the X matrix, excluding an intercept if present). If a double of length p^\prime, H is set to diag(h) where h is the bandwidth vector entered. If H is a p^\prime\times p^\prime matrix it is used as is. Any other dimensionality of H results in an error.

ignorecov

A logical. If TRUE (the default), the variance-covariance matrix of s is assumed to be diagonal. (This assumption is, strictly speaking, invalid, but usually yields a reasonable approximation. Computation time is prohibitive for large sample sizes if set to FALSE).

B

An integer specifying the number of nonparametric bootstrap replications to be used, if distmethod="bootstrap".

seed

An integer specifying a seed to pass to set.seed for random number generation. This allows reproducibility of bootstrap results. The value NA results in not setting a seed.

statonly

A logical. If TRUE, only the test statistic value is returned, instead of an object of class "htest". Defaults to FALSE.

Details

The test entails undertaking a transformation of the OLS residuals s_i=\sqrt{|e_i|}-E_0(\sqrt{|e_i|}), where E_0 denotes expectation under the null hypothesis of homoskedasticity. The kernel method of nonparametric regression is used to fit the relationship between these s_i and the explanatory variables. This leads to a test statistic T that is a ratio of quadratic forms involving the vector of s_i and the matrix of normal kernel weights. Although nonparametric in its method of fitting the possible heteroskedastic relationship, the distributional approximation used to compute p-values assumes normality of the errors.

Value

An object of class "htest". If object is not assigned, its attributes are displayed in the console as a tibble using tidy.

References

Diblasi A, Bowman A (1997). “Testing for Constant Variance in a Linear Model.” Statistics & Probability Letters, 33, 95–103.

Examples

mtcars_lm <- lm(mpg ~ wt + qsec + am, data = mtcars)
diblasi_bowman(mtcars_lm)
diblasi_bowman(mtcars_lm, ignorecov = FALSE)
diblasi_bowman(mtcars_lm, distmethod = "bootstrap")


[Package skedastic version 2.0.2 Index]