Using R for Heteroskedasticity

Using R for Heteroskedasticity

<p>Using R for Heteroskedasticity (Example expenditure on food) Detect and Test for Heteroskedasticity</p><p>Residual plot plot(resid(model)~fitted(model),B)</p><p>Breusch-Pagan bp(model) you must download lmtest (package)</p><p>> bptest(model)</p><p> studentized Breusch-Pagan test data: model BP = 12.0439, df = 1, p-value = 0.0005196</p><p>Fix Heteroskedasticity</p><p>Whitewashing hccm(model) you must download car (package)</p><p>> hccm(model) (Intercept) x (Intercept) 746.454611 -1.181709141 x -1.181709 0.001934526</p><p>Weight Least Squares model<- lm(y~x, weights=I(1/x), B)</p><p>Long way WLS model=lm(I(y/sqrt(x))~I(x/sqrt(x))+I(1/sqrt(x))-1, B)</p><p>> model=lm(y~x,weights=I(1/x),B) > summary(model)</p><p>Call: lm(formula = y ~ x, data = B, weights = I(1/x))</p><p>Residuals: Min 1Q Median 3Q Max -2.2902 -0.7889 -0.2033 0.8225 2.7116 </p><p>Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 31.9244 17.9861 1.775 0.084 . x 0.1410 0.0270 5.222 6.63e-06 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 </p><p>Residual standard error: 1.345 on 38 degrees of freedom Multiple R-Squared: 0.4178, Adjusted R-squared: 0.4024 F-statistic: 27.26 on 1 and 38 DF, p-value: 6.632e-06 </p><p>> model=lm(I(y/sqrt(x))~I(x/sqrt(x))+I(1/sqrt(x))-1,B) > summary(model)</p><p>Call: lm(formula = I(y/sqrt(x)) ~ I(x/sqrt(x)) + I(1/sqrt(x)) - 1, data = B)</p><p>Residuals: Min 1Q Median 3Q Max -2.2902 -0.7889 -0.2033 0.8225 2.7116 </p><p>Coefficients: Estimate Std. Error t value Pr(>|t|) I(x/sqrt(x)) 0.1410 0.0270 5.222 6.63e-06 *** I(1/sqrt(x)) 31.9244 17.9861 1.775 0.084 . --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 </p><p>Residual standard error: 1.345 on 38 degrees of freedom Multiple R-Squared: 0.9344, Adjusted R-squared: 0.931 F-statistic: 270.7 on 2 and 38 DF, p-value: < 2.2e-16</p>

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    2 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us