Learn R Programming

⚠️There's a newer version (2.0.2) of this package.Take me there.

skedastic

The purpose of the skedastic package is to make diagnostic methods for detecting heteroskedasticity in linear regression models accessible to R users.

Installation

# Install from CRAN
install.packages("skedastic", dependencies = c("Depends", "Imports"))

# Or the development version from GitHub:
install.packages("devtools")
devtools::install_github("tjfarrar/skedastic")

Usage

The purpose of the skedastic package is to make diagnostic methods for detecting heteroskedasticity in linear regression models accessible to R users. Heteroskedasticity (sometimes spelt 'heteroscedasticity') is a violation of one of the assumptions of the classical linear regression model (the Gauss-Markov Assumptions). This assumption, known as homoskedasticity, holds that the variance of the random error term remains constant across all observations.

23 distinct functions in the package implement hypothesis testing methods for detecting heteroskedasticity that have been previously published in academic literature. Other functions implement graphical methods for detecting heteroskedasticity or perform supporting tasks for the tests such as computing transformations of the Ordinary Least Squares (OLS) residuals that are useful in heteroskedasticity detection, or computing probabilities from the null distribution of a nonparametric test statistic. Certain functions have applications beyond the problem of heteroskedasticity in linear regression. These include pRQF, which computes cumulative probabilities from the distribution of a ratio of quadratic forms in normal random vectors, twosidedpval, which implements three different approaches for calculating two-sided $p$-values from asymmetric null distributions, and dDtrend and pdDtrend, which compute probabilities from Lehmann's nonparametric trend statistic.

Most of the exported functions in the package take a linear model as their primary argument (which can be passed as an lm object). Thus, to use this package a user must first be familiar with how to fit linear regression models using the lm function from package stats. Note that the package currently supports only linear regression models fit using OLS.

For heteroskedasticity tests that are implemented in other R packages on CRAN, or in other statistical software such as SAS or SHAZAM, the functions in the skedastic package have been checked against them to ensure that they produce the same values of the test statistic and $p$-value. This is true of breusch_pagan, cook_weisberg, glejser, goldfeld_quandt (parametric test only), harvey, and white_lm.

Here is an example of implementing the Breusch-Pagan Test for heteroskedasticity on a linear regression model fit to the cars dataset, with distance (cars$dist) as the response (dependent) variable and speed (cars$speed) as the explanatory (independent) variable.

library(skedastic)
mylm <- lm(dist ~ speed, data = cars)
breusch_pagan(mylm)

To compute BLUS residuals for the same model:

myblusres <- blus(mylm, omit = "last")
myblusres

To create customised residual plots for the same model:

hetplot(mylm, horzvar = c("explanatory", "log_explanatory"), vertvar = c("res", "res_stud"), vertfun = "2", filetype = NA)

Learn More

No vignettes have been created yet for this package. Watch this space.

Copy Link

Version

Install

install.packages('skedastic')

Monthly Downloads

1,462

Version

1.0.0

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Thomas Farrar

Last Published

August 11th, 2020

Functions in skedastic (1.0.0)

anscombe

Anscombe's Test for Heteroskedasticity in a Linear Regression Model
bickel

Bickel's Test for Heteroskedasticity in a Linear Regression Model
cook_weisberg

Cook-Weisberg Score Test for Heteroskedasticity in a Linear Regression Model
dDtrend

Probability mass function of nonparametric trend statistic \(D\)
bamset

Ramsey's BAMSET Test for Heteroskedasticity in a Linear Regression Model
countpeaks

Count peaks in a data sequence
blus

Compute Best Linear Unbiased Scalar-Covariance (BLUS) residuals from a linear model
carapeto_holt

Carapeto-Holt Test for Heteroskedasticity in a Linear Regression Model
T_alpha

Pseudorandom numbers from Asymptotic Null Distribution of Test Statistic for Method of Rackauskas07;textualskedastic
breusch_pagan

Breusch-Pagan Test for Heteroskedasticity in a Linear Regression Model
harvey

Harvey Test for Heteroskedasticity in a Linear Regression Model
hetplot

Graphical Methods for Detecting Heteroskedasticity in a Linear Regression Model
goldfeld_quandt

Goldfeld-Quandt Tests for Heteroskedasticity in a Linear Regression Model
godfrey_orme

Godfrey and Orme's Nonparametric Bootstrap Test for Heteroskedasticity in a Linear Regression Model
diblasi_bowman

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

Probability mass function of number of peaks in an i.i.d. random sequence
glejser

Glejser Test for Heteroskedasticity in a Linear Regression Model
evans_king

Evans-King Tests for Heteroskedasticity in a Linear Regression Model
szroeter

Szroeter's Test for Heteroskedasticity in a Linear Regression Model
dufour_etal

Dufour et al.'s Monte Carlo Test for Heteroskedasticity in a Linear Regression Model
twosidedpval

Computation of Conditional Two-Sided \(p\)-Values
simonoff_tsai

Simonoff-Tsai Tests for Heteroskedasticity in a Linear Regression Model
dpeakdat

Probability distribution for number of peaks in a continuous, uncorrelated stochastic series
white_lm

White's Test for Heteroskedasticity in a Linear Regression Model
verbyla

Verbyla's Test for Heteroskedasticity in a Linear Regression Model
rackauskas_zuokas

Rackauskas-Zuokas Test for Heteroskedasticity in a Linear Regression Model
li_yao

Li-Yao ALRT and CVT Tests for Heteroskedasticity in a Linear Regression Model
honda

Honda's Test for Heteroskedasticity in a Linear Regression Model
pRQF

Probabilities for a Ratio of Quadratic Forms in a Normal Random Vector
pDtrend

Cumulative distribution function of nonparametric trend statistic \(D\)
ppeak

Cumulative distribution function of number of peaks in an i.i.d. random sequence
horn

Horn's Test for Heteroskedasticity in a Linear Regression Model
zhou_etal

Zhou, Song, and Thompson's Test for Heteroskedasticity in a Linear Regression Model
wilcox_keselman

Wilcox and Keselman's Test for Heteroskedasticity in a Linear Regression Model