Empirical R Research Code Auditor

LLMs generate syntactically clean R code that executes without errors while silently introducing catastrophic econometric biases. Compare naive prompt output against production academic econometrics.

Active Vulnerability Score: 4 / 4 Bugs Active
⚠️ Silent Cartesian Fanout Detected: Naive left_join() without key validation duplicated 350 rows! Sample inflated from 250 to 600 observations, creating phantom statistical significance. N = 600 (2.4x fanout)
Observed Effect Est. (β)
-0.142
True Param: -0.018 (Null)
Standard Error & p-value
p = 0.004 ***
SE: 0.048 (Unclustered)
Observations (N)
600 (+140%)
True Unique N: 250
Specification Verdict
False Discovery
Unsound Academic Result
Empirical Pipeline Stages (Click to Inspect & Toggle Flaws) Toggle individual fixes to observe real-time coefficient changes
1. Join & Merge
Many-to-Many Fanout
BUG: FANOUT
2. Panel Lags
Cross-Entity Lookahead
BUG: UNGROUPED
3. Missingness & Attrition
Selective Survivorship
BUG: DROP_NA
4. Model & Clustering
Pooled OLS vs Clustered FE
BUG: IID LM
Live Empirical Microdata Regression Fit
Naive Vibecoded Slope Rigorous Econometric Ground Truth
Stage 1: Data Merging & Entity Key Integrity
Naive AI Prompt (ChatGPT / Copilot) Syntax: Valid ✓
Production Academic Econometrics Audited ✓
Naive left_join() assumes uniqueness on composite keys without validation. Unmatched multiple tax codes duplicate entity-year rows.
01 Why "Vibecoding" Fails in Panel Econometrics
When students ask an LLM "merge the minimum wage data with state unemployment and calculate a 1-year lag", the LLM will reliably output df <- left_join(wages, unemp) %>% mutate(lag_wage = lag(wage)). In R, this code runs flawlessly with zero errors or warnings. However:
  • Cartesian Row Duplication: If the secondary dataset contains duplicate records per year, left_join() duplicates rows silently. Standard errors collapse because $N$ is artificially multiplied.
  • Entity Boundary Leakage: dplyr::lag() on an ungrouped tibble shifts values across entity boundaries (e.g., California year 2022 gets assigned Alabama's 2018 value).
  • Phantom Asterisks: Standard OLS lm() assumes independent and identically distributed (i.i.d.) errors, ignoring serially correlated state shocks and inflating $t$-statistics by 200–400%.
Econometric Correction: fixest::feols(log(employment) ~ min_wage + lag_wage | state_id + year, cluster = ~state_id, data = panel_df)
Reproducible R Markdown & Audit Log Export
Download clean R code with academic defensive practices and proof metrics for your research project.
Loading replication artifact...
Enjoy this tool? Build your own with Super