Hi I'm very new to R but have plenty of experience with statistics and other packages like SPSS, SAS etc. I have a dataset of around 20 columns and 200 rows. I'm trying to fit a very simple linear model between two variables. Having done so, I want to test the model for heteroscedasticity using the Breusch-Pagan test. Apparently this is easy in R by simply doing bptest(modelCH, data=KP) I've tried this but I'm told it cannot find function bptest. It's here where I'm struggling. I'm probably wrong but as far as I can see, bptest is part of the lm package which, as far as I know, I have installed. Irrespective of the fact I'm not sure how to tell bptest which is the dependent and explanatory variables - there's a more fundamental problem if it can't find the bptest function. I have searched the documentation - albeit briefly so if anyone could help I'd be very grateful Rob QBE Management -- View this message in context: http://r.789695.n4.nabble.com/bptest-tp2553506p2553506.html Sent from the R help mailing list archive at Nabble.com.
you have to load package {lmtest} first. That is, library(lmtest) bptest(modelCH, data=KP) -- View this message in context: http://r.789695.n4.nabble.com/bptest-tp2553506p2579815.html Sent from the R help mailing list archive at Nabble.com.
First load the package lmtest. Then run the bptest. library(lmtest) bptest(modelCH) You don't need to tell the function which variables are explanatory or dependent. Just give it the fitted model object, and it will sort all of that out and return the statistic. Andrew Miles Department of Sociology Duke University On Sep 24, 2010, at 9:53 AM, robm wrote:> > Hi > > I'm very new to R but have plenty of experience with statistics and > other > packages like SPSS, SAS etc. > > I have a dataset of around 20 columns and 200 rows. I'm trying to > fit a > very simple linear model between two variables. Having done so, I > want to > test the model for heteroscedasticity using the Breusch-Pagan test. > Apparently this is easy in R by simply doing > > bptest(modelCH, data=KP) > > I've tried this but I'm told it cannot find function bptest. It's > here > where I'm struggling. I'm probably wrong but as far as I can see, > bptest > is part of the lm package which, as far as I know, I have installed. > > Irrespective of the fact I'm not sure how to tell bptest which is the > dependent and explanatory variables - there's a more fundamental > problem if > it can't find the bptest function. > > I have searched the documentation - albeit briefly so if anyone > could help > I'd be very grateful > > Rob > > QBE Management > -- > View this message in context: http://r.789695.n4.nabble.com/bptest-tp2553506p2553506.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
Hi Rob, I googled "cran bptest" and the first hit was for package "lmtest". I installed lmtest, loaded it up, and bptest is available there.> require("lmtest")Loading required package: lmtest Loading required package: zoo> bptestfunction (formula, varformula = NULL, studentize = TRUE, data = list()) ... So see if you can get package lmtest. HTH Cheers Steven McKinney ________________________________________ From: r-help-bounces at r-project.org [r-help-bounces at r-project.org] On Behalf Of robm [r.malpass at ntlworld.com] Sent: September 24, 2010 6:53 AM To: r-help at r-project.org Subject: [R] bptest Hi I'm very new to R but have plenty of experience with statistics and other packages like SPSS, SAS etc. I have a dataset of around 20 columns and 200 rows. I'm trying to fit a very simple linear model between two variables. Having done so, I want to test the model for heteroscedasticity using the Breusch-Pagan test. Apparently this is easy in R by simply doing bptest(modelCH, data=KP) I've tried this but I'm told it cannot find function bptest. It's here where I'm struggling. I'm probably wrong but as far as I can see, bptest is part of the lm package which, as far as I know, I have installed. Irrespective of the fact I'm not sure how to tell bptest which is the dependent and explanatory variables - there's a more fundamental problem if it can't find the bptest function. I have searched the documentation - albeit briefly so if anyone could help I'd be very grateful Rob QBE Management -- View this message in context: http://r.789695.n4.nabble.com/bptest-tp2553506p2553506.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Maybe Matching Threads
- Breusch-pagan and white test - check homoscedasticity
- Testing autocorrelation & heteroskedasticity of residuals in ts
- some irritation with heteroskedasticity testing
- Test for Homoscedesticity in R Without BP Test
- Test for Homoscedesticity in R Without BP Test