raintest {lmtest}R Documentation

Rainbow Test

Description

Rainbow test for linearity.

Usage

raintest(formula, fraction = 0.5, order.by = NULL, center = NULL,
   data=list())

Arguments

formula

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

fraction

numeric. The percentage of observations in the subset is determined by fraction*n if n is the number of observations in the model.

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). If set to "mahalanobis" then the observations are ordered by their Mahalanobis distances from the mean regressor.

center

numeric. If center is smaller than 1 it is interpreted as percentages of data, i.e. the subset is chosen that n*fraction observations are around observation number n*center. If center is greater than 1 it is interpreted to be the index of the center of the subset. By default center is 0.5.

If the Mahalanobis distance is chosen center is taken to be the mean regressor, but can be specified to be a k-dimensional vector if k is the number of regressors and should be in the range of the respective regressors.

data

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

Details

The basic idea of the Rainbow test is that even if the true relationship is non-linear, a good linear fit can be achieved on a subsample in the "middle" of the data. The null hypothesis is rejected whenever the overall fit is significantly worse than the fit for the subsample. The test statistic under H_0 follows an F distribution with parameter degrees of freedom.

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 p-value of the test.

parameter

degrees of freedom.

method

a character string indicating what type of test was performed.

data.name

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

References

J.M. Utts (1982), The Rainbow Test for Lack of Fit in Regression. Communications in Statistics – Theory and Methods 11, 2801–2815.

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

See Also

lm

Examples

x <- c(1:30)
y <- x^2 + rnorm(30,0,2)
rain <- raintest(y ~ x)
rain
## critical value
qf(0.95, rain$parameter[1], rain$parameter[2])

[Package lmtest version 0.9-40 Index]