tune
tune copied to clipboard
add helper for bridging causal fits
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