df_to_gapclosing_list: Convert Back to Canonical List Output

Description Usage Arguments Value References Examples

View source: R/df_to_gapclosing_list.R

Description

If the user has used as.data.frame(x) to convert a gapclosing object to a data frame of estimates, this function will invert back to the original list format. This function does not fully reinstate the original gapclosing object because some elements are lost when as.data.frame() is called. This function is most useful as a check on as.data.frame() and as a helper in settings like bootstrapping where a data frame is easier to work with but we want to return to the original format before returning an object to the user.

Usage

1

Arguments

x

A data frame produced by as.data.frame(x) applied to an object x of class gapclosing.

Value

A list containing a subset of the elements in a gapclosing object.

References

Lundberg I (2021). "The gap-closing estimand: A causal approach to study interventions that close disparities across social categories." Sociological Methods and Research. Available at https://osf.io/gx4y3/.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# Simulate example data
simulated_data <- generate_simulated_data(n = 100)

# Fit by outcome modeling
estimate <- gapclosing(
  data = simulated_data,
  outcome_formula = formula(outcome ~ treatment * category + confounder),
  treatment_name = "treatment",
  category_name = "category",
  counterfactual_assignments = 1
)
summary(estimate)

# Convert to a data frame
estimate.df <- as.data.frame(estimate)
# Convert back to a list
estimate.df <- df_to_gapclosing_list(estimate.df)

gapclosing documentation built on Oct. 11, 2021, 9:07 a.m.