# r-empirical-finance

Sets the R conventions your agent follows for empirical finance work: fixest regressions, DiD and IV models, Parquet loading through arrow, plots in ggplot2.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf (Devin Desktop), Claude.ai · ★ 165 repo stars
- Author: aspi6246
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/aspi6246/Claude-Code-Skills-for-Academics/tree/HEAD/r-empirical-finance/SKILL.md
- Updated: 2026-08-21
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/r-empirical-finance

## What it does

This skill pins down the house style for R work in empirical finance. Regressions go through `feols` and `feglm` from `fixest`, large Parquet files through `arrow`, plots through `ggplot2` on a minimal theme, and result tables through `etable()` or `modelsummary`.

Panel data gets its own section. Keys via `setkey`, a duplicate check right after loading, and explicit answers on whether the panel is balanced and how merges join. On the estimation side there are templates for two-way fixed effects with clustered standard errors, event studies with `i(rel_year, ref = -1)`, IV/2SLS, and staggered DiD via `sunab()`. Unit-level clustering is the stated default; two-way clustering is fine on short panels as long as you call the choice out.

A gotcha list covers the usual breakage: `lm()` on panel data, a missing `vcov` argument, `read.csv()` on large files, hardcoded paths, summary stats without `na.rm`. You need `fixest` and `arrow` installed for those templates to run. The skill also fixes a project layout, keeps `data/raw` read-only, numbers scripts in run order, and points to `references/fixest-patterns.md` for deeper `fixest` detail.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add aspi6246/Claude-Code-Skills-for-Academics --skill r-empirical-finance -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/r-empirical-finance/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/r-empirical-finance/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add aspi6246/Claude-Code-Skills-for-Academics --skill r-empirical-finance -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/r-empirical-finance/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add aspi6246/Claude-Code-Skills-for-Academics --skill r-empirical-finance -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/r-empirical-finance/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install aspi6246/Claude-Code-Skills-for-Academics r-empirical-finance
```

2. **Manually: put the files in place**
- File: `.github/skills/r-empirical-finance/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add aspi6246/Claude-Code-Skills-for-Academics --skill r-empirical-finance -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/aspi6246/Claude-Code-Skills-for-Academics --path r-empirical-finance
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/r-empirical-finance/SKILL.md` — The legacy .windsurf/skills/ path still works

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/aspi6246/Claude-Code-Skills-for-Academics/tree/HEAD/r-empirical-finance/SKILL.md

## When to use it
- Run a two-way fixed effects regression with clustered standard errors
- Plot an event study around `rel_year`
- Load a large Parquet panel and catch duplicate keys
- Export a regression table to LaTeX for a paper
- Refactor a script that still calls `lm()` on panel data

## Example prompts
- Estimate `feols(roa ~ treatment | firm_id + year, data = dt, vcov = ~firm_id)` and print it with `etable`
- Build an event study on `rel_year` and draw the `iplot`
- Clean this panel: set keys on `firm_id` and `year`, then check for duplicates

## Similar
- [r-econometrics](https://affpapa.org/en/nevibecode/skills/r-econometrics.md) — skill · 340 installs
- [ft50-empirical-writing](https://affpapa.org/en/nevibecode/skills/ft50-empirical-writing.md) — skill · ★ 240 repo stars
- [model-selection](https://affpapa.org/en/nevibecode/skills/model-selection.md) — skill · ★ 89 repo stars
- [stata](https://affpapa.org/en/nevibecode/skills/franklee16-stata.md) — skill · ★ 240 repo stars
- [finance-manager](https://affpapa.org/en/nevibecode/skills/finance-manager.md) — skill · 2500 installs
- [finance-sentiment](https://affpapa.org/en/nevibecode/skills/finance-sentiment.md) — skill · 1700 installs

From the same set: [aspi6246/claude-code-skills-for-academics](https://affpapa.org/en/nevibecode/by/aspi6246/claude-code-skills-for-academics.md) — 17 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
