Auto-Bin a table of a continuous moderating variable into a discrete moderating variable
Source:R/plot_moderators.R
table_moderator_c_bin.Rd
Use a regression tree to optimally bin a continuous variable, this function will print out a table with estimates and 95
Arguments
- .model
a model produced by `bartCause::bartc()`
- moderator
the moderator as a vector
- .name
sting representing the name of the moderating variable
Examples
# \donttest{
data(lalonde)
confounders <- c('age', 'educ', 'black', 'hisp', 'married', 'nodegr')
model_results <- bartCause::bartc(
response = lalonde[['re78']],
treatment = lalonde[['treat']],
confounders = as.matrix(lalonde[, confounders]),
estimand = 'ate',
commonSuprule = 'none'
)
#> fitting treatment model via method 'bart'
#> fitting response model via method 'bart'
table_moderator_c_bin(model_results, lalonde$age, .name = 'age')
#> Joining with `by = join_by(splits)`
#> Adding missing grouping variables: `moderator`
#> # A tibble: 4 × 5
#> # Groups: moderator [4]
#> moderator est sd lci uci
#> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 age:17-19 1005. 809. -636. 2552.
#> 2 age:20-24 1401. 720. -62.8 2751.
#> 3 age:25-42 1999. 722. 634. 3458.
#> 4 age:43-55 1318. 1440. -2295. 3794.
# }