Statistical Correctness Validation for SQL-Based Panel Analysis
Verify econometric integrity, time-series continuity, and aggregation precision across SQL analytical models.
Use this checklist when validating SQL scripts that calculate econometric indicators, longitudinal regressions, or multi-period aggregations. It prevents silent calculation bugs like survivor bias, lookahead leakage, and floating-point drift.
Role: Senior Quantitative Analytics Methodologist specialized in statistical computing and econometric data pipelines.
Context
- Target SQL Dialect: {{sql_dialect}}
- Analytical & Econometric Framework: {{analytical_framework}}
- Longitudinal Panel Dimensions: {{panel_dimensions}}
- Aggregation Granularity & Windows: {{aggregation_granularity}}
- Null and Imputation Policy: {{null_handling_policy}}
- Embedded Statistical Calculations: {{statistical_tests_embedded}}
Task
Create a rigorous statistical verification checklist to audit SQL scripts implementing {{analytical_framework}}, ensuring mathematical precision, temporal integrity, and valid handling of unbalanced panel datasets.
Method
- Review {{analytical_framework}} against {{panel_dimensions}} to detect survivorship bias and panel attrition flaws in initial CTE selections.
- Verify that temporal lead/lag window offsets strictly prevent lookahead data leakage in {{aggregation_granularity}} calculations.
- Audit division operations and cumulative product calculations against floating-point precision loss and catastrophic cancellation risks in {{sql_dialect}}.
- Validate that {{null_handling_policy}} distinguishes correctly between true structural zeros, missing observations, and non-applicable entity states.
- Inspect degrees-of-freedom adjustments and denominator corrections in {{statistical_tests_embedded}}.
- Evaluate group-by groupings to ensure unbalanced panel units do not introduce unweighted aggregation bias.
- Check rolling window calculations for correct frame bounds (
ROWS BETWEENvsRANGE BETWEEN). - Develop deterministic baseline tests comparing SQL outputs against known analytical reference values.
Constraints
- MUST include explicit SQL validation assertions or test queries for every verification category.
- MUST NOT permit ambiguous floating-point comparisons without explicit epsilon tolerance thresholds.
- All lookahead leakage checks MUST explicitly define the temporal timestamp boundary rules.
- Must cover edge cases where entity group size N is 0 or 1.
Output format
- Validation Scope Summary (1 paragraph defining analytical boundaries)
- Phase 1: Temporal Integrity & Leakage Prevention Checklist (4-5 markdown checkbox items with SQL assertion code)
- Phase 2: Panel Balance & Aggregation Mechanics Checklist (4-5 markdown checkbox items with SQL assertion code)
- Phase 3: Numerical Stability & Statistical Precision Checklist (4-5 markdown checkbox items with expected outcomes)
- Acceptance Sign-off Criteria (3-4 definitive mathematical conditions required for sign-off)
Self-review
- Ensure each checklist item includes a concrete assertion test in {{sql_dialect}}.
- Verify that statistical formula mechanics in {{statistical_tests_embedded}} are thoroughly audited.
- Confirm that unbalanced panel handling is explicitly validated.
Explicit role, a named task, and discrete steps the model can follow.
Background, inputs and variables the model needs before it starts.
Hard boundaries — what the model must and must not do.
A named, field-level shape for the response.
Ordered work items that force analysis before an answer.
Length and structure that travel across frontier models.
Signal density — instruction weight without padding.
Documented variables so the scaffold adapts to new inputs.
Quality bar, assumptions and behaviour when inputs are thin.
How much real usage the template has behind it.