Intro

Packages to install:

Remarks on bptest()

Let’s make some data that is very heteroscedastic:

You can see the heteroscedasticity:

Now have lmtest::bptest() do its work:

## 
##  studentized Breusch-Pagan test
## 
## data:  mod
## BP = 100.15, df = 1, p-value < 2.2e-16

But the above P-value is only human-readable representation of the P-value that the routine computed. To see that this is so, look into the structure of the object produced by a call to bptest():

## List of 5
##  $ statistic: Named num 100
##   ..- attr(*, "names")= chr "BP"
##  $ parameter: Named num 1
##   ..- attr(*, "names")= chr "df"
##  $ method   : chr "studentized Breusch-Pagan test"
##  $ p.value  : Named num 1.41e-23
##   ..- attr(*, "names")= chr "BP"
##  $ data.name: chr "mod"
##  - attr(*, "class")= chr "htest"

Aha! We can access the P-value as follows:

##           BP 
## 1.413889e-23

So I figure that the P-value you computed by hand is probably the same as what bptest() got, under the hood.

Choosing R Packages

Any open-source software of any note accumulates an overgrown jungle of packages. People do attempt to curate lists of the best packages for given tasks. One highly-regarded (but also very incomplete) set of sets of packages is provided in CRAN’s Task Views.