foryourhealth111-pixel/Vibe-Skills / bundled/skills/performing-causal-analysis
performing-causal-analysis
VerifiedEstimate causal effects from existing data. Use when fitting or interpreting DiD, ITS, synthetic control, regression discontinuity, or other treatment-effect analyses, including robustness checks and counterfactual plots. For choosing a study design before analysis, use designing-experiments instead.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 1.4 KB |
| reference/diff_in_diff.md | markdown | 1.7 KB |
| reference/interrupted_time_series.md | markdown | 1.5 KB |
| reference/synthetic_control.md | markdown | 1.4 KB |
reference/synthetic_control.md
View on GitHub# Causal Synthetic Control (SCG)
Synthetic Control constructs a "synthetic" counterfactual unit using a weighted combination of untreated control units.
## Class: `SyntheticControl`
```python
causalpy.experiments.SyntheticControl(
data,
treatment_time,
control_units,
treated_units,
model=None,
**kwargs
)
```
### Parameters
* **`data`** (`pd.DataFrame`): Input dataframe containing panel data.
* **`treatment_time`** (`Union[int, float, pd.Timestamp]`): The time of intervention.
* **`control_units`** (`List[str]`): List of column names representing the control units.
* **`treated_units`** (`List[str]`): List of column names representing the treated unit(s).
* **`model`**: A PyMC model (typically `cp.pymc_models.WeightedSumFitter`) or a Scikit-Learn Regressor.
### How it Works
1. **Fit**: Model learns weights for `control_units` to approximate `treated_units` using **only pre-intervention data**.
2. **Predict**: Weights are applied to `control_units` in post-intervention period.
3. **Impact**: Difference between observed treated unit and synthetic counterfactual.
### Example
```python
import causalpy as cp
import causalpy.pymc_models as cp_pymc
df = cp.load_data("sc")
treatment_time = 70
result = cp.SyntheticControl(
df,
treatment_time,
control_units=["a", "b", "c", "d", "e"],
treated_units=["actual"],
model=cp_pymc.WeightedSumFitter()
)
result.summary()
result.plot()
```
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |