10.07.2015 Views

Using R for Introductory Statistics : John Verzani

Using R for Introductory Statistics : John Verzani

Using R for Introductory Statistics : John Verzani

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Using</strong> R <strong>for</strong> introductory statistics 29210.3.4 Statistical inferencesAs in the simple linear regression case, if the model is correct, statistical inference can bemade about the coefficients. In general, the estimators <strong>for</strong> a linear model are unbiased andnormally distributed; from this, t-tests and confidence intervals can be constructed <strong>for</strong> theestimators, once we learn the standard errors. As be<strong>for</strong>e, these are output by the summary() function.■ Example 10.8: Galileo, continued For the Galileo data example, the summary () ofthe quadratic fit contains> summary(res.lm2)...Coefficients:Estimate Std. Error t value Pr(>|t|)(Intercept) −2.40e+02 6.90e+01 −3.48 0.0253 *init.h 1.05e+00 1.41e-01 7.48 0.0017 **I(init.h^2) −3.44e-04 6.68e-05 −5.15 0.0068 **---Signif. codes: a ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1‘ ’1…For each the standard errors are given, as is the marginal t-test, which tests <strong>for</strong> the nullhypothesis that the is 0. All three have small p-values and are flagged as such withsignificance stars.Finding a confidence interval <strong>for</strong> the parameters is straight<strong>for</strong>ward, as the valueshave a t-distribution with n−(p+1) degrees of freedom if the linear modelapplies.For example, a 95% confidence interval <strong>for</strong> β 1 would be> alpha =0.05> tstar=qt(1−alpha/2, df=4) # n=7; p=2; df=n−(p+1)> c(1.05−tstar*0.141, 1.05+tstar*0.141)[1] 0.6585 1.441510.3.5 Model selectionIf there is more than one possible model <strong>for</strong> a relationship, how do we know which toprefer? There are many criteria <strong>for</strong> selecting a model. We mention two here that areeasily used within R.Partial F-testConsider these two nested models <strong>for</strong> Y i :Y i =β 0 +β 1 x 1i +…+β k x ki +ε i(10.10)

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

Saved successfully!

Ooh no, something went wrong!