Learn R Programming

lmtest (version 0.9-5)

raintest: 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.
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 formula or a string. A formula with a single explanatory variable like ~ x. The observations in the model are ordered by the size of x. If set to NULL (the default) the observations are assumed t
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 g
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.

Value

  • A list with class "htest" containing the following components:
  • statisticthe value of the test statistic.
  • p.valuethe p-value of the test.
  • parameterdegrees of freedom.
  • methoda character string indicating what type of test was performed.
  • data.namea character string giving the name(s) of the data.

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 inferious to the fit of 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.

References

J.M. Utts (1982), The Rainbow Test for Lack of Fit in Regression. Communications in Statistics - Theory and Methods 11, 1801--1815

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

See Also

lm

Examples

Run this code
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])

Run the code above in your browser using DataLab