Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

hmctest

Harrison-McCabe test


Description

Harrison-McCabe test for heteroskedasticity.

Usage

hmctest(formula, point = 0.5, order.by = NULL, simulate.p = TRUE, nsim = 1000,
  plot = FALSE, data = list())

Arguments

formula

a symbolic description for the model to be tested (or a fitted "lm" object).

point

numeric. If point is smaller than 1 it is interpreted as percentages of data, i.e. n*point is taken to be the (potential) breakpoint in the variances, if n is the number of observations in the model. If point is greater than 1 it is interpreted to be the index of the breakpoint.

order.by

Either a vector z or a formula with a single explanatory variable like ~ z. The observations in the model are ordered by the size of z. If set to NULL (the default) the observations are assumed to be ordered (e.g., a time series).

simulate.p

logical. If TRUE a p value will be assessed by simulation, otherwise the p value is NA.

nsim

integer. Determines how many runs are used to simulate the p value.

plot

logical. If TRUE the test statistic for all possible breakpoints is plotted.

data

an optional data frame containing the variables in the model. By default the variables are taken from the environment which hmctest is called from.

Details

The Harrison-McCabe test statistic is the fraction of the residual sum of squares that relates to the fraction of the data before the breakpoint. Under H_0 the test statistic should be close to the size of this fraction, e.g. in the default case close to 0.5. The null hypothesis is reject if the statistic is too small.

Examples can not only be found on this page, but also on the help pages of the data sets bondyield, currencysubstitution, growthofmoney, moneydemand, unemployment, wages.

Value

A list with class "htest" containing the following components:

statistic

the value of the test statistic.

p.value

the simulated p-value of the test.

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

References

M.J. Harrison & B.P.M McCabe (1979), A Test for Heteroscedasticity based on Ordinary Least Squares Residuals. Journal of the American Statistical Association 74, 494–499

W. Krämer & H. Sonnberger (1986), The Linear Regression Model under Test. Heidelberg: Physica

See Also

Examples

## generate a regressor
x <- rep(c(-1,1), 50)
## generate heteroskedastic and homoskedastic disturbances
err1 <- c(rnorm(50, sd=1), rnorm(50, sd=2))
err2 <- rnorm(100)
## generate a linear relationship
y1 <- 1 + x + err1
y2 <- 1 + x + err2
## perform Harrison-McCabe test
hmctest(y1 ~ x)
hmctest(y2 ~ x)

lmtest

Testing Linear Regression Models

v0.9-38
GPL-2 | GPL-3
Authors
Torsten Hothorn [aut] (<https://orcid.org/0000-0001-8301-0471>), Achim Zeileis [aut, cre] (<https://orcid.org/0000-0003-0918-3766>), Richard W. Farebrother [aut] (pan.f), Clint Cummins [aut] (pan.f), Giovanni Millo [ctb], David Mitchell [ctb]
Initial release
2020-09-09

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.