Description Usage Arguments Details Value Examples

Declare potential outcomes

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | ```
declare_potential_outcomes(
...,
handler = potential_outcomes_handler,
label = NULL
)
potential_outcomes_internal.formula(
formula,
conditions = c(0, 1),
assignment_variables = "Z",
data,
level = NULL,
label = outcome_variable
)
potential_outcomes_internal.NULL(
formula = stop("Not provided"),
...,
data,
level = NULL
)
``` |

`...` |
arguments to be captured, and later passed to the handler |

`handler` |
a tidy-in, tidy-out function |

`label` |
a string describing the step |

`formula` |
a formula to calculate potential outcomes as functions of assignment variables. |

`conditions` |
see |

`assignment_variables` |
The name of the assignment variable. Generally not required as names are taken from |

`data` |
a data.frame |

`level` |
a character specifying a level of hierarchy for fabricate to calculate at |

A `declare_potential_outcomes`

function is used to create outcomes that each unit would express in each possible treatment condition.

a function that returns a data.frame

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | ```
# Potential outcomes can be declared in two ways:
# by using a formula or as separate variables.
# Using a formula
declare_population(N = 100, U = rnorm(N)) +
declare_potential_outcomes(Y ~ 0.5*Z + U)
# As separate variables
declare_population(N = 100, U = rnorm(N)) +
declare_potential_outcomes(Y_Z_0 = U,
Y_Z_1 = U + 0.5)
# (notice the naming structure: outcome_assignment_condition: Y_Z_1)
# You can change the name of the outcome
declare_population(N = 100, U = rnorm(N)) +
declare_potential_outcomes(Y2 ~ 0.5*Z + U)
# You can change the name of the assignment_variable
declare_population(N = 100, U = rnorm(N)) +
declare_potential_outcomes(Y ~ 0.5*D + U, assignment_variable = "D")
# `conditions` defines the "range" of the potential outcomes function
declare_population(N = 100, age = sample(18:65, N, replace = TRUE)) +
declare_potential_outcomes(formula = Y ~ .05 + .25 * Z + .01 * age * Z,
conditions = 1:4)
# Multiple assignment variables can be specified in `conditions`. For example,
# in a 2x2 factorial potential outcome:
declare_population(N = 100, age = sample(18:65, N, replace = TRUE)) +
declare_potential_outcomes(formula = Y ~ .05 + .25 * Z1 + .01 * age * Z2,
conditions = list(Z1 = 0:1, Z2 = 0:1))
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.