Skip to content
Submodule
causalis.scenarios.did.dgp

dgp

Submodule causalis.scenarios.did.dgp with no child pages and 4 documented members.

Functions

Jump directly into the documented functions for this page.

1 items

Data

Jump directly into the documented data for this page.

3 items
data
causalis.scenarios.did.dgp.PanelOutput

PanelOutput

Value: None

None

Canonical target

causalis.scenarios.did.dgp.PanelOutput

Link to this symbol
function
causalis.scenarios.did.dgp.generate_did_gamma_26

generate_did_gamma_26

Generate a staggered-adoption Gamma DID panel for CSA estimators.

The returned panel is long-format with absorbing treatment, multiple first-treatment cohorts, never-treated controls, baseline-compatible covariates, cluster labels, and optional oracle counterfactual/effect columns. It is intended to be consumed directly by :class:causalis.scenarios.did.model.CallawaySantAnnaDID.

Parameters

seedint, default 42

Random seed for reproducibility.

return_panel_databool, default True

If True, returns a :class:PanelDataDID contract; if False, returns a raw :class:pd.DataFrame.

include_oraclesbool, default True

Whether to include ground-truth columns (e.g., y_cf, tau_mean_true).

n_treated_unitsint, default 20

Number of units that will eventually receive treatment.

n_control_unitsint, default 60

Number of never-treated units.

n_pre_periodsint, optional

Number of periods before any treatment starts. Defaults to 24.

n_post_periodsint, optional

Number of periods after the first treatment cohort starts. Defaults to 8.

n_cohortsint, default 4

Number of distinct treatment-start times (cohorts) among treated units.

treatment_effect_ratefloat, default 0.08

Base treatment effect as a fraction of the counterfactual outcome.

treatment_effect_slopefloat, default 0.0

The rate at which the treatment effect grows or decays per period after start.

treatment_effect_heterogeneity_stdfloat, default 0.025

Standard deviation of unit-level treatment effect multipliers.

parallel_trend_violationfloat, default 0.0

Strength of a differential trend between treated and control units (0 = parallel).

calendar_startstr, default “2021-01”

The starting period string for the pandas index.

time_freqstr, default “M”

The pandas frequency alias (e.g., “M”, “W”, “D”).

treated_prefixstr, default “treated_market_”

Prefix for treated unit IDs.

control_prefixstr, default “control_market_”

Prefix for control unit IDs.

**advanced_paramsdict

Reserved for future parameters.

Returns

PanelDataDID or pd.DataFrame

The generated panel dataset.

Examples

Generate default panel data

Notes

The DGP simulates a complex business environment where the outcome YitY_{it} (e.g., revenue) follows a Gamma distribution:

YitGamma(shape=κ,scale=μitκ)Y_{it} \sim \text{Gamma}\left( \text{shape}=\kappa, \text{scale}=\frac{\mu_{it}}{\kappa} \right)

The mean μit\mu_{it} is decomposed into a counterfactual μit(0)\mu_{it}(0) and a treatment effect τit\tau_{it}:

μit(1)=μit(0)(1+τit)\mu_{it}(1) = \mu_{it}(0) \cdot (1 + \tau_{it})

The counterfactual mean μit(0)\mu_{it}(0) is modeled as a product of exposure, conversion rate, and average order value (AOV), each subject to macro-economic cycles, seasonality, and unit-level trends:

lnμit(0)=ln(Exposureit)+ln(ConvRateit)+ln(AOVit)\ln \mu_{it}(0) = \ln(\text{Exposure}_{it}) + \ln(\text{ConvRate}_{it}) + \ln(\text{AOV}_{it})

where each component follows an AR(1) process with latent confounding. The treatment effect τit\tau_{it} for a unit ii treated at time GiG_i is:

τit=(θrate+θslope(tGi))Ramp(tGi)ηi\tau_{it} = (\theta_{rate} + \theta_{slope} \cdot (t - G_i)) \cdot \text{Ramp}(t - G_i) \cdot \eta_i

where Ramp()\text{Ramp}(\cdot) is an exponential adoption curve and ηi\eta_i is unit-level heterogeneity. Parallel trend violations are introduced by adding a differential linear trend to treated units’ counterfactuals.

Canonical target

causalis.scenarios.did.dgp.generate_did_gamma_26

Sections

ParametersReturnsNotesExamples
Link to this symbol
data
causalis.scenarios.did.dgp.generate_staggered_did_gamma_26

generate_staggered_did_gamma_26

Value: None

None

Canonical target

causalis.scenarios.did.dgp.generate_staggered_did_gamma_26

Link to this symbol
data
causalis.scenarios.did.dgp.__all__

__all__

Value: ['generate_did_gamma_26', 'generate_staggered_did_gamma_26']

[‘generate_did_gamma_26’, ‘generate_staggered_did_gamma_26’]

Canonical target

causalis.scenarios.did.dgp.__all__

Link to this symbol