{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

WeightedLS - p-value 3.710e-06> anova(m1 Analysis of...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Weighted Least Squares and Lack of Fit Test This handout reproduces many of the calculations in Chapter 5 of ALR. > library(alr3) > data(physics) > physics x y SD 1 0.345 367 17 2 0.287 311 9 3 0.251 295 9 4 0.225 268 7 5 0.207 253 7 6 0.186 239 6 7 0.161 220 6 8 0.132 213 6 9 0.084 193 5 10 0.060 192 5 > plot(y ~ x, data=physics) > m1 <- lm(y ~ x, data=physics, weights = 1/SD^2) > abline(m1) > summary(m1) Call: lm(formula = y ~ x, data = physics, weights = 1/SD^2) Residuals: Min 1Q Median 3Q Max -2.323e+00 -8.842e-01 1.266e-06 1.390e+00 2.335e+00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 200 250 300 350 x y
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 148.473 8.079 18.38 7.91e-08 *** x 530.835 47.550 11.16 3.71e-06 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 1.657 on 8 degrees of freedom Multiple R-squared: 0.9397, Adjusted R-squared: 0.9321 F-statistic: 124.6 on 1 and 8 DF,
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: p-value: 3.710e-06 > anova(m1) Analysis of Variance Table Response: y Df Sum Sq Mean Sq F value Pr(>F) x 1 341.99 341.99 124.63 3.710e-06 *** Residuals 8 21.95 2.74 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 > RSS <- sum(residuals(m1)^2/physics$SD^2) [1] 21.95265 The lack-of-fit test compares RSS/ g G = RSS, since / g G = 1 by construction, to the ± G distribution with df given by the df in RSS: > pval1 <- pchisq(RSS, df.residual(m1), lower.tail = FALSE) [1] 0.005004345 The tiny p-value indicates lack of fit. As discussed in the book, a quadratic fits better: > plot(y ~ x, physics, type = "p") > abline(m1) > m2 <- update(m1, ~. + I(x^2)) > lines(physics$x, predict(m2),lty = 2, col = 2) > chistat <- sum(residuals(m2)^2/physics$SD^2 > pval2 <- pchisq(chistat), df.residual(m1), lower.tail = FALSE) [1] 0.9194173 0.05 0.10 0.15 0.20 0.25 0.30 0.35 200 250 300 350 x y...
View Full Document

{[ snackBarMessage ]}