domains / research / descriptive-statistics-summary-tables / stats
The two skills share the name 'stats' but perform different tasks. The davepoon/buildwithclaude skill is a project-management tool that displays phase progress, plan execution metrics, requirements completion, and git history stats. The brycewang-stanford skill is an econometrics tool for generating publication-quality descriptive statistics, balance tables, and correlation matrices for empirical research. They do not overlap in procedure or intent, so crowning one would hide a real alternative.
| Repository | Path |
|---|---|
| davepoon/buildwithclaude | plugins/gsd/skills/stats/SKILL.md |
| brycewang-stanford/Auto-Empirical-Research-Skills | skills/67-econfin-workflow-toolkit/stats/SKILL.md |
| Role | Repository | Path |
|---|---|---|
| peer | davepoon/buildwithclaude | plugins/gsd/skills/stats/SKILL.md |
| peer | brycewang-stanford/Auto-Empirical-Research-Skills | skills/67-econfin-workflow-toolkit/stats/SKILL.md |
# Stats
This skill covers two distinct uses of the term 'stats'.
## 1. Project Statistics (GSD)
Display comprehensive project statistics including phase progress, plan execution metrics, requirements completion, git history stats, and project timeline.
### Process
1. Execute the stats workflow from the GSD plugin's workflows/stats.md end-to-end.
2. Use Read and Bash tools to gather and display the statistics.
## 2. Descriptive Statistics & Summary Tables (Econometrics)
Generate publication-quality summary statistics tables, balance tables, and correlation matrices for empirical research.
### When to Use
- Before any regression: Summarize your sample to understand distributions and detect issues.
- For the "Data" section of papers: Standard Table 1 with means, SDs, and sample sizes.
- Treatment/control comparison: Balance tables with t-tests or normalized differences.
- Variable relationships: Correlation matrices for initial exploration.
### Summary Statistics Table (Table 1)
#### Python
```python
import pandas as pd
desc = df[['income', 'age', 'education', 'hours_worked']].describe().T
desc = desc[['count', 'mean', 'std', 'min', '25%', '50%', '75%', 'max']]
desc.columns = ['N', 'Mean', 'SD', 'Min', 'P25', 'Median', 'P75', 'Max']
print(desc.round(3).to_string())
```
#### R
```r
library(modelsummary)
datasummary(income + age + education + hours_worked ~
N + Mean + SD + Min + Median + Max,
data = df,
output = "table1.tex")
```
#### Stata
```stata
estpost summarize income age education hours_worked, detail
esttab using "table1.tex", cells("count mean(fmt(3)) sd(fmt(3)) min max") ///
nomtitle nonumber label replace title("Summary Statistics")
```
### Balance Tables (Treatment vs Control)
#### Normalized Differences
Preferred over t-tests for balance assessment (Imbens & Rubin 2015): Δ = (X̄₁ − X̄₀) / √(S₁² + S₀²). Rule: |Δ| < 0.25 is acceptable.
#### Python
```python
import numpy as np
def normalized_diff(treated, control):
return (treated.mean() - control.mean()) / \
np.sqrt(treated.var() + control.var())
```
#### R
```r
library(cobalt)
bal.tab(treatment ~ income + age + education + female,
data = df, thresholds = c(m = 0.25),
stats = c("mean.diffs", "variance.ratios"))
```
#### Stata
```stata
iebaltab income age education female, grpvar(treatment) ///
save("balance.xlsx") replace rowvarlabel ///
pttest starsnoadd normdiff
```
### Correlation Matrix
#### Python
```python
import scipy.stats as stats
vars = ['income', 'age', 'education', 'hours_worked']
corr = df[vars].corr()
```
#### R
```r
library(modelsummary)
datasummary_correlation(df[, c("income", "age", "education", "hours_worked")],
output = "correlation.tex")
```
#### Stata
```stata
pwcorr income age education hours_worked, star(0.05) sig
```
### Missing Data Summary
#### Python
```python
missing = df.isnull().sum()
missing_pct = (missing / len(df) * 100).round(2)
missing_report = pd.DataFrame({'N_Missing': missing, 'Pct_Missing': missing_pct})
missing_report = missing_report[missing_report.N_Missing > 0].sort_values('Pct_Missing', ascending=False)
print(missing_report)
```