add_balance_table: Add the balancing table to the final output

View source: R/utility_functions.R

add_balance_tableR Documentation

Add the balancing table to the final output

Description

Add the balancing table to the final output

Usage

add_balance_table(scored_data, vars, tm, id, combined_output, treat, matches)

Arguments

scored_data

The dataframe from score_data()

vars

See rollmatch()

tm

See rollmatch()

id

See rollmatch()

combined_output

A list of output for the rollmatch package. See make_output

treat

See rollmatch()

matches

Dataframe containing the matches from comparison_pool

Value

output returns a list with the additional output:

balance

The balancing table.

Examples

## Not run: 
data(package="rollmatch", "rem_synthdata_small")
reduced_data <- reduce_data(data = rem_synthdata_small, treat = "treat",
                            tm = "quarter", entry = "entry_q",
                            id = "indiv_id", lookback = 1)
fm <- as.formula(treat ~ qtr_pmt + yr_pmt + age)
vars <- all.vars(fm)
scored_data <- score_data(model_type = "logistic", match_on = "logit", fm = fm,
                          reduced_data = reduced_data, treat = "treat",
                          tm = "quarter", entry = "entry_q", id = "indiv_id")
comparison_pool <- compare_pool(scored_data, treat = "treat",
                                tm = "quarter", entry = "entry_q",
                                id = "indiv_id")
trimmed_pool <- trim_pool(alpha = .2, comparison_pool = comparison_pool,
                          scored_data = scored_data, treat = "treat",
                          tm = "quarter", standard_deviation = 'average')
matches <- create_matches(trimmed_pool = trimmed_pool, tm = "quarter",
                          num_matches = 3, replacement = TRUE)
matches <- add_matches_columns(matches)
combined_output <- make_output(scored_data = scored_data,
                               data = rem_synthdata_small,
                               matches = matches,
                               treat = "treat", tm = "quarter",
                               entry = "entry_q", id = "indiv_id", lookback = 1)
# Add balance table to the output
output <- add_balance_table(scored_data = scored_data, vars = vars,
                            tm = "quarter", id = "indiv_id",
                            combined_output = combined_output,
                            treat = "treat", matches = matches)

## End(Not run)


RTIInternational/rollmatch documentation built on Feb. 17, 2024, 2:31 p.m.