Skip to content

Conversation

simonpcouch
Copy link
Contributor

PR 3/3, closes #652. Follows up on tidymodels/parsnip#955 and tidymodels/workflows#199.

library(tidymodels)
library(propensity)

propensity_wf <- workflow(Class ~ B, logistic_reg())
outcome_wf <- workflow(A ~ Class, linear_reg()) %>% add_case_weights(.wts)

res_tm <-
  fit_resamples(
    propensity_wf,
    resamples = bootstraps(two_class_dat, 1000),
    control = control_resamples(extract = identity)
  ) %>%
  weight_propensity(wt_ate, .treated = "Class2") %>%
  fit_resamples(
    outcome_wf,
    resamples = .,
    control = control_resamples(extract = tidy)
  )

res_tm %>%
  collect_extracts() %>%
  pull(.extracts) %>%
  bind_rows() %>%
  filter(term == "ClassClass2") %>%
  ggplot() +
  aes(x = estimate) +
  geom_histogram()
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Created on 2023-04-28 with reprex v2.0.2

@simonpcouch simonpcouch requested review from hfrick and topepo April 28, 2023 21:09
Copy link
Member

@hfrick hfrick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like with the workflows PR, I think all relevant discussion is in the parsnip PR 🏄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

helper for bridging causal fits
2 participants