Manual for the marginaleffects R and Python package, and guide to the book "Model to Meaning".

CC-BY-4.0Auto-check passedResearch & Science

Install Marginaleffects

skills CLI
$ npx skills add brycewang-stanford/Auto-Empirical-Research-Skills --skill marginaleffects -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install brycewang-stanford/Auto-Empirical-Research-Skills marginaleffects --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/brycewang-stanford/Auto-Empirical-Research-Skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/39-vincentarelbundock-marginaleffects .claude/skills/marginaleffects && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
marginaleffects
GitHub stars
4.5k
Token cost
~2.1k tokens
SKILL.md length
702 words
Files
2
Skills in repo
369
Repo updated
First seen
Licence
CC-BY-4.0

At a glance

Manual for the marginaleffects R and Python package, and guide to the book "Model to Meaning".

  • Works in 5 steps: Quantity: What estimand? (predictions,… → Predictors (Grid): Where to evaluate?… → Aggregation: Over whom? (unit-level,… → …
  • Users ask about predictions
  • SKILL.md covers Core framework: Five questions…, Quick start, When to use this skill and Instructions, plus 3 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Marginaleffects is an agent skill from brycewang-stanford/Auto-Empirical-Research-Skills. Manual for the marginaleffects R and Python package, and guide to the book "Model to Meaning". Use when users ask about predictions, comparisons, slopes, marginal effects, average treatment effects (ATE/ATT/CATE), hypothesis testing, contrasts, counterfactuals, risk ratios, odds ratios, causal inference with G-computation, or need help with marginaleffects functions like predictions(), comparisons(), slopes(), hypotheses(), datagrid(), avgpredictions(), avgcomparisons(), avgslopes(), or plot functions.

Its SKILL.md is about 2.1k tokens, which your agent loads only when the skill is triggered. The skill folder holds 1 other file (for example `README-original.md`).

It sits in Research & Science, covering Econometrics and empirical research. It works with Python. The repository describes itself as: 🔬 A curated collection of 23,000+ agent skills for empirical research across 8 social science disciplines. | 精选 23,000+ AI Agent 技能库,覆盖8大社会科学学科的实证研究。CoPaper.AI… The licence is CC-BY-4.0.

When your agent uses it

  • Users ask about predictions
  • Marginal effects
  • Average treatment effects (ATE/ATT/CATE)
  • Hypothesis testing

Example prompts

  • “Model to Meaning”
  • “/marginaleffects”

Requirements

  • Python 3
  • Pre-approved tools (allowed-tools): Read, Grep, Glob

Workflow steps

5 steps, taken from the first numbered list in SKILL.md.

  1. Quantity: What estimand? (predictions, comparisons, slopes, or tests)
  2. Predictors (Grid): Where to evaluate? (observed values, counterfactual scenarios, balanced grids)
  3. Aggregation: Over whom? (unit-level, group means with by=, weighted averages)
  4. Uncertainty: Which inference method? (delta method, robust SE, bootstrap, Bayesian)
  5. Test: What hypothesis? (null tests, equivalence, pairwise contrasts)

What it can do on your machine

Read from SKILL.md and the folder at commit 9fa87d8. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Read
    • Grep
    • Glob

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are r and python).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • marginaleffects.com
    • routledge.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Marginaleffects loads about 2.1k tokens when it runs. Until then it costs about 132 tokens; SKILL.md has 702 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~132
When it runs · the whole SKILL.md, loaded when a task matches
~2.1k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from brycewang-stanford/Auto-Empirical-Research-Skills at commit 9fa87d8, republished under its CC-BY-4.0 licence (© brycewang-stanford). 702 words, ~2,108 tokens.

Download SKILL.mdSave it as .claude/skills/marginaleffects/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
marginaleffects
description
Manual for the marginaleffects R and Python package, and guide to the book "Model to Meaning". Use when users ask about predictions, comparisons, slopes, marginal effects, average treatment effects (ATE/ATT/CATE), hypothesis testing, contrasts, counterfactuals, risk ratios, odds ratios, causal inference with G-computation, or need help with marginaleffects functions like predictions(), comparisons(), slopes(), hypotheses(), datagrid(), avg_predictions(), avg_comparisons(), avg_slopes(), or plot functions.
allowed-tools
Read, Grep, Glob
license
CC-BY-4.0
metadata.source
https://marginaleffects.com
metadata.maintainer
vincentarelbundock

marginaleffects

Primary source of information: https://marginaleffects.com Free book, case studies, and vignettes are available there.

Package manual for R and Python, plus a guide to the companion book.

Book: Model to Meaning: How to Interpret Statistical Models in R and Python

Core framework: Five questions for every analysis

Every interpretation task can be decomposed into five disciplined questions:

  1. Quantity: What estimand? (predictions, comparisons, slopes, or tests)
  2. Predictors (Grid): Where to evaluate? (observed values, counterfactual scenarios, balanced grids)
  3. Aggregation: Over whom? (unit-level, group means with by=, weighted averages)
  4. Uncertainty: Which inference method? (delta method, robust SE, bootstrap, Bayesian)
  5. Test: What hypothesis? (null tests, equivalence, pairwise contrasts)

Quick start

Chapter summaries: Read chapters/<chapter>.qmd Function reference: Read man/r/<function>.md or man/python/<function>.md

When to use this skill

  • User asks about predictions, comparisons, slopes, or marginal effects
  • User needs help choosing estimands (ATE, ATT, CATE, risk difference, odds ratio)
  • User asks about marginaleffects function syntax or arguments
  • User wants to interpret model results or test hypotheses
  • User mentions counterfactual analysis, G-computation, or causal inference
  • User references Model to Meaning chapters

Instructions

  1. Classify the request:

    • Conceptual: Which estimand? How to interpret? → Use chapters/
    • Implementation: Function syntax, arguments, code → Use man/r/ or man/python/
    • Mixed: Start with conceptual framing, then provide code
  2. Read the relevant source files:

    • Book chapters: chapters/framework.qmd, chapters/predictions.qmd, chapters/comparisons.qmd, chapters/slopes.qmd, chapters/hypothesis.qmd, etc.
    • R reference: man/r/predictions.md, man/r/comparisons.md, man/r/slopes.md, man/r/hypotheses.md, man/r/datagrid.md
    • Python reference: man/python/predictions.md, man/python/comparisons.md, man/python/slopes.md, man/python/hypotheses.md
  3. Apply the five-question framework to organize your response:

    • Help user define the estimand (Quantity)
    • Clarify where to evaluate it (Grid)
    • Determine aggregation level (Aggregation)
    • Recommend uncertainty quantification (Uncertainty)
    • Specify hypothesis if testing (Test)
  4. Provide concrete code examples using the correct function for their language (R or Python)

Available resources

Book chapters (chapters/)
FileTopicChapter focus
framework.qmdFive-question framework (start here)Defines the five questions and core quantities (predictions, comparisons, slopes) for turning models into intuitive estimands.
predictions.qmdPredicted values and expected outcomesDefines predictions, grids, aggregation, and tests with predictions()/avg_predictions().
comparisons.qmdCounterfactual comparisons, ATE, ATT, risk ratiosDefines counterfactual comparisons, effect functions, grids, and aggregation with comparisons()/avg_comparisons().
slopes.qmdMarginal effects, partial derivativesDefines slopes as partial derivatives, conditional on predictors; uses slopes()/avg_slopes().
hypothesis.qmdHypothesis testing and equivalenceNull vs equivalence tests for any quantity using hypothesis and equivalence arguments.
interactions.qmdInteraction effects and effect modificationInterprets heterogeneity and nonlinearity with interactions and polynomials using predictions, comparisons, and slopes.
categorical.qmdCategorical predictors and contrastsApplies the framework to categorical/ordinal outcomes with predictions and comparisons by outcome level.
experiments.qmdExperimental designsATE in experiments and factorial designs via avg_comparisons() and robust SEs.
gcomputation.qmdG-computation and causal inferenceG-computation steps for ATE/ATT/ATU/CATE with counterfactual prediction grids.
uncertainty.qmdInference methods (delta, bootstrap, Bayesian)Delta method, bootstrap, simulation, conformal prediction, and robust/clustered standard errors via inferences()/vcov.
mrp.qmdMultilevel regression and poststratificationMultilevel models and poststratification with predictions and comparisons in mixed effects.
ml.qmdMachine learning modelsModel auditing with predictions, comparisons, and slopes for ML frameworks.
challenge.qmdThe interpretation challengeDefines analysis goals, estimands, and why coefficients need transformation.
Show full SKILL.md (179 more words)Show less
R function reference (man/r/)

Core functions (includes avg_* variants): predictions.md, comparisons.md, slopes.md, hypotheses.md Grids: datagrid.md Plots: plot_predictions.md, plot_comparisons.md, plot_slopes.md Utilities: posterior_draws.md, inferences.md, get_dataset.md

Python function reference (man/python/)

Core: predictions.md, avg_predictions.md, comparisons.md, avg_comparisons.md, slopes.md, avg_slopes.md, hypotheses.md Grids: datagrid.md Plots: plot_predictions.md, plot_comparisons.md, plot_slopes.md Model fitting: fit_statsmodels.md, fit_sklearn.md, fit_linearmodels.md

Examples

Logit model example

R:

r
library(marginaleffects)

# Fit logistic regression
mod <- glm(am ~ hp + wt, data = mtcars, family = binomial)

# Average marginal effects (slopes on probability scale)
avg_slopes(mod)

# Predicted probabilities at specific values
predictions(mod, newdata = datagrid(hp = c(100, 150, 200), wt = 3))

# Average treatment effect: compare hp = 150 vs hp = 100
avg_comparisons(mod, variables = list(hp = c(100, 150)))

# Risk ratio for a 50-unit increase in hp
avg_comparisons(mod, variables = list(hp = 50), comparison = "ratio")

Python:

python
import marginaleffects as me
import statsmodels.formula.api as smf

# Fit logistic regression
mod = smf.logit("am ~ hp + wt", data=me.get_dataset("mtcars")).fit()

# Average marginal effects
me.avg_slopes(mod)

# Predicted probabilities at specific values
me.predictions(mod, newdata=me.datagrid(mod, hp=[100, 150, 200], wt=3))

# Average treatment effect: compare hp = 150 vs hp = 100
me.avg_comparisons(mod, variables={"hp": [100, 150]})

User asks about choosing an estimand: → Read chapters/framework.qmd and chapters/comparisons.qmd, explain the five-question framework, recommend the appropriate quantity (e.g., avg_comparisons() for ATE).

User asks how to compute marginal effects: → Read man/r/slopes.md or man/python/slopes.md, provide syntax with relevant arguments.

User wants to test treatment effect heterogeneity: → Read chapters/comparisons.qmd for CATE concepts, then man/r/hypotheses.md for testing syntax with by= groups.

User asks about counterfactual grids: → Read chapters/framework.qmd (Predictors section) and man/r/datagrid.md for datagrid() usage.

Best practices

  • Ask about language preference: If the user hasn't specified R or Python, ask which they prefer before providing code examples
  • Always frame responses using the five-question framework when appropriate
  • Cite specific sections from summaries or manuals
  • Mention get_dataset() when users need example data
  • For mixed requests, start with conceptual framing then show implementation

© brycewang-stanford, CC-BY-4.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file in skills/39-vincentarelbundock-marginaleffects of brycewang-stanford/Auto-Empirical-Research-Skills.

  • SKILL.md
  • README-original.md

Open the folder on GitHubat commit 9fa87d8

Compare with similar skills

Marginaleffects next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Marginaleffects compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Marginaleffects this skillbrycewang-stanford/Auto-Empirical-Research-Skills4.5k—~2.1kAutomated safety check: PassCC-BY-4.0
Stata C Pluginsdylantmoore/stata-skill2911 repos~5.8kAutomated safety check: PassCustom licence
Capture Environmentpedrohcgs/claude-code-my-workflow1.6k—~2.8kAutomated safety check: NotesMIT
Fin Data Acquisitioncsmar432/finai-research109—~2kAutomated safety check: PassMIT
Empirical Research MethodsCitrus-bit/Anaxa120—~1.9kAutomated safety check: PassCC-BY-SA-4.0
Diagnosepedrohcgs/claude-code-my-workflow1.6k—~4.2kAutomated safety check: PassMIT

Similar skills

  • Stata C Plugins

    dylantmoore/stata-skill

    Develop high-performance C/C++ plugins for Stata using the stplugin.h SDK.

    291 GitHub starsUsed in 1 repo~5.8k tokens
    Research & ScienceAuto-check passed
  • Capture Environment

    pedrohcgs/claude-code-my-workflow

    Snapshot the computational environment for a replication package — detects the analysis stack (R / Stata / Python) and emits the right lockfiles (renv.lock + sessionInfo.txt, requirements.txt /…

    1.6k GitHub stars~2.8k tokensUpdated 9 days ago
    Research & ScienceAuto-check: notes
  • Fin Data Acquisition

    csmar432/finai-research

    根据REFINEDDESIGN.md中的变量定义,自动获取所需数据并生成可执行的回归分析脚本(Python/Stata)。

    109 GitHub stars~2k tokensUpdated yesterday
    Research & ScienceAuto-check passed
  • A skill your agent uses for empirical social-science research, applied economics, public policy, education, finance, management, sociology, psychology, epidemiology, or public-health data studies.

    120 GitHub stars~1.9k tokensUpdated 1 mo ago
    Research & ScienceAuto-check passed
  • Diagnose

    pedrohcgs/claude-code-my-workflow

    Root-cause a failing or wrong empirical result with a disciplined reproduce → minimise → hypothesise → instrument → fix loop, instead of guessing-and-poking.

    1.6k GitHub stars~4.2k tokensUpdated 9 days ago
    Research & ScienceAuto-check passed
  • Differential Audit

    pedrohcgs/claude-code-my-workflow

    Compare two implementations of the same thing — a port (R↔Python↔Stata), a reimplementation, a replication package, a refactor, or a new version against the old — so that agreement means something.

    1.6k GitHub stars~1.6k tokensUpdated 9 days ago
    Research & ScienceAuto-check: notes

More from brycewang-stanford/Auto-Empirical-Research-Skills

All 369 skills in this repo
  • Latex Paper En

    brycewang-stanford/Auto-Empirical-Research-Skills

    English LaTeX academic paper assistant for existing .tex projects.

    4.5k GitHub starsUsed in 1 repo~2.2k tokens
    Auto-check passed
  • Bayesian Workflow

    brycewang-stanford/Auto-Empirical-Research-Skills

    Opinionated Bayesian modeling workflow with PyMC and ArviZ. An agent skill from brycewang-stanford/Auto-Empirical-Research-Skills.

    4.5k GitHub stars~3.5k tokensUpdated 2 days ago
    Auto-check passed
  • Five Questions

    brycewang-stanford/Auto-Empirical-Research-Skills

    Deeply analyze any empirical economics PDF using the five-question framework (五问框架): research question, identification strategy, core estimand, robustness logic, and scholarly contribution.

    4.5k GitHub stars~1.7k tokensUpdated 2 days ago
    Auto-check: notes
  • Kaggle Research

    brycewang-stanford/Auto-Empirical-Research-Skills

    A skill your agent uses when a research task needs reproducible Kaggle discovery, metadata inspection, bounded public-data downloads, competition or kernel discovery, model discovery, or an…

    4.5k GitHub stars~868 tokensUpdated 2 days ago
    Auto-check passed
  • Latex Thesis Zh

    brycewang-stanford/Auto-Empirical-Research-Skills

    Chinese LaTeX thesis assistant for existing .tex degree thesis projects (XeLaTeX/LuaLaTeX/latexmk).

    4.5k GitHub stars~1.5k tokensUpdated 2 days ago
    Auto-check passed
  • Obsidian Project Memory

    brycewang-stanford/Auto-Empirical-Research-Skills

    This skill should be used when the user asks to maintain an Obsidian knowledge base for a research project, import an existing research repository into Obsidian, keep project memory or daily notes…

    4.5k GitHub stars~2.4k tokensUpdated 2 days ago
    Auto-check passed

Works with

Questions about Marginaleffects

What does Marginaleffects do?

Manual for the marginaleffects R and Python package, and guide to the book "Model to Meaning". Marginaleffects is an agent skill from brycewang-stanford/Auto-Empirical-Research-Skills. Manual for the marginaleffects R and Python package, and guide to the book "Model to Meaning".

When should I use Marginaleffects?

Marginaleffects fits situations like: users ask about predictions; marginal effects; average treatment effects (ATE/ATT/CATE); hypothesis testing.

How do I install Marginaleffects in Claude Code?

Run `npx skills add brycewang-stanford/Auto-Empirical-Research-Skills --skill marginaleffects -a claude-code`. Or copy the skill folder (skills/39-vincentarelbundock-marginaleffects in brycewang-stanford/Auto-Empirical-Research-Skills) into .claude/skills/marginaleffects in your project. Claude Code loads it when a task matches its description.

How do I install Marginaleffects in Codex?

Run `npx skills add brycewang-stanford/Auto-Empirical-Research-Skills --skill marginaleffects -a codex`. Or copy the skill folder (skills/39-vincentarelbundock-marginaleffects in brycewang-stanford/Auto-Empirical-Research-Skills) into .agents/skills/marginaleffects in your project. Codex loads it when a task matches its description.

Can I use Marginaleffects in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add brycewang-stanford/Auto-Empirical-Research-Skills --skill marginaleffects -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/marginaleffects, .gemini/skills/marginaleffects, .github/skills/marginaleffects and .opencode/skills/marginaleffects in your project.

What does Marginaleffects need to run?

SKILL.md names no scripts, command-line tools or credentials: Marginaleffects is instructions for the agent only. Our summary lists: Python 3. Its frontmatter pre-approves these tools: Read, Grep, Glob.

Does Marginaleffects access the network?

SKILL.md names 2 domains. As links in the text: marginaleffects.com and routledge.com. This is read from the text; nothing was executed.

Is Marginaleffects safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Marginaleffects use?

Marginaleffects is published under the CC-BY-4.0 licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Marginaleffects use?

About 2.1k tokens (SKILL.md is roughly 8.4k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Marginaleffects?

Skills that share tags, products or a category with Marginaleffects: Stata C Plugins (dylantmoore/stata-skill, 291 stars), Capture Environment (pedrohcgs/claude-code-my-workflow, 1.6k stars), Fin Data Acquisition (csmar432/finai-research, 109 stars) and Empirical Research Methods (Citrus-bit/Anaxa, 120 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Marginaleffects?

brycewang-stanford (a GitHub user) maintains it in brycewang-stanford/Auto-Empirical-Research-Skills, which has 4,517 GitHub stars. The repository holds 369 skills in this directory. The repository was last updated on October 5, 2026.

Source: brycewang-stanford/Auto-Empirical-Research-Skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.