Test for constant variance. It assumes that the error terms are normally distributed.

bp_test(model, fitted.values = TRUE, rhs = FALSE, multiple = FALSE,
  p.adj = c("none", "bonferroni", "sidak", "holm"), vars = NA)

Arguments

model
an object of class lm
fitted.values
logical; if TRUE, use fitted values of regression model
rhs
logical; if TRUE, specifies that tests for heteroskedasticity be performed for the right-hand-side (explanatory) variables of the fitted regression model
multiple
logical; if TRUE, specifies that multiple testing be performed
p.adj
p value adjustment, following options are available: bonferroni, holm, sidak and none
vars
variables to be used for for heteroskedasticity test

Value

bp_test returns an object of class "bp_test". An object of class "bp_test" is a list containing the following components:

References

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

Cook, R. D.; Weisberg, S. (1983). "Diagnostics for Heteroskedasticity in Regression". Biometrika. 70 (1): 1�10.

Examples

# Use fitted values of the model model <- lm(mpg ~ disp + hp + wt + drat, data = mtcars) bp_test(model)
#> #> Breusch Pagan Test for Heteroskedasticity #> ----------------------------------------- #> Ho: the variance is constant #> Ha: the variance is not constant #> #> Data #> ------------------------------- #> Response : mpg #> Variables: fitted values of mpg #> #> Test Summary #> ------------------------- #> DF = 1 #> Chi2 = 1.4297 #> Prob > Chi2 = 0.2318
# Use independent variables of the model model <- lm(mpg ~ disp + hp + wt + drat, data = mtcars) bp_test(model, rhs = TRUE)
#> #> Breusch Pagan Test for Heteroskedasticity #> ----------------------------------------- #> Ho: the variance is constant #> Ha: the variance is not constant #> #> Data #> -------------------------- #> Response : mpg #> Variables: disp hp wt drat #> #> Test Summary #> ------------------------- #> DF = 4 #> Chi2 = 1.5138 #> Prob > Chi2 = 0.8242
# Use independent variables of the model and perform multiple tests model <- lm(mpg ~ disp + hp + wt + drat, data = mtcars) bp_test(model, rhs = TRUE, multiple = TRUE)
#> #> Breusch Pagan Test for Heteroskedasticity #> ----------------------------------------- #> Ho: the variance is constant #> Ha: the variance is not constant #> #> Data #> -------------------------- #> Response : mpg #> Variables: disp hp wt drat #> #> Test Summary (Unadjusted p values) #> ---------------------------------------- #> Variable chi2 df p #> ---------------------------------------- #> disp 1.2355 1 0.2663 #> hp 0.9210 1 0.3372 #> wt 1.2530 1 0.2630 #> drat 1.1668 1 0.2800 #> ---------------------------------------- #> simultaneous 1.5138 4 0.8242 #> ----------------------------------------
# Bonferroni p value Adjustment model <- lm(mpg ~ disp + hp + wt + drat, data = mtcars) bp_test(model, rhs = TRUE, multiple = TRUE, p.adj = 'bonferroni')
#> #> Breusch Pagan Test for Heteroskedasticity #> ----------------------------------------- #> Ho: the variance is constant #> Ha: the variance is not constant #> #> Data #> -------------------------- #> Response : mpg #> Variables: disp hp wt drat #> #> Test Summary (Bonferroni p values) #> ---------------------------------------- #> Variable chi2 df p #> ---------------------------------------- #> disp 1.2355 1 1.0000 #> hp 0.9210 1 1.0000 #> wt 1.2530 1 1.0000 #> drat 1.1668 1 1.0000 #> ---------------------------------------- #> simultaneous 1.5138 4 0.8242 #> ----------------------------------------
# Sidak p value Adjustment model <- lm(mpg ~ disp + hp + wt + drat, data = mtcars) bp_test(model, rhs = TRUE, multiple = TRUE, p.adj = 'sidak')
#> #> Breusch Pagan Test for Heteroskedasticity #> ----------------------------------------- #> Ho: the variance is constant #> Ha: the variance is not constant #> #> Data #> -------------------------- #> Response : mpg #> Variables: disp hp wt drat #> #> Test Summary (Sidak p values) #> ---------------------------------------- #> Variable chi2 df p #> ---------------------------------------- #> disp 1.2355 1 0.7103 #> hp 0.9210 1 0.8070 #> wt 1.2530 1 0.7049 #> drat 1.1668 1 0.7313 #> ---------------------------------------- #> simultaneous 1.5138 4 0.8242 #> ----------------------------------------
# Holm's p value Adjustment model <- lm(mpg ~ disp + hp + wt + drat, data = mtcars) bp_test(model, rhs = TRUE, multiple = TRUE, p.adj = 'holm')
#> #> Breusch Pagan Test for Heteroskedasticity #> ----------------------------------------- #> Ho: the variance is constant #> Ha: the variance is not constant #> #> Data #> -------------------------- #> Response : mpg #> Variables: disp hp wt drat #> #> Test Summary (Holm's p values) #> ---------------------------------------- #> Variable chi2 df p #> ---------------------------------------- #> disp 1.2355 1 0.7990 #> hp 0.9210 1 0.3372 #> wt 1.2530 1 1.0000 #> drat 1.1668 1 0.5601 #> ---------------------------------------- #> simultaneous 1.5138 4 0.8242 #> ----------------------------------------