Guide for creating DAAF agent definition files. Covers 12-section template, hook registration, skills-in-frontmatter, integration checklist. Use when adding or revising agents. For SKILL.md files, use skill-authoring instead.
中文简介正在准备中。当前显示原文说明。
R panel data models with plm: within (FE), random (RE), between, first difference, Fama-MacBeth. Hausman test, panel unit root tests. Includes estimatr for robust estimation and lme4 for mixed effects. Use when execution language is R. Python equivalent: linearmodels. For high- dimensional FE use fixest; for cross-sectional OLS/GLM use r-stats.
中文简介正在准备中。当前显示原文说明。
实测评分 未实测
查看安装方法安装前可以查看交给 AI 代理的指令内容。
R's canonical panel data modeling package. Covers within (FE), random effects
(RE), between, first difference, and pooled OLS estimators via plm(), plus
Fama-MacBeth via pmg() (requires a reversed, time-first index — see
models.md). Provides the Hausman test (phtest()) for FE vs RE selection,
LM tests for unobserved effects (plmtest()), panel serial correlation tests
(pbgtest(), pwartest(), pbsytest()), cross-sectional dependence tests
(pcdtest()), and panel unit root tests (purtest(), cipstest()). Includes estimatr for robust/cluster-robust estimation
(lm_robust(), iv_robust()) and lme4 for mixed-effects models
(lmer(), glmer()). Use when execution language is R and the analysis
involves panel data requiring RE, between, first-difference, or Hausman
testing. Python equivalent: linearmodels. For high-dimensional fixed effects,
IV with FE, or DiD, use fixest. For cross-sectional OLS/GLM without panel
structure, use r-stats.
plm (Croissant & Millo, 2008) is the standard R package for linear panel data
models. It provides a unified formula interface that mirrors base R's lm() but
adds panel-aware estimation:
pdata.frame() declares entity and time identifiersmodel= argument to plm()pmg(model = "mg") with a reversed (time-first) index
— index = c("time", "entity") — so the per-group regressions are
cross-sectional per period, not per-entity time series (see models.md)phtest() for FE vs RE model selectionpgmm() for Arellano-Bond and Blundell-Bond GMMplm() with instruments argument for 2SLS within panelsThis skill also covers two companion packages:
| Package | Version | Role |
|---|---|---|
estimatr | 1.0.6 | lm_robust() and iv_robust() with HC/CR standard errors |
lme4 | 2.0-1 | lmer() for random intercepts/slopes (mixed-effects models) |
This skill targets plm 2.6-7 (R 4.5.3). Key features:
pdata.frame() for explicit panel structure declarationplm() formula interface: y ~ x1 + x2 | instrumentspgmm() supports both Arellano-Bond ("ab") and Blundell-Bond ("bb")
transformations| File | Purpose | When to Read |
|---|---|---|
quickstart.md | pdata.frame, plm() basics, model= argument, summary, coeftest | Starting with plm or panel data in R |
models.md | within, random, between, fd, Fama-MacBeth, comparison | Choosing or switching between panel estimators |
diagnostics.md | phtest() Hausman, plmtest(), pcdtest(), panel unit root | Testing assumptions, model selection |
iv.md | Panel IV via plm() instruments, Sargan/Hansen, pgmm() | IV estimation within panel structure |
robust.md | estimatr lm_robust/iv_robust, HC/CR SEs, plm vcov options | Robust or clustered standard errors |
mixed-effects.md | lme4 lmer/glmer, random intercepts/slopes, ICC | Mixed-effects / multilevel models |
gotchas.md | pdata.frame requirements, FE vs RE, fixest vs plm routing | Debugging or package selection |
quickstart.md then models.mdquickstart.md then diagnostics.mdrobust.mdiv.mdmixed-effects.mdquickstart.md then gotchas.mdThe reference-file routing in this skill applies to advisory and brainstorming turns as much as implementation. Recommending an estimator, reviewing a panel analysis plan, or answering a question that touches a routed topic calls for reading the routed reference file just as much as writing code does — the reference files carry curated caveats and environment-specific constraints (e.g., the Fama-MacBeth index reversal) that this overview and general knowledge lack.
| Skill | Relationship |
|---|---|
linearmodels | Python equivalent for panel data. plm covers the same estimators (FE, RE, between, FD, Fama-MacBeth) with R-native formula syntax. Key API difference: plm uses pdata.frame() for panel declaration; linearmodels uses pandas MultiIndex |
fixest | Preferred for high-dimensional FE, FE + IV, DiD, fast FE demeaning, publication tables. Use plm when fixest cannot do what you need (RE, between, Hausman test, Fama-MacBeth, panel diagnostics, dynamic GMM) |
r-stats | Base R regression without panel structure. Use r-stats for cross-sectional OLS, GLM, classical tests. plm extends the lm() formula interface for panel data |
data-scientist | Methodology guidance -- load for "why and when" behind model choices |
tidyverse | Data preparation before estimation; plm accepts data.frames directly from dplyr pipelines |
gt | Publication-quality tables -- plm model output feeds into modelsummary/gt for formatted regression tables |
What panel estimation method?
+-- Fixed effects (within estimator)
| +-- 1-2 way FE, no IV --> plm (model = "within") or fixest feols
| +-- 3+ way FE --> fixest (plm max 2-way via twoways)
| +-- FE + IV combined --> plm with instruments or fixest 3-part formula
| +-- FE + DiD --> fixest (plm has no DiD)
+-- Random effects (GLS) --> plm (model = "random")
| --> ./references/models.md
+-- FE vs RE comparison --> plm phtest() (Hausman test)
| --> ./references/diagnostics.md
+-- Between estimator --> plm (model = "between")
| --> ./references/models.md
+-- First difference --> plm (model = "fd")
| --> ./references/models.md
+-- Pooled OLS (panel-aware) --> plm (model = "pooling")
| --> ./references/models.md
+-- Fama-MacBeth --> pmg(model = "mg") with REVERSED index c("time","entity")
| --> ./references/models.md
+-- Dynamic panel (Arellano-Bond/Blundell-Bond) --> plm pgmm()
| --> ./references/iv.md
What inference?
+-- Heteroskedasticity-robust (HC) --> ./references/robust.md
| +-- For plm models: vcovHC() from plm
| +-- For lm models: estimatr::lm_robust()
+-- Clustered SEs --> ./references/robust.md
| +-- For plm models: vcovHC(type = "HC1", cluster = "group")
| +-- For lm models: estimatr::lm_robust(clusters = group)
+-- Newey-West (panel HAC) --> ./references/robust.md
| +-- vcovNW() from plm
+-- Driscoll-Kraay --> ./references/robust.md
| +-- vcovSCC() from plm
+-- Bootstrap --> sandwich::vcovBS
What diagnostic?
+-- FE vs RE decision --> ./references/diagnostics.md
| +-- Hausman test: phtest()
+-- Serial correlation --> ./references/diagnostics.md
| +-- Breusch-Godfrey: pbgtest()
| +-- Wooldridge AR(1) FE test: pwartest() / first-difference: pwfdtest()
+-- Unobserved individual/time effects (LM) --> ./references/diagnostics.md
| +-- plmtest() (Breusch-Pagan, Honda, GHM -- NOT a serial correlation test)
+-- Cross-sectional dependence --> ./references/diagnostics.md
| +-- Pesaran CD: pcdtest()
+-- Unit root (stationarity) --> ./references/diagnostics.md
| +-- purtest() (Levin-Lin-Chu, Im-Pesaran-Shin, etc.)
| +-- cipstest() (Pesaran CIPS)
+-- Poolability (F-test for FE) --> ./references/diagnostics.md
| +-- pooltest()
Having issues?
+-- Error about pdata.frame or index --> ./references/gotchas.md
+-- Hausman test gives warnings --> ./references/gotchas.md
+-- Results differ from fixest --> ./references/gotchas.md
+-- Unbalanced panel handling --> ./references/gotchas.md
+-- Want to compare with linearmodels (Python) --> ./references/gotchas.md
+-- plm vs fixest: which to use? --> ./references/gotchas.md
Important: In DAAF research pipelines, plm regressions are executed through script files, not interactively. This ensures auditability and reproducibility.
The pattern:
scripts/stage8_analysis/{step}_{task-name}.RClosely read agent_reference/SCRIPT_EXECUTION_REFERENCE.md for the mandatory
file-first execution protocol covering complete code file writing, output capture,
and file versioning rules. All regression scripts must follow the Inline Audit
Trail (IAT) standard -- see agent_reference/INLINE_AUDIT_TRAIL.md. For regression
code, document model specification choices (why this estimator, why this clustering
level, what identifying assumptions) with # INTENT:, # REASONING:, and
# ASSUMES: comments.
See:
agent_reference/WORKFLOW_PHASE4_ANALYSIS.md -- Stage 8 (Analysis & Visualization)agent_reference/INLINE_AUDIT_TRAIL.md -- IAT documentation standardThe examples below show plm syntax. In research workflows, wrap them in scripts following the file-first pattern.
library(plm)
library(estimatr) # lm_robust, iv_robust
library(lme4) # lmer, glmer
library(lmtest) # coeftest with custom vcov
library(arrow) # For parquet I/O (DAAF convention)
# Declare panel structure -- entity and time identifiers
pdf <- pdata.frame(df, index = c("entity_id", "year"))
# Verify
pdim(pdf) # Panel dimensions
is.pbalanced(pdf) # Check balance
| Operation | Code |
|---|---|
| Panel FE (within) | plm(y ~ x1 + x2, data = pdf, model = "within") |
| Two-way FE | plm(y ~ x1 + x2, data = pdf, model = "within", effect = "twoways") |
| Random effects | plm(y ~ x1 + x2, data = pdf, model = "random") |
| Between | plm(y ~ x1 + x2, data = pdf, model = "between") |
| First difference | plm(y ~ x1 + x2, data = pdf, model = "fd") |
| Pooled OLS | plm(y ~ x1 + x2, data = pdf, model = "pooling") |
| Panel IV | plm(y ~ x1 + x2 | z1 + z2, data = pdf, model = "within") |
| Hausman test | phtest(fe_fit, re_fit) |
| Robust SEs | coeftest(fit, vcov = vcovHC(fit, type = "HC1")) |
| Clustered SEs | coeftest(fit, vcov = vcovHC(fit, cluster = "group")) |
| Driscoll-Kraay | coeftest(fit, vcov = vcovSCC(fit)) |
| Summary | summary(fit) |
| Dynamic GMM | pgmm(y ~ lag(y, 1) + x1 | lag(y, 2:99), data = pdf) |
# Standard panel formula
y ~ x1 + x2
# Panel IV: instruments after |
y ~ x1 + x_endog | z1 + z2 + x1
# Interactions
y ~ x1 * x2 # x1 + x2 + x1:x2
# Transformations
y ~ log(x1) + I(x2^2)
# Suppress intercept (for within estimator, intercept is absorbed anyway)
y ~ x1 + x2 - 1
fit <- plm(y ~ x1 + x2, data = pdf, model = "within")
summary(fit) # Full summary
coef(fit) # Coefficients
vcov(fit) # Variance-covariance matrix
fixef(fit) # Fixed effects estimates
pFtest(fit, plm(y ~ x1 + x2, data = pdf, model = "pooling")) # F-test for FE
within_intercept(fit) # Overall intercept for within model
broom::tidy(fit, conf.int = TRUE) # Tidy output
broom::glance(fit) # Model-level statistics
| Topic | Reference File |
|---|---|
| pdata.frame setup | ./references/quickstart.md |
| plm() basics | ./references/quickstart.md |
| model= argument | ./references/quickstart.md |
| summary() output | ./references/quickstart.md |
| pdim(), is.pbalanced() | ./references/quickstart.md |
| Comparison to linearmodels (Python) | ./references/quickstart.md |
| Within (FE) estimator | ./references/models.md |
| Random effects (RE) | ./references/models.md |
| Between estimator | ./references/models.md |
| First difference (FD) | ./references/models.md |
| Pooled OLS | ./references/models.md |
| Fama-MacBeth (pmg) | ./references/models.md |
| Two-way effects | ./references/models.md |
| Model comparison | ./references/models.md |
| Weighted estimation | ./references/models.md |
| Hausman test (phtest) | ./references/diagnostics.md |
| Poolability F-test | ./references/diagnostics.md |
| Serial correlation tests | ./references/diagnostics.md |
| Cross-sectional dependence | ./references/diagnostics.md |
| Panel unit root tests | ./references/diagnostics.md |
| Panel IV (plm instruments) | ./references/iv.md |
| Sargan/Hansen test | ./references/iv.md |
| Dynamic GMM (pgmm) | ./references/iv.md |
| Arellano-Bond test | ./references/iv.md |
| vcovHC (heteroskedasticity-robust) | ./references/robust.md |
| Clustered SEs | ./references/robust.md |
| Newey-West (vcovNW) | ./references/robust.md |
| Driscoll-Kraay (vcovSCC) | ./references/robust.md |
| estimatr lm_robust | ./references/robust.md |
| estimatr iv_robust | ./references/robust.md |
| lme4 lmer | ./references/mixed-effects.md |
| lme4 glmer | ./references/mixed-effects.md |
| Random intercepts/slopes | ./references/mixed-effects.md |
| ICC (intraclass correlation) | ./references/mixed-effects.md |
| Conditional vs marginal effects | ./references/mixed-effects.md |
| pdata.frame requirements | ./references/gotchas.md |
| Unbalanced panels | ./references/gotchas.md |
| FE vs RE choice | ./references/gotchas.md |
| fixest vs plm routing | ./references/gotchas.md |
| linearmodels vs plm comparison | ./references/gotchas.md |
When plm is used as a primary analytical tool, include in the report's Software & Tools references:
Croissant, Y. & Millo, G. (2008). "Panel Data Econometrics in R: The plm Package." Journal of Statistical Software, 27(2), 1-43.
For estimatr:
Blair, G., Cooper, J., Coppock, A., Humphreys, M., & Sonnet, L. (2022). estimatr: Fast Estimators for Design-Based Inference. R package. https://CRAN.R-project.org/package=estimatr
For lme4:
Bates, D., Machler, M., Bolker, B., & Walker, S. (2015). "Fitting Linear Mixed-Effects Models Using lme4." Journal of Statistical Software, 67(1), 1-48.
Cite when: plm is used for panel estimation (FE, RE, between, FD), Hausman testing, or panel diagnostics. Cite estimatr when HC/CR SEs are the primary inference approach. Cite lme4 when mixed-effects models are estimated. Do not cite when: Only loaded but no estimation performed.
For method-specific citations (e.g., individual estimators or techniques),
consult the reference files in this skill and agent_reference/CITATION_REFERENCE.md.
还没有评价。欢迎分享你的使用感受。
无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。
还没有评论。来写第一条吧。
Guide for creating DAAF agent definition files. Covers 12-section template, hook registration, skills-in-frontmatter, integration checklist. Use when adding or revising agents. For SKILL.md files, use skill-authoring instead.
中文简介正在准备中。当前显示原文说明。
Researcher-facing analytic triangulation ("creative verification") for stress-testing provisional findings and designing pre-specified challenges before an analysis runs. Turns a researcher's concern or focal claim into competing explanations, bounded discriminating tests, audited diagnostic artifacts, and evidence-calibrated interpretations in a hypothesis/evidence ledger — behavioral, output-level verification replacing line-by-line code review. Covers 12 challenge families organized by Shadish-Cook-Campbell validity type, named sensitivity statistics, pre-committed interpretation rules, anti-fishing guardrails, and interactive diagnostic-artifact QA. Use in Ad Hoc Collaboration to verify, challenge, or stress-test a result, or to design discriminating tests before an analysis runs. Not code-change verification (verify skill / code review) and not final adjudication or re-execution (data-verifier, Reproducibility Verification) — prospective, hypothesis-driven challenge design of analytic claims.
中文简介正在准备中。当前显示原文说明。
In-situ smoke testing that verifies a LIVE DAAF deployment functions end-to-end in whatever provider route it is configured for. Auto-detects the active install route (anthropic-subscription, openrouter, chatgpt-subscription shim, openai-api shim) and runs tiered probes: Tier 0 free preflight (route/env coherence, hooks, statuslines, shim health); Tier 1 one live round-trip (~cents); Tier 2 a six-probe functional battery (dispatch, coding, web, skill loading, isolation-strip, nested-dispatch deny); Tier D a zero-cost deterministic battery (bats, Pester, lint, safety-hook tests). Use after install, after a rebuild or update, after any provider/config change (new API key, model remap, shim change), for pre-release validation, or when asked "is my install working" or to "smoke test the deployment/config." Requires the DAAF_DEV=1 dev image; a contributor tool, not end-user-facing. NOT DAAFBench (model behavioral-adherence evaluation under benchmarks/) and NOT scripts/smoke_tests/ (R/Python library-package smoke tests).
中文简介正在准备中。当前显示原文说明。
Operational framework for the DAAF orchestrator. Defines engagement modes, confirmation protocol, subagent dispatch, context budget, and reference-loading. Loaded exclusively by the orchestrator — not for subagents or user questions.
中文简介正在准备中。当前显示原文说明。
Data science methodology and method-selection routing for quantitative research. Covers EDA, data validation, descriptive analysis, causal inference (IV, DiD, RD, synthetic control), clustering/PCA/UMAP, supervised ML, geospatial analysis, network analysis, and visualization design. Contains the canonical method-to-library routing tree, routed by execution language — Python: statsmodels (OLS/GLM/time series), pyfixest (FE/DiD), linearmodels (RE/GMM/SUR), svy (complex surveys), scikit-learn (clustering/prediction ML), geopandas (spatial), igraph (network analysis); R: r-stats (OLS/GLM/time series), fixest (FE/DiD), plm (panel/RE/IV), survey-r (complex surveys), tidymodels (ML), sf-terra (spatial), igraph-r (network analysis). Load the routed tool-specific skill before giving tool-specific advice or writing code — library skills encode environment constraints and curated caveats absent from general knowledge.
中文简介正在准备中。当前显示原文说明。
Interpretation guidance for Urban Institute Education Data Portal datasets. The Portal is a curation layer over federal data: lowercase variable names, integer-encoded categoricals, standardized missing codes (-1 missing, -2 not applicable, -3 suppressed). Covers year definitions, grade encoding (grade=-1 is Pre-K, not missing), suppression rates, ODC-By licensing, and cross-source join identifiers. Load before analyzing any Portal data. Routes to source-specific deep-dive skills for individual datasets.
中文简介正在准备中。当前显示原文说明。