Skip to content

Commit c71bd20

Browse files
committed
Ch10 fixes
1 parent f751251 commit c71bd20

11 files changed

+16787
-412
lines changed

10-inference-for-regression.Rmd

+5-7
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ $$b_1 = \frac{\sum_{i=1}^n(x_i - \bar x)(y_i - \bar y)}{\sum_{i=1}^n(x_i - \bar
352352

353353
Furthermore, an *estimator* for the standard deviation of $\epsilon_i$ is given by
354354

355-
$s = \sqrt{\frac{\sum_{i=1}^n \left[y_i - (b_0 + b_1 \cdot x_i)\right]^2}{n-2}} = \sqrt{\frac{\sum_{i=1}^n \left(y_i - \widehat{y}_i\right)^2}{n-2}}.$
355+
$$s = \sqrt{\frac{\sum_{i=1}^n \left[y_i - (b_0 + b_1 \cdot x_i)\right]^2}{n-2}} = \sqrt{\frac{\sum_{i=1}^n \left(y_i - \widehat{y}_i\right)^2}{n-2}}.$$
356356

357357
These or equivalent calculations are done in R when using the `lm()` function.
358358
For `old_faithful_2024` we get:
@@ -455,14 +455,14 @@ spotify_for_anova <- spotify_by_genre |>
455455

456456
```{r eval=FALSE}
457457
spotify_for_anova |>
458-
slice_sample(n = 10)
458+
slice_sample(n = 5)
459459
```
460460

461-
(ref:spotify-for-anova-slice) 10 randomly selected rows from `spotify_for_anova`
461+
(ref:spotify-for-anova-slice) Five randomly selected rows from `spotify_for_anova`
462462

463463
```{r echo=FALSE}
464464
spotify_for_anova |>
465-
slice_sample(n = 10) |>
465+
slice_sample(n = 5) |>
466466
kbl(caption = "(ref:spotify-for-anova-slice)") |>
467467
kable_styling(
468468
font_size = ifelse(is_latex_output(), 8, 16),
@@ -2468,9 +2468,7 @@ null_distribution_mlr
24682468

24692469
#### Hypothesis tests for the partial slopes {-}
24702470

2471-
We can now conduct hypothesis tests for the partial slopes in multiple linear regression. We can use the permutation test to test the null hypothesis $H_0: \beta_i = 0$ versus the alternative hypothesis $H_A: \beta_i \neq 0$ for each of the partial slopes. Let's use a significance level of $\alpha = 0.05$.
2472-
2473-
We can visualize the $p$-values in the null distribution by comparing them to the observed test statistics. We do this by adding a `shade_p_value()` layer to the `visualize()` function.
2471+
We can now conduct hypothesis tests for the partial slopes in multiple linear regression. We can use the permutation test to test the null hypothesis $H_0: \beta_i = 0$ versus the alternative hypothesis $H_A: \beta_i \neq 0$ for each of the partial slopes. Let's use a significance level of $\alpha = 0.05$. We can visualize the $p$-values in the null distribution by comparing them to the observed test statistics. We do this by adding a `shade_p_value()` layer `visualize()`.
24742472

24752473
```{r, fig.height=ifelse(knitr::is_latex_output(), 6, 8), fig.width=6, fig.cap="Shaded p-values for the partial slopes in this multiple linear regression."}
24762474
visualize(null_distribution_mlr) +

ModernDive.bbl

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
\begin{thebibliography}{}
2+
3+
\bibitem[Bray et~al., 2024]{R-infer}
4+
Bray, A., Ismay, C., Chasnovski, E., Couch, S., Baumer, B., and Cetinkaya-Rundel, M. (2024).
5+
\newblock {\em infer: Tidy Statistical Inference}.
6+
\newblock R package version 1.0.7.9000.
7+
8+
\bibitem[Chernick and LaBudde, 2011]{Chernick2011}
9+
Chernick, M.~R. and LaBudde, R.~A. (2011).
10+
\newblock {\em An Introduction to Bootstrap Methods with Applications to R}.
11+
\newblock Wiley, Hoboken, NJ, first edition.
12+
13+
\bibitem[Chihara and Hesterberg, 2011]{hester2011}
14+
Chihara, L.~M. and Hesterberg, T.~C. (2011).
15+
\newblock {\em Mathematical Statistics with Resampling and R}.
16+
\newblock John Wiley \& Sons, Hoboken, NJ, first edition.
17+
18+
\bibitem[Diez et~al., 2014]{isrs2014}
19+
Diez, D.~M., Barr, C.~D., and \c{C}etinkaya Rundel, M. (2014).
20+
\newblock {\em Introductory Statistics with Randomization and Simulation}.
21+
\newblock CreateSpace Independent Publishing Platform, Scotts Valley, CA, first edition.
22+
23+
\bibitem[Efron, 1979]{Efron1979}
24+
Efron, B. (1979).
25+
\newblock Bootstrap methods: Another look at the jackknife.
26+
\newblock {\em The Annals of Statistics}, Volume 7(1).
27+
28+
\bibitem[Efron and Tibshirani, 1986]{EfronTibshi1986}
29+
Efron, B. and Tibshirani, R. (1986).
30+
\newblock Bootstrap methods for standard errors, confidence intervals, and other measures of statistical accuracy.
31+
\newblock {\em Statistical Science}, Volume 1(1).
32+
33+
\bibitem[Firke, 2023]{R-janitor}
34+
Firke, S. (2023).
35+
\newblock {\em janitor: Simple Tools for Examining and Cleaning Dirty Data}.
36+
\newblock R package version 2.2.0.
37+
38+
\bibitem[Grolemund and Wickham, 2017]{rds2016}
39+
Grolemund, G. and Wickham, H. (2017).
40+
\newblock {\em R for Data Science}.
41+
\newblock O'Reilly Media, Sebastopol, CA, first edition.
42+
43+
\bibitem[Hall, 1986]{Hall1986}
44+
Hall, P. (1986).
45+
\newblock On the bootstrap and confidence intervals.
46+
\newblock {\em The Annals of Statistics}, Volume 14(4).
47+
48+
\bibitem[Hall, 1988]{Hall1988}
49+
Hall, P. (1988).
50+
\newblock Theoretical comparison of bootstrap confidence intervals.
51+
\newblock {\em The Annals of Statistics}, Volume 16(3).
52+
53+
\bibitem[Hall, 1992]{Hall1992}
54+
Hall, P. (1992).
55+
\newblock {\em The Bootstrap and Edgeworth Expansion}.
56+
\newblock Springer series in statistics, New York, first edition.
57+
58+
\bibitem[Ismay et~al., 2024]{R-nycflights23}
59+
Ismay, C., Couch, S.~P., and Wickham, H. (2024).
60+
\newblock {\em nycflights23: Flights and Other Useful Metadata for NYC Outbound Flights in 2023}.
61+
\newblock R package version 0.1.0.
62+
63+
\bibitem[Ismay and Kennedy, 2016]{usedtor2016}
64+
Ismay, C. and Kennedy, P.~C. (2016).
65+
\newblock {\em Getting Used to R, {RStudio}, and R Markdown}.
66+
67+
\bibitem[Kim and Ismay, 2024]{R-moderndive}
68+
Kim, A.~Y. and Ismay, C. (2024).
69+
\newblock {\em moderndive: Tidyverse-Friendly Introductory Linear Regression}.
70+
\newblock R package version 0.7.0.
71+
72+
\bibitem[Kim et~al., 2021]{R-fivethirtyeight}
73+
Kim, A.~Y., Ismay, C., and Chunn, J. (2021).
74+
\newblock {\em fivethirtyeight: Data and Code Behind the Stories and Interactives at FiveThirtyEight}.
75+
\newblock R package version 0.6.2.
76+
77+
\bibitem[Robbins, 2013]{robbins2013}
78+
Robbins, N. (2013).
79+
\newblock {\em Creating More Effective Graphs}.
80+
\newblock Chart House, New York, NY, first edition.
81+
82+
\bibitem[Wickham, 2014]{tidy}
83+
Wickham, H. (2014).
84+
\newblock Tidy data.
85+
\newblock {\em Journal of Statistical Software}, Volume 59(Issue 10).
86+
87+
\bibitem[Wickham, 2023]{R-tidyverse}
88+
Wickham, H. (2023).
89+
\newblock {\em tidyverse: Easily Install and Load the Tidyverse}.
90+
\newblock R package version 2.0.0.
91+
92+
\bibitem[Wickham et~al., 2024a]{R-ggplot2}
93+
Wickham, H., Chang, W., Henry, L., Pedersen, T.~L., Takahashi, K., Wilke, C., Woo, K., Yutani, H., Dunnington, D., and {van den Brand}, T. (2024a).
94+
\newblock {\em ggplot2: Create Elegant Data Visualisations Using the Grammar of Graphics}.
95+
\newblock R package version 3.5.1.
96+
97+
\bibitem[Wickham et~al., 2023]{R-dplyr}
98+
Wickham, H., François, R., Henry, L., Müller, K., and Vaughan, D. (2023).
99+
\newblock {\em dplyr: A Grammar of Data Manipulation}.
100+
\newblock R package version 1.1.4.
101+
102+
\bibitem[Wickham et~al., 2024b]{R-readr}
103+
Wickham, H., Hester, J., and Bryan, J. (2024b).
104+
\newblock {\em readr: Read Rectangular Text Data}.
105+
\newblock R package version 2.1.5.
106+
107+
\bibitem[Wickham et~al., 2024c]{R-tidyr}
108+
Wickham, H., Vaughan, D., and Girlich, M. (2024c).
109+
\newblock {\em tidyr: Tidy Messy Data}.
110+
\newblock R package version 1.3.1.
111+
112+
\bibitem[Wilkinson, 2005]{wilkinson2005}
113+
Wilkinson, L. (2005).
114+
\newblock {\em The Grammar of Graphics (Statistics and Computing)}.
115+
\newblock Springer-Verlag, Secaucus, NJ, first edition.
116+
117+
\bibitem[Xie, 2024]{R-bookdown}
118+
Xie, Y. (2024).
119+
\newblock {\em bookdown: Authoring Books and Technical Documents with R Markdown}.
120+
\newblock R package version 0.40.
121+
122+
\end{thebibliography}

0 commit comments

Comments
 (0)