.get_synth_draws3d {bsynth} | R Documentation |
Get Synthetic Draws in Tidy Format for Multiple Treated Units (3D Array)
Description
This internal helper function extracts synthetic draws from a Stan fit object where the draws are stored in a 3D array. It handles multiple treated units and combines the draws with observed outcome data, returning a tidy data frame suitable for analysis or plotting.
Usage
.get_synth_draws3d(fit, data, id, treated_ids, time, outcome, intervention)
Arguments
fit |
A Stan fit object containing the model results. |
data |
A data frame with the input data, including outcome, time, and unit identifier. |
id |
The name of the variable in |
treated_ids |
A vector of identifiers for the treated units. |
time |
The name of the time period variable (as a string). |
outcome |
The name of the outcome variable (as a string). |
intervention |
The name of the variable in |
Value
A data frame containing:
-
draw
: The index of the synthetic draw. -
id
: The identifier of the treated unit. -
time
: The time period. -
y_hat
: The synthetic outcome for the given draw, unit, and time period.