Potential Outcomes

declare_potential_outcomes(..., potential_outcomes_function = potential_outcomes_function_default)

... | Arguments to the potential_outcomes_function |
---|---|

potential_outcomes_function | A function that accepts a data.frame as an argument and returns a data.frame with potential outcomes columns appended. See the examples for the behavior of the default function. |

a function that returns a data.frame

A `declare_potential_outcomes` declaration returns a function. That function takes data and returns data with potential outcomes columns appended. These columns describe the outcomes that each unit would express if that unit were in the corresponding treatment condition.

The potential outcomes function can sometimes be a stumbling block for users, as some are uncomfortable asserting anything in particular about the very causal process that they are conducting a study to learn about! We recommend trying to imagine what your preferred theory would predict, what an alternative theory would predict, and what your study would reveal if there were no differences in potential outcomes for any unit (i.e., all treatment effects are zero).

my_population <- declare_population(N = 1000, income = rnorm(N), age = sample(18:95, N, replace = TRUE)) pop <- my_population() # By default, there are two ways of declaring potential outcomes: # as separate variables or using a formula: # As separate variables my_potential_outcomes <- declare_potential_outcomes( Y_Z_0 = .05, Y_Z_1 = .30 + .01 * age) head(my_potential_outcomes(pop))#> ID income age Y_Z_0 Y_Z_1 #> 1 0001 0.0235178938 27 0.05 0.57 #> 2 0002 0.1935314992 28 0.05 0.58 #> 3 0003 0.6475869285 58 0.05 0.88 #> 4 0004 -1.1584248436 34 0.05 0.64 #> 5 0005 0.5512135714 69 0.05 0.99 #> 6 0006 -0.0007347207 70 0.05 1.00# Using a formula my_potential_outcomes <- declare_potential_outcomes( formula = Y ~ .25 * Z + .01 * age * Z) pop_pos <- my_potential_outcomes(pop) head(pop_pos)#> ID income age Y_Z_0 Y_Z_1 #> 1 0001 0.0235178938 27 0 0.52 #> 2 0002 0.1935314992 28 0 0.53 #> 3 0003 0.6475869285 58 0 0.83 #> 4 0004 -1.1584248436 34 0 0.59 #> 5 0005 0.5512135714 69 0 0.94 #> 6 0006 -0.0007347207 70 0 0.95# condition_names defines the "range" of the potential outcomes function my_potential_outcomes <- declare_potential_outcomes( formula = Y ~ .25 * Z + .01 * age * Z, condition_names = 1:4) head(my_potential_outcomes(pop))#> ID income age Y_Z_1 Y_Z_2 Y_Z_3 Y_Z_4 #> 1 0001 0.0235178938 27 0.52 1.04 1.56 2.08 #> 2 0002 0.1935314992 28 0.53 1.06 1.59 2.12 #> 3 0003 0.6475869285 58 0.83 1.66 2.49 3.32 #> 4 0004 -1.1584248436 34 0.59 1.18 1.77 2.36 #> 5 0005 0.5512135714 69 0.94 1.88 2.82 3.76 #> 6 0006 -0.0007347207 70 0.95 1.90 2.85 3.80