SpillPanel

data.SpillPanel(
    df,
    spatial_w,
    spatial_W,
    outcome,
    unitid,
    time,
    treat,
    covariates,
    treated_unit,
    treatment_time,
    description,
    column_map=dict(),
    affected_units=(),
)

A bundled case study, ready to feed :class:scspill.SCSPILLConfig.

A panel carries what the models it was published with need: spatial weights for sar, a set of potentially exposed units for cd.

Attributes

Name Type Description
df pd.DataFrame Long panel with a 0/1 treated indicator column (1 for the treated unit in post-treatment periods).
spatial_w pd.Series or None Treated-to-control exposure weights, indexed by donor unit label. Raw (unnormalized); the estimator scales it to sum to one. None for a panel without spatial weights.
spatial_W pd.DataFrame or None Control-to-control spatial weights, indexed and columned by donor unit label. Raw (unnormalized); the estimator row-normalizes it. None for a panel without spatial weights.
outcome, unitid, time, treat str Column names in df.
covariates tuple of str Covariate column names in df.
treated_unit str Label of the treated unit.
treatment_time int First treated period.
description str One-paragraph provenance note.
column_map dict Mapping from original CSV headers to the column names in df (empty when no renaming was applied).
affected_units tuple Control units that may receive a spillover, as published for the cd model; empty when none were published.

Methods

Name Description
config_kwargs Keyword arguments ready to splat into :class:scspill.SCSPILLConfig.

config_kwargs

data.SpillPanel.config_kwargs(method=None)

Keyword arguments ready to splat into :class:scspill.SCSPILLConfig.

Parameters

Name Type Description Default
method ('sar', 'cd') The model to configure. By default "sar" when the panel has spatial weights and "cd" otherwise. "sar"

Returns

Name Type Description
dict The column names plus, for sar, spatial_w, spatial_W and covariates (method is left at its default); for cd, method="cd" and affected_units.

Raises

Name Type Description
ScspillDataError When method="sar" is asked of a panel without spatial weights, or method is unknown.

Examples

from scspill import SCSPILL
from scspill.data import load_california, load_california_cd

sar = SCSPILL({**load_california().config_kwargs(), "seed": 1}).fit()
cd = SCSPILL(load_california_cd(51).config_kwargs()).fit()