From 2fa4821642d74b823e9af2d43d8a1c6b87b37a64 Mon Sep 17 00:00:00 2001 From: Malcolm Barrett Date: Mon, 23 Dec 2024 17:55:32 -0500 Subject: [PATCH] alright alright, it's `augment(newdata = ...)` -> `augment(data = ...)` for most of our examples --- chapters/02-whole-game.qmd | 2 +- chapters/08-propensity-scores.qmd | 2 +- chapters/10-estimands.qmd | 6 +++--- chapters/15-missingness-and-measurement.qmd | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/chapters/02-whole-game.qmd b/chapters/02-whole-game.qmd index 2e1992f..350d675 100644 --- a/chapters/02-whole-game.qmd +++ b/chapters/02-whole-game.qmd @@ -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)) diff --git a/chapters/08-propensity-scores.qmd b/chapters/08-propensity-scores.qmd index 97b4461..473db6a 100644 --- a/chapters/08-propensity-scores.qmd +++ b/chapters/08-propensity-scores.qmd @@ -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. diff --git a/chapters/10-estimands.qmd b/chapters/10-estimands.qmd index 8f39c88..c28a1dd 100644 --- a/chapters/10-estimands.qmd +++ b/chapters/10-estimands.qmd @@ -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 |> @@ -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( @@ -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) diff --git a/chapters/15-missingness-and-measurement.qmd b/chapters/15-missingness-and-measurement.qmd index d7cd442..f85bb45 100644 --- a/chapters/15-missingness-and-measurement.qmd +++ b/chapters/15-missingness-and-measurement.qmd @@ -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