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 -1.79 26 0.05 0.56 #> 2 0002 -1.00 89 0.05 1.19 #> 3 0003 0.16 39 0.05 0.69 #> 4 0004 2.31 59 0.05 0.89 #> 5 0005 0.77 45 0.05 0.75 #> 6 0006 0.65 51 0.05 0.81# 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 -1.79 26 0 0.51 #> 2 0002 -1.00 89 0 1.14 #> 3 0003 0.16 39 0 0.64 #> 4 0004 2.31 59 0 0.84 #> 5 0005 0.77 45 0 0.70 #> 6 0006 0.65 51 0 0.76# 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 -1.79 26 0.51 1.0 1.5 2.0 #> 2 0002 -1.00 89 1.14 2.3 3.4 4.6 #> 3 0003 0.16 39 0.64 1.3 1.9 2.6 #> 4 0004 2.31 59 0.84 1.7 2.5 3.4 #> 5 0005 0.77 45 0.70 1.4 2.1 2.8 #> 6 0006 0.65 51 0.76 1.5 2.3 3.0