Skip to content

Commit

Permalink
alright alright, it's augment(newdata = ...) -> `augment(data = ...…
Browse files Browse the repository at this point in the history
…)` for most of our examples
  • Loading branch information
malcolmbarrett committed Dec 23, 2024
1 parent 8b55067 commit 2fa4821
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion chapters/02-whole-game.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ In other words, if you used a bed net, the ATE weight is the probability that yo
library(broom)
library(propensity)
net_data_wts <- propensity_model |>
augment(newdata = net_data, type.predict = "response") |>
augment(data = net_data, type.predict = "response") |>
# .fitted is the value predicted by the model
# for a given observation
mutate(wts = wt_ate(.fitted, net))
Expand Down
2 changes: 1 addition & 1 deletion chapters/08-propensity-scores.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ We can extract the propensity scores by pulling out the predictions on the proba
Using the `augment()` function from the [{`broom`}](https://broom.tidymodels.org/) package, we can extract these propensity scores and add them to our original data frame.
The argument `type.predict` is set to `"response"` to indicate that we want to extract the predicted values on the *probability* scale.
By default, these will be on the linear logit scale.
The `data` argument contains the original data frame.
The `data` argument contains the original data frame; if we leave this blank, we'll only get back a data frame with the variables in the propensity score model, but we need the outcome, too.
This code will output a new data frame consisting of all components in `df` with six additional columns corresponding to the logistic regression model that was fit.
The `.fitted` column is the propensity score.

Expand Down
6 changes: 3 additions & 3 deletions chapters/10-estimands.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ finite_sample_wts <- glm(
data = finite_sample,
family = binomial("probit")
) |>
augment(newdata = finite_sample, type.predict = "response") |>
augment(data = finite_sample, type.predict = "response") |>
mutate(wts = wt_ate(.fitted, x))
finite_sample_wts |>
Expand Down Expand Up @@ -309,7 +309,7 @@ sim <- function(n) {
data = finite_sample,
family = binomial("probit")
) |>
augment(newdata = finite_sample, type.predict = "response") |>
augment(data = finite_sample, type.predict = "response") |>
mutate(wts = wt_ate(.fitted, x))
bias <- finite_sample_wts |>
summarize(
Expand Down Expand Up @@ -711,7 +711,7 @@ sim <- function(n) {
data = finite_sample,
family = binomial("probit")
) |>
augment(newdata = finite_sample, type.predict = "response") |>
augment(data = finite_sample, type.predict = "response") |>
mutate(
wts_ate = wt_ate(.fitted, x),
wts_ato = wt_ato(.fitted, x)
Expand Down
2 changes: 1 addition & 1 deletion chapters/15-missingness-and-measurement.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ calib_model <- lm(
)
seven_dwarves_calib <- calib_model |>
augment(newdata = seven_dwarfs_train_2018) |>
augment(data = seven_dwarfs_train_2018) |>
rename(wait_minutes_actual_calib = .fitted) |>
# convert back to the original scale
# and fill in real values where they exist
Expand Down

0 comments on commit 2fa4821

Please sign in to comment.