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.7861140 26 0.05 0.56 #> 2 0002 -1.0002125 89 0.05 1.19 #> 3 0003 0.1629330 39 0.05 0.69 #> 4 0004 2.3074042 59 0.05 0.89 #> 5 0005 0.7701894 45 0.05 0.75 #> 6 0006 0.6528480 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.7861140 26 0 0.51 #> 2 0002 -1.0002125 89 0 1.14 #> 3 0003 0.1629330 39 0 0.64 #> 4 0004 2.3074042 59 0 0.84 #> 5 0005 0.7701894 45 0 0.70 #> 6 0006 0.6528480 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.7861140 26 0.51 1.02 1.53 2.04 #> 2 0002 -1.0002125 89 1.14 2.28 3.42 4.56 #> 3 0003 0.1629330 39 0.64 1.28 1.92 2.56 #> 4 0004 2.3074042 59 0.84 1.68 2.52 3.36 #> 5 0005 0.7701894 45 0.70 1.40 2.10 2.80 #> 6 0006 0.6528480 51 0.76 1.52 2.28 3.04