0

Attempting to run this line of code but receiving this error message:

ols_test_breusch_pagan(wls_model) 
# Error in ols_test_breusch_pagan(wls_model) : 
#   could not find function "ols_test_breusch_pagan" 

Can anyone help diagnose? I've tried installing packages, etc. Used to work, now not.

Additional Code for Reference:

bptest(wls_model) 
#  Error in bptest(wls_model) : could not find function "bptest"
plot(fitted(model4), resid(model4), xlab='Fitted Values', ylab='Residuals')
abline(0,0)
wt <- 1/lm(abs(model4$residuals) ~ model4$fitted.values)$fitted.values^2
wls_model <- lm(formula= revenue ~ Resource + Days + Resource.Location.Name.1, data=data1, weights=wt)
summary(wls_model)

Attempted to install olsr packages, different strings of code, etc. Still receiving error (typically run this code without problem so not sure what's going wrong now).

Rui Barradas
  • 70,273
  • 8
  • 34
  • 66
razztazz
  • 13
  • 4
  • 1
    Overwhelmingly likely that you either don't have the `olsrr` package installed, *or* you installed it and failed to load it. Can you please give us a [mcve], i.e. a few lines of code that you can run in a *clean* R session that will give you this error? i.e. what happens if you run `library("olsrr"); model <- lm(mpg ~ disp + hp + wt + drat, data = mtcars); ols_test_breusch_pagan(model)` in a clean R session? – Ben Bolker Jul 10 '23 at 19:23
  • What if you run `olsrr::ols_test_breusch_pagan(wls_model)` explictly. – MrFlick Jul 10 '23 at 19:35
  • @MrFlick - this worked - thank you! – razztazz Jul 10 '23 at 19:43
  • 1
    If that worked that means you never loaded the package after you installed it. Normally you should have `library(olsrr)` in your code in each session before you try to use any functions from that package. – MrFlick Jul 10 '23 at 19:45

0 Answers0