diff_diff.load_castle_doctrine#
- diff_diff.load_castle_doctrine(force_download=False)[source]
Load Castle Doctrine / Stand Your Ground laws dataset.
This dataset tracks the staggered adoption of Castle Doctrine (Stand Your Ground) laws across U.S. states, which expanded self-defense rights. It’s commonly used to demonstrate heterogeneous treatment timing methods like Callaway-Sant’Anna or Sun-Abraham.
- Parameters:
force_download (bool, default=False) – If True, re-download the dataset even if cached.
- Returns:
Panel dataset with columns: - state : str - State abbreviation - year : int - Year (2000-2010) - first_treat : int - Year of law adoption (0 = never adopted) - homicide_rate : float - Homicides per 100,000 population - population : int - State population - income : float - State median income - treated : int - 1 if law in effect, 0 otherwise - treatment_exposure : float - Fraction of the year the law was in effect - cohort : int - Alias for first_treat
- Return type:
pd.DataFrame
Notes
Castle Doctrine laws remove the duty to retreat before using deadly force in self-defense. States adopted these laws at different times between 2005 and 2009, creating a staggered treatment design.
The canonical data are checksum-verified and returned with
df.attrs["source"] == "cheng_hoekstra_castle_data". A download failure falls back to a checksum-valid cache entry when one exists, returning that canonical data; a pin mismatch additionally warns that the upstream file has changed. Only when neither a verified cache entry nor a verified fresh download is available - or when the source fails to parse or validate - does the loader emit oneUserWarningcontainingSYNTHETICand mark the returned frame as"synthetic_fallback".treatment_exposureis fractional only on canonical frames; synthetic fallback frames set it to a binary 0/1 copy oftreatedand therefore carry no partial-year information.Replicating Cheng-Hoekstra (2013) requires the paper’s regressor and outcome: regress
log(homicide_rate)ontreatment_exposure(theirCDL_it, the proportion of the year the law was in effect), not the binarytreated. See “Castle Doctrine treatment coding” indocs/methodology/REGISTRY.md.References
Cheng, C., & Hoekstra, M. (2013). Does Strengthening Self-Defense Law Deter Crime or Escalate Violence? Evidence from Expansions to Castle Doctrine. Journal of Human Resources, 48(3), 821-854.
Examples
>>> from diff_diff.datasets import load_castle_doctrine >>> from diff_diff import CallawaySantAnna >>> >>> castle = load_castle_doctrine() >>> cs = CallawaySantAnna(control_group="never_treated") >>> results = cs.fit( ... castle, ... outcome="homicide_rate", ... unit="state", ... time="year", ... first_treat="first_treat" ... )