|
1 | 1 | Regression and Other Stories: AgePeriodCohort
|
2 | 2 | ================
|
3 | 3 | Andrew Gelman, Jennifer Hill, Aki Vehtari
|
4 |
| -2021-04-20 |
| 4 | +2021-06-23 |
5 | 5 |
|
6 | 6 | - [2 Data and measurement](#2-data-and-measurement)
|
7 | 7 | - [2.4 Data and adjustment: trends in mortality
|
@@ -136,14 +136,14 @@ A helper function to set the mortality rates for all years to that of a
|
136 | 136 | given year.
|
137 | 137 |
|
138 | 138 | ``` r
|
139 |
| -set_rates <- function(.data, rate_year) { |
140 |
| - .data %>% |
| 139 | +set_rates <- function(data, rate_year) { |
| 140 | + data %>% |
141 | 141 | left_join(
|
142 |
| - .data %>% |
| 142 | + data %>% |
143 | 143 | filter(year == rate_year) %>%
|
144 | 144 | mutate(rate = deaths / population * 1e5) %>%
|
145 | 145 | select(!c(year, deaths, population)),
|
146 |
| - by = names(.data) %>% setdiff(c("year", "deaths", "population")) |
| 146 | + by = names(data) %>% setdiff(c("year", "deaths", "population")) |
147 | 147 | )
|
148 | 148 | }
|
149 | 149 | ```
|
@@ -193,13 +193,13 @@ substantial role in the increase of the unadjusted mortality.
|
193 | 193 | A helper function to add the weights for age adjustment.
|
194 | 194 |
|
195 | 195 | ``` r
|
196 |
| -add_weight <- function(.data, weight_year) { |
197 |
| - .data %>% |
| 196 | +add_weight <- function(data, weight_year) { |
| 197 | + data %>% |
198 | 198 | left_join(
|
199 |
| - .data %>% |
| 199 | + data %>% |
200 | 200 | filter(year == weight_year) %>%
|
201 | 201 | select(!c(year, deaths), weight = population),
|
202 |
| - by = names(.data) %>% setdiff(c("year", "deaths", "population")) |
| 202 | + by = names(data) %>% setdiff(c("year", "deaths", "population")) |
203 | 203 | )
|
204 | 204 | }
|
205 | 205 | ```
|
|
0 commit comments