statspai.smart¶
smart ¶
Smart Workflow Engine.
Registered workflow helpers for planning, diagnostics, sensitivity, and replication support:
- recommend() — DAG + data → estimator selection
- compare_estimators() — run multiple methods, compare, diagnose
- assumption_audit() — comprehensive assumption testing by method
- sensitivity_dashboard() — multi-dimensional sensitivity analysis
- pub_ready() — journal-specific publication readiness checklist
- replicate() — famous paper replication with built-in data
RecommendationResult ¶
Result from the estimator recommendation engine.
to_latex ¶
Export recommendations as a booktabs LaTeX table.
If verify=True was used when calling recommend(), the
table includes the stability-check columns (composite score,
bootstrap stability, placebo pass-rate, subsample agreement).
IMPORTANT CAVEAT FOR AUTHORS: The stability score measures whether a method gives consistent estimates under resampling on the observed data — it does NOT establish identification validity or protect against unobserved confounding. A biased OLS on observational data will typically score high because the bias is stable across resamples. Do not cite this score as evidence that a method is "correct" for a given design; use it only to compare the stability of methods that already satisfy the design's identification assumptions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
caption
|
str
|
Table caption. Defaults to the detected design. |
None
|
label
|
str
|
LaTeX label for cross-referencing. |
'tab:recommendation'
|
Returns:
| Type | Description |
|---|---|
str
|
LaTeX source (booktabs + threeparttable). |
run ¶
Execute the recommended estimator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
which
|
int
|
Which recommendation to run (0 = top recommendation). |
0
|
**kwargs
|
Override any parameters. |
{}
|
ComparisonResult ¶
Results from multi-estimator comparison.
AssumptionResult ¶
SensitivityDashboard ¶
Multi-dimensional sensitivity analysis results.
PubReadyResult ¶
Publication readiness checklist results.
IdentificationReport
dataclass
¶
Report from check_identification.
DiagnosticFinding
dataclass
¶
A single design-level finding.
IdentificationError ¶
Bases: Exception
Raised by check_identification(strict=True) when a blocker is found.
Carries the full :class:IdentificationReport on self.report so
downstream code can still inspect findings without re-running.
compare_estimators ¶
compare_estimators(data: DataFrame, y: str, treatment: str, methods: List[str] = None, covariates: List[str] = None, id: str = None, time: str = None, instrument: str = None, alpha: float = 0.05, method_hints: Optional[Dict[str, Dict[str, Any]]] = None) -> ComparisonResult
Run multiple estimators on the same data and compare.
Run selected estimators and return an agreement-diagnostics table for manual robustness review.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
|
required |
y
|
str
|
Outcome variable. |
required |
treatment
|
str
|
Treatment variable (binary). |
required |
methods
|
list of str
|
Estimators to compare. Default auto-selects based on data.
Classical options: Hint-driven Sprint-B options (require |
None
|
method_hints
|
dict
|
Per-method keyword overrides, merged with the shared kwargs when dispatching each estimator. Structure:: Collision rule (docs/ROADMAP.md §6): per-method hints
take precedence over the shared kwargs for the method they
name. If the top-level |
None
|
covariates
|
list of str
|
|
None
|
id
|
str
|
Panel unit ID. |
None
|
time
|
str
|
Time variable. |
None
|
instrument
|
str
|
|
None
|
alpha
|
float
|
|
0.05
|
Returns:
| Type | Description |
|---|---|
ComparisonResult
|
With .summary(), .plot(), .results (dict of individual results). |
Examples:
assumption_audit ¶
assumption_audit(result, data: DataFrame = None, alpha: float = 0.05, verbose: bool = True) -> AssumptionResult
Comprehensive assumption audit for any estimated model.
Run the method's registered assumption checks and provide actionable remedies for failed or inconclusive diagnostics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
EconometricResults or CausalResult
|
Estimated model result. |
required |
data
|
DataFrame
|
Original data (needed for some tests). Auto-extracted if available. |
None
|
alpha
|
float
|
Significance level for tests. |
0.05
|
verbose
|
bool
|
Print summary automatically. |
True
|
Returns:
| Type | Description |
|---|---|
AssumptionResult
|
With .summary(), .failed(), .passed_all() methods. |
Examples:
bib_for ¶
Top-level structured citation for a fitted result.
Convenience entry that pairs with result.cite(format="json")
so agents that don't have direct access to the result method can
pull the structured payload via sp.bib_for(...) instead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
CausalResult or EconometricResults
|
Any fitted result object exposing a |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Same shape as |
Examples:
render_citation ¶
Render a stored BibTeX string in the requested format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bibtex
|
str
|
Raw BibTeX entry as stored on the result class. May contain
multiple |
required |
fmt
|
('bibtex', 'apa', 'json')
|
Output format. |
"bibtex"
|
Returns:
| Type | Description |
|---|---|
str | dict | list
|
|
sensitivity_dashboard ¶
sensitivity_dashboard(result, data: DataFrame = None, dimensions: List[str] = None, alpha: float = 0.05, verbose: bool = True) -> SensitivityDashboard
Comprehensive multi-dimensional sensitivity analysis.
Test sensitivity across selected dimensions and produce an overall stability grade.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
EconometricResults or CausalResult
|
Baseline estimated result. |
required |
data
|
DataFrame
|
Original data (auto-extracted if possible). |
None
|
dimensions
|
list of str
|
Which dimensions to test. Default: all applicable. Options: 'sample', 'controls', 'functional_form', 'outliers', 'unobservables'. |
None
|
alpha
|
float
|
|
0.05
|
verbose
|
bool
|
|
True
|
Returns:
| Type | Description |
|---|---|
SensitivityDashboard
|
|
Examples:
pub_ready ¶
pub_ready(results: list = None, venue: str = 'top5_econ', design: str = None, has_balance: bool = False, has_pretrends: bool = False, has_robustness: bool = False, has_heterogeneity: bool = False, has_sensitivity: bool = False, has_placebo: bool = False, has_mht: bool = False) -> PubReadyResult
Publication readiness checklist.
Generate a venue-specific checklist for empirical paper submission.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
list
|
List of estimated result objects. |
None
|
venue
|
str
|
Target venue: 'top5_econ', 'aej_applied', 'rct'. |
'top5_econ'
|
design
|
str
|
Research design: 'rct', 'did', 'rd', 'iv', 'observational'. |
None
|
has_balance
|
bool
|
Already have balance table. |
False
|
has_pretrends
|
bool
|
Already have pre-trend tests. |
False
|
has_robustness
|
bool
|
Already have robustness checks. |
False
|
has_heterogeneity
|
bool
|
Already have subgroup analysis. |
False
|
has_sensitivity
|
bool
|
Already have sensitivity analysis. |
False
|
has_placebo
|
bool
|
Already have placebo tests. |
False
|
has_mht
|
bool
|
Already have MHT correction. |
False
|
Returns:
| Type | Description |
|---|---|
PubReadyResult
|
|
Examples:
list_replications ¶
check_identification ¶
check_identification(data: DataFrame, y: str, treatment: Optional[str] = None, covariates: Optional[List[str]] = None, id: Optional[str] = None, time: Optional[str] = None, running_var: Optional[str] = None, instrument: Optional[str] = None, cluster: Optional[str] = None, cutoff: Optional[float] = None, design: Optional[str] = None, cohort: Optional[str] = None, dag=None, strict: bool = False) -> IdentificationReport
Run design-level identification diagnostics before fitting an estimator.
This reads your dataframe + design and outputs a prioritised list of pitfalls — bad controls, overlap violations, underpowered designs, small cohorts, clustering ambiguity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
|
required |
y
|
str
|
Outcome column. |
required |
treatment
|
str
|
Binary or continuous treatment column. |
None
|
covariates
|
list of str
|
Candidate control variables. |
None
|
id
|
str
|
Panel identifiers. |
None
|
time
|
str
|
Panel identifiers. |
None
|
running_var
|
str
|
RD running variable. |
None
|
instrument
|
str
|
IV instrument. |
None
|
cluster
|
str
|
Clustering column for inference. |
None
|
cutoff
|
float
|
RD cutoff value. |
None
|
design
|
str
|
Override auto-detected design: one of 'rct', 'did', 'rd', 'iv', 'observational', 'panel'. |
None
|
cohort
|
str
|
First-treatment-period column (for staggered DID). |
None
|
dag
|
DAG
|
Causal DAG. If supplied, runs Cinelli-Forney-Pearl (2022) bad-control detection (mediator, descendant, collider, M-bias) and verifies the covariate set satisfies a valid adjustment criterion. Upgrades correlation heuristic to a principled check. |
None
|
strict
|
bool
|
If True, raise :class: |
False
|
Returns:
| Type | Description |
|---|---|
IdentificationReport
|
With |
Examples: