dot-get_synth_draws3d: Get Synthetic Draws in Tidy Format for Multiple Treated Units...

.get_synth_draws3dR 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 data that identifies units (as a string).

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 data that indicates the intervention time (as a string).

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.


bsynth documentation built on June 25, 2024, 5:08 p.m.