diff --git a/ch3/applied.Rmd b/ch3/applied.Rmd index e5e0554..df905c8 100644 --- a/ch3/applied.Rmd +++ b/ch3/applied.Rmd @@ -408,7 +408,7 @@ suggests that there isn't a relationship between y and $x^2$. ---- ```{r} set.seed(1) -eps1 = rnorm(100, 0, 0.125) +eps1 = rnorm(100, 0, sqrt(0.125)) x1 = rnorm(100) y1 = -1 + 0.5*x1 + eps1 plot(x1, y1) @@ -424,7 +424,7 @@ As expected, the error observed in $R^2$ and $RSE$ decreases considerably. ---- ```{r} set.seed(1) -eps2 = rnorm(100, 0, 0.5) +eps2 = rnorm(100, 0, sqrt(0.5)) x2 = rnorm(100) y2 = -1 + 0.5*x2 + eps2 plot(x2, y2) diff --git a/ch3/applied.html b/ch3/applied.html index e43bad0..b4a2ff4 100644 --- a/ch3/applied.html +++ b/ch3/applied.html @@ -743,7 +743,7 @@

13g.

13h.

set.seed(1)
-eps1 = rnorm(100, 0, 0.125)
+eps1 = rnorm(100, 0, sqrt(0.125))
 x1 = rnorm(100)
 y1 = -1 + 0.5*x1 + eps1
 plot(x1, y1)
@@ -754,19 +754,19 @@ 

13h.

## lm(formula = y1 ~ x1) ## ## Residuals: -## Min 1Q Median 3Q Max -## -0.29052 -0.07545 0.00067 0.07288 0.28665 +## Min 1Q Median 3Q Max +## -0.8217 -0.2134 0.0019 0.2061 0.8108 ## ## Coefficients: ## Estimate Std. Error t value Pr(>|t|) -## (Intercept) -0.9864 0.0113 -87.3 <2e-16 *** -## x1 0.4999 0.0118 42.2 <2e-16 *** +## (Intercept) -0.9615 0.0319 -30.1 <2e-16 *** +## x1 0.4997 0.0335 14.9 <2e-16 *** ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ## -## Residual standard error: 0.113 on 98 degrees of freedom -## Multiple R-squared: 0.948, Adjusted R-squared: 0.947 -## F-statistic: 1.78e+03 on 1 and 98 DF, p-value: <2e-16
+## Residual standard error: 0.319 on 98 degrees of freedom +## Multiple R-squared: 0.694, Adjusted R-squared: 0.691 +## F-statistic: 223 on 1 and 98 DF, p-value: <2e-16
abline(lm.fit1, lwd=3, col=2)
 abline(-1, 0.5, lwd=3, col=3)
 legend(-1, legend = c("model fit", "pop. regression"), col=2:3, lwd=3)
@@ -775,7 +775,7 @@

13h.

13i.

set.seed(1)
-eps2 = rnorm(100, 0, 0.5)
+eps2 = rnorm(100, 0, sqrt(0.5))
 x2 = rnorm(100)
 y2 = -1 + 0.5*x2 + eps2
 plot(x2, y2)
@@ -787,18 +787,21 @@ 

13i.

## ## Residuals: ## Min 1Q Median 3Q Max -## -1.1621 -0.3018 0.0027 0.2915 1.1466 +## -1.6434 -0.4268 0.0038 0.4123 1.6215 ## ## Coefficients: ## Estimate Std. Error t value Pr(>|t|) -## (Intercept) -0.9456 0.0452 -20.9 <2e-16 *** -## x2 0.4995 0.0474 10.6 <2e-16 *** +## (Intercept) -0.9230 0.0639 -14.45 < 2e-16 *** +## x2 0.4993 0.0670 7.46 3.6e-11 *** ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ## -## Residual standard error: 0.451 on 98 degrees of freedom -## Multiple R-squared: 0.532, Adjusted R-squared: 0.527 -## F-statistic: 111 on 1 and 98 DF, p-value: <2e-16
+## Residual standard error: 0.638 on 98 degrees of freedom +## Multiple R-squared: 0.362, Adjusted R-squared: 0.355 +## F-statistic: 55.6 on 1 and 98 DF, p-value: 3.62e-11 + + +
abline(lm.fit2, lwd=3, col=2)
 abline(-1, 0.5, lwd=3, col=3)
 legend(-1, legend = c("model fit", "pop. regression"), col=2:3, lwd=3)
@@ -812,12 +815,12 @@

13j.

## x 0.3926 0.6064
confint(lm.fit1)
##               2.5 %  97.5 %
-## (Intercept) -1.0088 -0.9640
-## x1           0.4764  0.5234
+## (Intercept) -1.0249 -0.8981 +## x1 0.4332 0.5661
confint(lm.fit2)
##               2.5 %  97.5 %
-## (Intercept) -1.0352 -0.8559
-## x2           0.4055  0.5935
+## (Intercept) -1.0498 -0.7963 +## x2 0.3664 0.6323

All intervals seem to be centered on approximately 0.5, with the second fit’s interval being narrower than the first fit’s interval and the last fit’s interval being wider than the first fit’s interval.