bp_test: Breusch-Pagan Test

Description Usage Arguments Details Value References Examples

View source: R/homoskedasticity.R

Description

Calculate a Breusch-Pegan test for heteroscedasticity

Usage

1
bp_test(e, X)

Arguments

e

a vector with error terms

X

a dataframe with k parameter and n observations

Details

The Breusch-Pagan test fits a linear regression model to the residuals of a linear regression model and rejects if too much of the variance is explained by the additional explanatory variables. Under H0 the test statistic of the Breusch-Pagan test follows a chi-squared distribution with k degrees of freedom.

Value

An htest object is returned. The critical value and the p-value are contained in the object.

References

T.S. Breusch & A.R. Pagan (1979), A Simple Test for Heteroscedasticity and Random Coefficient Variation. Econometrica 47, 1287–1294

R. Koenker (1981), A Note on Studentizing a Test for Heteroscedasticity. Journal of Econometrics 17, 107–112.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
 ## Not run: 
## generate a regressor
X <- rep(c(1, 2), 50)
## generate homoskedastic errors
err1 <- rnorm(100)
## generate heteroskedastic errors
err2 <- rnorm(100, sd = x)

# perform the Breusch-Pagan test
olsdiagnosticR:::bp_test(err1, X)
olsdiagnosticR:::bp_test(err2, X)

## End(Not run)

Kale-S/olsdiagnosticR documentation built on Oct. 30, 2019, 8:12 p.m.