r-econometrics_skill

This skill helps you run IV, DiD, and RDD analyses in R with diagnostics and publication ready output.
  • HTML

156

GitHub Stars

2

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill meleantonio/awesome-econ-ai-stuff --skill r-econometrics

  • index.md5.2 KB
  • SKILL.md5.2 KB

Overview

This skill generates R code and workflows for rigorous econometric analysis, focusing on Instrumental Variables (IV), Difference-in-Differences (DiD), and Regression Discontinuity Design (RDD). It produces publication-ready scripts using modern packages, includes key diagnostics, and emphasizes correct clustering and robustness checks. The output is practical, well-commented, and ready to run with minimal adaptation.

How this skill works

The skill asks a few questions about identification (IV, DiD, RDD, or simple regression), unit of observation, fixed effects, and clustering choices. It then generates step-by-step R code that uses fixest for estimation, includes diagnostics (first-stage F, pre-trend/event-study plots, bandwidth and density tests), and formats results with modelsummary or etable. Each script is organized into setup, data prep, descriptive stats, main specification, robustness checks, visualization, and export sections, with comments explaining interpretation and limitations.

When to use it

  • Estimating causal effects with panel or cross-sectional data
  • Implementing IV when endogeneity is a concern
  • Running DiD with staggered or universal treatment timing
  • Performing sharp or fuzzy RDD around a cutoff
  • Preparing publication-ready regression tables and figures

Best practices

  • Cluster standard errors at the treatment assignment level and consider multi-way clustering if needed
  • Run and plot pre-trend tests for DiD and event studies to assess parallel trends
  • Report first-stage F-statistics and weak-instrument diagnostics for IV (rule of thumb: F>10)
  • Use feols from fixest for fast FE estimation and sunab()/did tools for staggered DiD when appropriate
  • Document specification choices, identification assumptions, and limitations directly in code comments

Example use cases

  • Run a DiD with state and year fixed effects, clustering at the state level, and an event study plot
  • Estimate treatment effect of X on Y using Z as an instrument and report first-stage statistics
  • Implement a sharp RDD with optimal bandwidth selection and McCrary density test
  • Produce robustness table comparing main FE, two-way clustered, and alternative bandwidth specifications
  • Export LaTeX tables and PNG figures for manuscript submission

FAQ

Use fixest for estimation, modelsummary or etable for tables, tidyverse for data prep, and ggplot2 for visualization.

How do I choose clustering level?

Cluster at the level of treatment assignment or the highest aggregation that could generate correlated shocks; add multi-way clustering if both dimensions matter.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational