Score Test for Non-Constant Error Variance
Computes a score test of the hypothesis of constant error variance against the alternative that the error variance changes with the level of the response (fitted values), or with a linear combination of predictors.
ncvTest(model, ...) ## S3 method for class 'lm': ncvTest(model, var.formula, data=NULL, subset, na.action, ...) ## S3 method for class 'glm': ncvTest(model, ...) # to report an error
- a weighted or unweighted linear model, produced by
- a one-sided formula for the error variance; if omitted, the error variance depends on the fitted values.
- an optional data frame containing the variables in the model.
By default the variables are taken from the environment from which
ncvTestis called. The
dataargument may therefore need to be specified even when t
- an optional vector specifying a subset of observations to be used.
- a function that indicates what should happen when the data contain
NAs. The default is set by the
- arguments passed down to methods functions.
This test is often called the Breusch-Pagan test; it was independently
suggested by Cook and Weisberg (1983).
ncvTest.glm is a dummy function to generate an error when a
model is used.
- The function returns a
chisqTestobject, which is usually just printed.
Breusch, T. S. and Pagan, A. R. (1979) A simple test for heteroscedasticity and random coefficient variation. Econometrica 47, 1287--1294. Cook, R. D. and Weisberg, S. (1983) Diagnostics for heteroscedasticity in regression. Biometrika 70, 1--10. Fox, J. (2008) Applied Regression Analysis and Generalized Linear Models, Second Edition. Sage. Fox, J. and Weisberg, S. (2011) An R Companion to Applied Regression, Second Edition, Sage. Weisberg, S. (2005) Applied Linear Regression, Third Edition, Wiley.
ncvTest(lm(interlocks ~ assets + sector + nation, data=Ornstein)) ncvTest(lm(interlocks ~ assets + sector + nation, data=Ornstein), ~ assets + sector + nation, data=Ornstein)