06.09.2021 Views

Learning Statistics with R - A tutorial for psychology students and other beginners, 2018a

Learning Statistics with R - A tutorial for psychology students and other beginners, 2018a

Learning Statistics with R - A tutorial for psychology students and other beginners, 2018a

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

St<strong>and</strong>ardized residuals<br />

0.0 0.5 1.0 1.5<br />

78<br />

Scale−Location<br />

81 36<br />

50 60 70 80<br />

Fitted values<br />

lm(dan.grump ~ dan.sleep + baby.sleep)<br />

Figure 15.15: Plot of the fitted values (model predictions) against the square root of the abs st<strong>and</strong>ardised<br />

residuals. This plot is used to diagnose violations of homogeneity of variance. If the variance is really<br />

constant, then the line through the middle should be horizontal <strong>and</strong> flat. This is one of the st<strong>and</strong>ard<br />

regression plots produced by the plot() function when the input is a linear regression object. It is<br />

obtained by setting which=3.<br />

.......................................................................................................<br />

that only make sense if you underst<strong>and</strong> the maths at a low level 14 You don’t need to underst<strong>and</strong> what<br />

this means (not <strong>for</strong> an introductory class), but it might help to note that there’s a hccm() function in<br />

the car() package that does it. Better yet, you don’t even need to use it. You can use the coeftest()<br />

function in the lmtest package, but you need the car package loaded:<br />

> coeftest( regression.2, vcov= hccm )<br />

t test of coefficients:<br />

Estimate Std. Error t value Pr(>|t|)<br />

(Intercept) 125.965566 3.247285 38.7910

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!