Skip to content

Commit 28794ae

Browse files
committed
tweaks
1 parent 6e7a706 commit 28794ae

File tree

3 files changed

+53
-53
lines changed

3 files changed

+53
-53
lines changed

PS05_source.html

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ <h1 class="title">Problem Set 05: Regression with One Categorical Variable</h1>
100100
<div>
101101
<div class="quarto-title-meta-heading">Published</div>
102102
<div class="quarto-title-meta-contents">
103-
<p class="date">Last modified on August 07, 2023 17:01:47 Eastern Daylight Time</p>
103+
<p class="date">Last modified on August 24, 2024 10:29:36 Eastern Daylight Time</p>
104104
</div>
105105
</div>
106106

@@ -466,8 +466,8 @@ <h1>Hate Crimes and Trump Support</h1>
466466
<div class="callout-body-container callout-body">
467467
<p>Below we calculate the group means of hate crimes for the <code>high</code>, <code>medium</code> and <code>low</code> levels of Trump support. How do these numbers compare to the three possible fitted values <span class="math inline">\(\widehat{y}\)</span> for this model?</p>
468468
<div class="cell" data-layout-align="center">
469-
<div class="sourceCode cell-code" id="cb11"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a>hate_crimes <span class="sc">%&gt;%</span> </span>
470-
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a><span class="fu">group_by</span>(trump_support) <span class="sc">%&gt;%</span> </span>
469+
<div class="sourceCode cell-code" id="cb11"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a>hate_crimes <span class="sc">|&gt;</span> </span>
470+
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a><span class="fu">group_by</span>(trump_support) <span class="sc">|&gt;</span> </span>
471471
<span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">summarize</span>(<span class="at">mean_hate_crimes =</span> <span class="fu">mean</span>(hate_crimes, <span class="at">na.rm =</span> <span class="cn">TRUE</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
472472
<div class="cell-output cell-output-stdout">
473473
<pre><code># A tibble: 3 × 2
@@ -970,7 +970,7 @@ <h1><strong>EXTRA</strong></h1>
970970
<div class="cell" data-layout-align="center">
971971
<div class="sourceCode cell-code" id="cb23"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb23-1"><a href="#cb23-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Reordering trump_support</span></span>
972972
<span id="cb23-2"><a href="#cb23-2" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(forcats)</span>
973-
<span id="cb23-3"><a href="#cb23-3" aria-hidden="true" tabindex="-1"></a>hate_crimes <span class="ot">&lt;-</span> hate_crimes <span class="sc">%&gt;%</span> </span>
973+
<span id="cb23-3"><a href="#cb23-3" aria-hidden="true" tabindex="-1"></a>hate_crimes <span class="ot">&lt;-</span> hate_crimes <span class="sc">|&gt;</span> </span>
974974
<span id="cb23-4"><a href="#cb23-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">trump_support =</span> <span class="fu">fct_relevel</span>(trump_support, </span>
975975
<span id="cb23-5"><a href="#cb23-5" aria-hidden="true" tabindex="-1"></a> <span class="st">"low"</span>, <span class="st">"medium"</span>, <span class="st">"high"</span>))</span>
976976
<span id="cb23-6"><a href="#cb23-6" aria-hidden="true" tabindex="-1"></a><span class="fu">ggplot</span>(<span class="at">data =</span> hate_crimes, <span class="fu">aes</span>(<span class="at">x =</span> trump_support, <span class="at">y =</span> hate_crimes)) <span class="sc">+</span> </span>
@@ -1035,12 +1035,12 @@ <h1>Logging out of the Server</h1>
10351035
<div class="cell" data-layout-align="center">
10361036
<div class="sourceCode cell-code" id="cb24"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb24-1"><a href="#cb24-1" aria-hidden="true" tabindex="-1"></a><span class="fu">sessionInfo</span>()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
10371037
<div class="cell-output cell-output-stdout">
1038-
<pre><code>R version 4.2.3 (2023-03-15)
1039-
Platform: x86_64-pc-linux-gnu (64-bit)
1040-
Running under: Red Hat Enterprise Linux 9.2 (Plow)
1038+
<pre><code>R version 4.4.1 (2024-06-14)
1039+
Platform: x86_64-redhat-linux-gnu
1040+
Running under: Red Hat Enterprise Linux 9.4 (Plow)
10411041

10421042
Matrix products: default
1043-
BLAS/LAPACK: /usr/lib64/libopenblasp-r0.3.21.so
1043+
BLAS/LAPACK: FlexiBLAS OPENBLAS-OPENMP; LAPACK version 3.9.0
10441044

10451045
locale:
10461046
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
@@ -1050,32 +1050,35 @@ <h1>Logging out of the Server</h1>
10501050
[9] LC_ADDRESS=C LC_TELEPHONE=C
10511051
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
10521052

1053+
time zone: America/New_York
1054+
tzcode source: system (glibc)
1055+
10531056
attached base packages:
10541057
[1] stats graphics grDevices utils datasets methods base
10551058

10561059
other attached packages:
1057-
[1] forcats_1.0.0 readr_2.1.4 moderndive_0.5.5 dplyr_1.1.2
1058-
[5] ggplot2_3.4.2 knitr_1.43
1060+
[1] forcats_1.0.0 readr_2.1.5 moderndive_0.6.1 dplyr_1.1.4
1061+
[5] ggplot2_3.5.1 knitr_1.48
10591062

10601063
loaded via a namespace (and not attached):
1061-
[1] tidyselect_1.2.0 xfun_0.39 janitor_2.2.0
1062-
[4] purrr_1.0.1 operator.tools_1.6.3 snakecase_0.11.0
1063-
[7] colorspace_2.1-0 vctrs_0.6.3 generics_0.1.3
1064-
[10] htmltools_0.5.5 yaml_2.3.7 utf8_1.2.3
1065-
[13] rlang_1.1.1 pillar_1.9.0 glue_1.6.2
1066-
[16] withr_2.5.0 infer_1.0.4 bit64_4.0.5
1067-
[19] lifecycle_1.0.3 stringr_1.5.0 munsell_0.5.0
1068-
[22] gtable_0.3.3 htmlwidgets_1.6.2 evaluate_0.21
1069-
[25] labeling_0.4.2 tzdb_0.4.0 fastmap_1.1.1
1070-
[28] parallel_4.2.2 fansi_1.0.4 broom_1.0.5
1071-
[31] backports_1.4.1 scales_1.2.1 vroom_1.6.3
1072-
[34] jsonlite_1.8.7 farver_2.1.1 bit_4.0.5
1073-
[37] hms_1.1.3 digest_0.6.33 stringi_1.7.12
1074-
[40] formula.tools_1.7.1 grid_4.2.2 cli_3.6.1
1075-
[43] tools_4.2.2 magrittr_2.0.3 tibble_3.2.1
1076-
[46] crayon_1.5.2 tidyr_1.3.0 pkgconfig_2.0.3
1077-
[49] lubridate_1.9.2 timechange_0.2.0 rmarkdown_2.23
1078-
[52] rstudioapi_0.15.0 R6_2.5.1 compiler_4.2.2 </code></pre>
1064+
[1] utf8_1.2.4 generics_0.1.3 tidyr_1.3.1
1065+
[4] stringi_1.8.4 hms_1.1.3 digest_0.6.36
1066+
[7] magrittr_2.0.3 evaluate_0.24.0 grid_4.4.1
1067+
[10] timechange_0.3.0 fastmap_1.2.0 operator.tools_1.6.3
1068+
[13] jsonlite_1.8.8 backports_1.5.0 purrr_1.0.2
1069+
[16] fansi_1.0.6 scales_1.3.0 infer_1.0.7
1070+
[19] cli_3.6.3 rlang_1.1.4 crayon_1.5.3
1071+
[22] bit64_4.0.5 munsell_0.5.1 withr_3.0.1
1072+
[25] yaml_2.3.10 tools_4.4.1 parallel_4.4.1
1073+
[28] tzdb_0.4.0 colorspace_2.1-1 broom_1.0.6
1074+
[31] vctrs_0.6.5 R6_2.5.1 lifecycle_1.0.4
1075+
[34] lubridate_1.9.3 snakecase_0.11.1 stringr_1.5.1
1076+
[37] htmlwidgets_1.6.4 bit_4.0.5 vroom_1.6.5
1077+
[40] janitor_2.2.0 pkgconfig_2.0.3 pillar_1.9.0
1078+
[43] gtable_0.3.5 glue_1.7.0 xfun_0.47
1079+
[46] tibble_3.2.1 tidyselect_1.2.1 rstudioapi_0.16.0
1080+
[49] farver_2.1.2 htmltools_0.5.8.1 labeling_0.4.3
1081+
[52] rmarkdown_2.28 formula.tools_1.7.1 compiler_4.4.1 </code></pre>
10791082
</div>
10801083
</div>
10811084
</section>

PS05_source.qmd

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ date-format: "[Last modified on] MMMM DD, YYYY HH:mm:ss zzz"
66
format:
77
html: default
88
pdf: default
9-
editor: visual
9+
editor: source
1010
---
1111

1212
```{r include = FALSE}
@@ -89,7 +89,7 @@ Create a visual model of these data (a graph) that will allow you to conduct an
8989
:::
9090

9191
::: {.callout-important icon="false" collapse="false" title="Problem 2 Answers"}
92-
* Delete this and put your text answer here.
92+
- Delete this and put your text answer here.
9393
:::
9494

9595
::: {.callout-note icon="false" title="Problem 3"}
@@ -108,15 +108,15 @@ What does the intercept mean in this regression table?
108108
:::
109109

110110
::: {.callout-important icon="false" collapse="false" title="Problem 4 Answers"}
111-
* Delete this and put your text answer here.
111+
- Delete this and put your text answer here.
112112
:::
113113

114114
::: {.callout-note icon="false" title="Problem 5"}
115115
What does the model estimate as the number of hate crimes per 100,000 people in states with "low" Trump support?
116116
:::
117117

118118
::: {.callout-important icon="false" collapse="false" title="Problem 5 Answers"}
119-
* Delete this and put your text answer here.
119+
- Delete this and put your text answer here.
120120

121121
```{r}
122122
# Type your code and comments inside the code chunk
@@ -134,7 +134,7 @@ Does the model estimate that hate crimes are more frequent in states that show "
134134
135135
```
136136

137-
* Delete this and put your text answer here.
137+
- Delete this and put your text answer here.
138138
:::
139139

140140
::: {.callout-note icon="false" title="Problem 7"}
@@ -147,7 +147,7 @@ How much greater were hate crimes in "medium" Trump-support states compared to "
147147
148148
```
149149

150-
* Delete this and put your text answer here.
150+
- Delete this and put your text answer here.
151151
:::
152152

153153
::: {.callout-note icon="false" title="Problem 8"}
@@ -160,25 +160,25 @@ What are the three possible fitted values $\hat{y}$ for this model? Hint: use th
160160
161161
```
162162

163-
* Delete this and put your text answer here.
163+
- Delete this and put your text answer here.
164164

165-
* Delete this and put your text answer here.
165+
- Delete this and put your text answer here.
166166

167-
* Delete this and put your text answer here.
167+
- Delete this and put your text answer here.
168168
:::
169169

170170
::: {.callout-note icon="false" title="Problem 9"}
171171
Below we calculate the group means of hate crimes for the `high`, `medium` and `low` levels of Trump support. How do these numbers compare to the three possible fitted values $\widehat{y}$ for this model?
172172

173173
```{r}
174-
hate_crimes %>%
175-
group_by(trump_support) %>%
174+
hate_crimes |>
175+
group_by(trump_support) |>
176176
summarize(mean_hate_crimes = mean(hate_crimes, na.rm = TRUE))
177177
```
178178
:::
179179

180180
::: {.callout-important icon="false" collapse="false" title="Problem 9 Answers"}
181-
* Delete this and put your text answer here.
181+
- Delete this and put your text answer here.
182182
:::
183183

184184
## The Regression Equation
@@ -189,7 +189,6 @@ The regression equation for this model is the following (render the document and
189189
hate_mod <- lm(hate_crimes ~ trump_support, data = hate_crimes)
190190
```
191191

192-
193192
$$
194193
\widehat{\text{hate\_crimes}} = `r coef(hate_mod)[1]` + `r coef(hate_mod)[2]` \times 1_{\text{low support}}(x) + `r coef(hate_mod)[3]` \times 1_{\text{med support}}(x)
195194
$$
@@ -233,14 +232,14 @@ Solve the regression equation for a state in which `trump_support` is "high".
233232
:::
234233

235234
::: {.callout-important icon="false" collapse="false" title="Problem 10 Answers"}
236-
Your $LaTeX$ here
235+
Your $LaTeX$ here
237236

238237
```{r}
239238
# Type your code and comments inside the code chunk
240239
241240
```
242241

243-
* Delete this and put your text answer here.
242+
- Delete this and put your text answer here.
244243
:::
245244

246245
::: {.callout-note icon="false" title="Problem 11"}
@@ -255,7 +254,7 @@ Do these results surprise you? (There is no right answer to this question.)
255254
256255
```
257256

258-
* Delete this and put your text answer here.
257+
- Delete this and put your text answer here.
259258
:::
260259

261260
# Hate Crimes and Unemployment
@@ -292,7 +291,6 @@ Write out the regression equation for `job_mod`.
292291
:::
293292

294293
::: {.callout-important icon="false" collapse="false" title="Problem 14 Answers"}
295-
296294
Write your equation with $LaTeX$ here.
297295
:::
298296

@@ -301,12 +299,11 @@ Interpret the estimate of the intercept from the table below.
301299
:::
302300

303301
::: {.callout-important icon="false" collapse="false" title="Problem 15 Answers"}
304-
* Delete this and put your text answer here.
302+
- Delete this and put your text answer here.
305303
:::
306304

307305
::: {.callout-note icon="false" title="Problem 16"}
308306
What does the model estimate the number of hate crimes per 100,000 people to be in a state with "low" unemployment?
309-
310307
:::
311308

312309
::: {.callout-important icon="false" collapse="false" title="Problem 16 Answers"}
@@ -315,7 +312,7 @@ What does the model estimate the number of hate crimes per 100,000 people to be
315312
316313
```
317314

318-
* Delete this and put your text answer here.
315+
- Delete this and put your text answer here.
319316
:::
320317

321318
::: {.callout-note icon="false" title="Problem 17"}
@@ -328,7 +325,7 @@ What are the two possible fitted values $\widehat{y}$ for this model? Why are th
328325
329326
```
330327

331-
* Delete this and put your text answer here.
328+
- Delete this and put your text answer here.
332329
:::
333330

334331
::: {.callout-note icon="false" title="Problem 18"}
@@ -341,7 +338,7 @@ Use the `get_regression_points()` function to generate a table showing the fitte
341338
342339
```
343340

344-
* Delete this and put your text answer here.
341+
- Delete this and put your text answer here.
345342
:::
346343

347344
# Hate Crimes and Household Income
@@ -362,7 +359,7 @@ Were there more hate crimes in areas with high or low median household incomes?
362359
:::
363360

364361
::: {.callout-important icon="false" collapse="false" title="Problem 20 Answers"}
365-
* Delete this and put your text answer here.
362+
- Delete this and put your text answer here.
366363
:::
367364

368365
::: {.callout-note icon="false" title="Problem 21"}
@@ -386,7 +383,7 @@ Take a look at data for Maine (row 2 of `hate_crimes`). Did the model (`job_med_
386383
387384
```
388385

389-
* Delete this and put your text answer here.
386+
- Delete this and put your text answer here.
390387
:::
391388

392389
# **EXTRA**
@@ -398,7 +395,7 @@ Take a look at data for Maine (row 2 of `hate_crimes`). Did the model (`job_med_
398395
#| fig-cap: "Hate crimes in relation to Trump support"
399396
# Reordering trump_support
400397
library(forcats)
401-
hate_crimes <- hate_crimes %>%
398+
hate_crimes <- hate_crimes |>
402399
mutate(trump_support = fct_relevel(trump_support,
403400
"low", "medium", "high"))
404401
ggplot(data = hate_crimes, aes(x = trump_support, y = hate_crimes)) +
-1.32 KB
Loading

0 commit comments

Comments
 (0)