[R] Regression Testing
Mojo
mojo at sispyrc.com
Thu Jan 20 20:08:29 CET 2011
I'm new to R and some what new to the world of stats. I got frustrated
with excel and found R. Enough of that already.
I'm trying to test and correct for Heteroskedasticity
I have data in a csv file that I load and store in a dataframe.
> ds <- read.csv("book2.csv")
> df <- data.frame(ds)
I then preform a OLS regression:
> lmfit <- lm(df$y~df$x)
To test for Heteroskedasticity, I run the BPtest:
> bptest(lmfit)
studentized Breusch-Pagan test
data: lmfit
BP = 11.6768, df = 1, p-value = 0.0006329
From the above, if I'm interpreting this correctly, there is
Heteroskedasticity present. To correct for this, I need to calculate
robust error terms. From my reading on this list, it seems like I need
to vcovHC.
> vcovHC(lmfit)
(Intercept) df$x
(Intercept) 1.057460e-03 -4.961118e-05
df$x -4.961118e-05 2.378465e-06
I'm having a little bit of a hard time following the help pages. So is
the first column the intercepts and the second column new standard errors?
Thanks,
mojo
More information about the R-help
mailing list