harvtest.RdHarvey-Collier test for linearity.
harvtest(formula, order.by = NULL, data = list())a symbolic description for the model to be tested
(or a fitted "lm" object).
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).
an optional data frame containing the variables in the model.
By default the variables are taken from the environment which
harvtest is called from.
The Harvey-Collier test performs a t-test (with parameter degrees of
freedom) on the recursive residuals. If the true relationship is not linear but
convex or concave the mean of the recursive residuals should differ
from 0 significantly.
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.
A list with class "htest" containing the following components:
the value of the test statistic.
the p-value of the test.
degrees of freedom.
a character string indicating what type of test was performed.
a character string giving the name(s) of the data.
A. Harvey & P. Collier (1977), Testing for Functional Misspecification in Regression Analysis. Journal of Econometrics 6, 103–119
W. Krämer & H. Sonnberger (1986), The Linear Regression Model under Test. Heidelberg: Physica
# generate a regressor and dependent variable
x <- 1:50
y1 <- 1 + x + rnorm(50)
y2 <- y1 + 0.3*x^2
## perform Harvey-Collier test
harv <- harvtest(y1 ~ x)
harv
#>
#> Harvey-Collier test
#>
#> data: y1 ~ x
#> HC = 1.4215, df = 47, p-value = 0.1618
#>
## calculate critical value vor 0.05 level
qt(0.95, harv$parameter)
#> [1] 1.677927
harvtest(y2 ~ x)
#>
#> Harvey-Collier test
#>
#> data: y2 ~ x
#> HC = 8.0649, df = 47, p-value = 2.038e-10
#>