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.
中文简介正在准备中。当前显示原文说明。
Complex survey analysis in R with survey (Lumley): svydesign, svymean/svytotal, svyglm, svyby domains, replicate weights (BRR, jackknife, bootstrap). Use when execution language is R. Python equivalent: svy. lm(weights=) is NOT survey analysis.
中文简介正在准备中。当前显示原文说明。
实测评分 未实测
查看安装方法安装前可以查看交给 AI 代理的指令内容。
R's survey package by Thomas Lumley -- the canonical tool for design-based
analysis of complex survey data. Covers survey design specification (strata, PSU,
weights, FPC), variance estimation (Taylor linearization, BRR, jackknife,
bootstrap), descriptive estimation (means, totals, proportions, ratios,
quantiles), survey-weighted GLM regression (gaussian, binomial, Poisson, ordinal,
Cox PH), domain/subpopulation analysis, calibration, and replicate weight
handling. The Python svy package is modeled after this R implementation. Use
when execution language is R and the data comes from a complex sample survey
(NHANES, CPS, ACS PUMS, BRFSS, DHS, ECLS-K, MEPS-HC). For non-survey regression
in R, use r-stats; for fixed effects use fixest; for panel RE/between use
plm.
The survey package is the definitive implementation of design-based inference
for complex survey data. First released in 2003, it is the reference
implementation that Python's svy and Stata's svy: prefix are modeled after.
svydesign() -- specifies strata, PSU, weights, FPCsvymean(), svytotal(), svyratio(),
svyquantile() with design-based standard errorssvyglm() for linear, logistic, Poisson, and more with
design-adjusted inferencesvyby() for correct subpopulation analysis without
pre-filteringsvrepdesign() for BRR, jackknife, bootstrap, Faycalibrate(), postStratify(), rake() for weight
adjustmentsvyolr() for ordinal logistic, svycoxph() for
survival analysis -- models not available in Python's svyThis skill targets survey 4.5 on R 4.5.3. Key features available:
svydesign() and svrepdesign() for all design typessvyglm() with quasi-family support (quasibinomial, quasipoisson)as.svrepdesign() to convert Taylor designs to replicate weight designssvycontrast() for custom linear/nonlinear contrastsoptions(survey.lonely.psu = ...)svyby() for domain estimation across arbitrary grouping variablesNote on emmeans: The emmeans package is NOT installed in this environment.
For marginal means or pairwise comparisons from survey models, use
svycontrast() for custom contrasts, or compute predicted values manually via
predict(svyglm_fit, newdata = ...). See ./references/regression.md for
patterns.
| File | Purpose | When to Read |
|---|---|---|
quickstart.md | svydesign(), svymean(), svytotal(), confint(), basic workflow | Starting with survey or need design setup |
estimation.md | Point estimates, ratios, quantiles, svyby() for domains, svycontrast() | Descriptive survey statistics |
regression.md | svyglm() for linear/logit/Poisson, update(), summary output, marginal effects without emmeans | Survey regression models |
replication.md | svrepdesign(), as.svrepdesign(), BRR, jackknife, bootstrap, replicate weight surveys | Working with replicate weights |
domains.md | svyby() domain estimation, interaction of strata with subgroups, conditional analysis | Subpopulation analysis |
gotchas.md | Lonely PSU handling, degrees of freedom, WLS-is-not-survey, subsetting (subset= not filter), calibration | Debugging common issues |
quickstart.md then estimation.mdquickstart.md then regression.mdreplication.md then estimation.md or
regression.mddomains.mdquickstart.md (federal
survey patterns table)quickstart.md -- the R API is the original
that svy was modeled after| Skill | Relationship |
|---|---|
svy | Python equivalent for complex survey analysis. Python's svy is modeled after R's survey. If execution language is Python, use svy instead |
data-scientist | Provides methodology guidance (especially survey-analysis.md); survey-r provides R implementation. Load data-scientist for "when and why" |
r-stats | Complement for non-survey regression (OLS, GLM, diagnostics). base R lm() with weights is NOT survey-weighted regression -- it does not account for stratification or clustering |
fixest | Complement for fixed effects models and DiD. fixest does not handle complex survey designs; use survey-r for survey-weighted estimation |
plm | Complement for panel models (RE, between, first difference). Does not handle survey designs |
tidyverse | Use for data preparation before passing to survey design objects. survey uses base R data.frames |
What task?
+-- Descriptive statistics (mean, total, proportion)
| +-- ./references/estimation.md
+-- Regression model
| +-- Linear (continuous outcome) --> ./references/regression.md
| +-- Logistic (binary outcome) --> ./references/regression.md
| +-- Poisson (count outcome) --> ./references/regression.md
| +-- Ordinal logistic --> ./references/regression.md (svyolr)
| +-- Cox survival --> ./references/regression.md (svycoxph)
+-- Set up the survey design object
| +-- ./references/quickstart.md
+-- Subpopulation / domain analysis
| +-- ./references/domains.md
+-- Replicate weight design (BRR, jackknife, bootstrap)
| +-- ./references/replication.md
+-- Something isn't working
+-- ./references/gotchas.md
What model?
+-- Linear regression (continuous Y)
| +-- svyglm(family = gaussian()) --> ./references/regression.md
+-- Logistic regression (binary Y)
| +-- svyglm(family = quasibinomial()) --> ./references/regression.md
+-- Poisson regression (count Y)
| +-- svyglm(family = quasipoisson()) --> ./references/regression.md
+-- Ordinal logistic (ordered categories)
| +-- svyolr() --> ./references/regression.md
+-- Cox proportional hazards (survival)
| +-- svycoxph() --> ./references/regression.md
+-- Negative binomial (overdispersed counts)
| +-- svyglm(family = quasipoisson()) as approximation
| +-- Or: MASS::glm.nb() ignores survey design -- use with caution
+-- Fixed effects + survey weights
+-- Methodologically complex -- consult data-scientist skill
What do you have?
+-- Design variables (strata, PSU, weights)
| +-- Taylor linearization via svydesign() --> ./references/quickstart.md
+-- Pre-computed replicate weights
| +-- BRR --> ./references/replication.md
| +-- Jackknife --> ./references/replication.md
| +-- Bootstrap --> ./references/replication.md
+-- Need to create replicate weights from design
| +-- as.svrepdesign() --> ./references/replication.md
+-- Not sure what I have
+-- Read survey documentation --> ./references/quickstart.md (federal survey
table)
survey covers:
svyby() and subset()svyolr), Cox PH (svycoxph) -- models NOT in Python svybroom::tidy() for tidy outputsurvey does NOT cover (use other tools):
fixest (survey weights + FE is methodologically
complex; consult data-scientist skill)plmfixesttidymodels or scikit-learn via reticulatedata-scientist
skill for methodologyemmeans -- emmeans is NOT installed; use svycontrast()
or manual predict() insteadImportant: In data research pipelines (see CLAUDE.md), R analyses 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. All survey analysis scripts must follow the Inline
Audit Trail (IAT) standard -- document design specification choices (why these
strata/PSU/weights, what variance method, domain definitions) with # INTENT:,
# REASONING:, and # ASSUMES: comments.
# --- Config ---
library(survey)
# 1. Load data
data <- arrow::read_parquet("data/raw/nhanes_demo.parquet")
# 2. Specify design
# INTENT: NHANES uses a complex multi-stage stratified cluster design
# REASONING: sdmvstra = pseudo-strata, sdmvpsu = pseudo-PSU,
# wtmec2yr = 2-year MEC exam weight
# ASSUMES: Analysis population is the MEC-examined subsample
des <- svydesign(
ids = ~sdmvpsu,
strata = ~sdmvstra,
weights = ~wtmec2yr,
data = data,
nest = TRUE
)
# 3. Estimate
svymean(~bmxbmi, design = des, na.rm = TRUE)
svytotal(~bmxbmi, design = des, na.rm = TRUE)
confint(svymean(~bmxbmi, design = des, na.rm = TRUE))
# 4. Regression
fit <- svyglm(bmxbmi ~ ridageyr + factor(riagendr), design = des)
summary(fit)
| Operation | Code |
|---|---|
| Design (Taylor) | svydesign(ids = ~psu, strata = ~strat, weights = ~wt, data = df, nest = TRUE) |
| Design (replicate) | svrepdesign(weights = ~wt, repweights = "wt[0-9]+", type = "BRR", data = df) |
| Mean | svymean(~var, design = des, na.rm = TRUE) |
| Total | svytotal(~var, design = des, na.rm = TRUE) |
| Proportion | svymean(~factor(var), design = des) |
| Ratio | svyratio(~num, ~denom, design = des) |
| Quantile | svyquantile(~var, design = des, quantiles = 0.5) |
| Domain estimation | svyby(~var, ~group, design = des, svymean) |
| Linear regression | svyglm(y ~ x, design = des, family = gaussian()) |
| Logistic regression | svyglm(y ~ x, design = des, family = quasibinomial()) |
| Poisson regression | svyglm(y ~ x, design = des, family = quasipoisson()) |
| Ordinal logistic | svyolr(ordered(y) ~ x, design = des) |
| Cox PH | svycoxph(Surv(time, event) ~ x, design = des) |
| Subset design | subset(des, age >= 18) |
| Confidence intervals | confint(svymean(...)) |
| Tidy output | broom::tidy(svyglm_fit, conf.int = TRUE) |
| Convert to replicate | as.svrepdesign(des, type = "JKn") |
| Calibrate | calibrate(des, formula = ~age_group, population = pop_totals) |
# Single variable
svymean(~income, design = des)
# Multiple variables
svymean(~income + age, design = des)
# Factor variable (for proportions)
svymean(~factor(education), design = des)
# Domain estimation
svyby(~income, ~gender, design = des, svymean)
# Regression with interaction
svyglm(y ~ x1 * factor(x2), design = des)
| Topic | Reference File |
|---|---|
| svydesign() setup | ./references/quickstart.md |
| Taylor linearization | ./references/quickstart.md |
| svymean() / svytotal() | ./references/quickstart.md |
| confint() for survey estimates | ./references/quickstart.md |
| Federal survey design patterns | ./references/quickstart.md |
| Point estimates | ./references/estimation.md |
| Proportions | ./references/estimation.md |
| Ratios | ./references/estimation.md |
| Quantiles / medians | ./references/estimation.md |
| svyby() for domain estimation | ./references/estimation.md |
| svycontrast() | ./references/estimation.md |
| Design effects (DEFF) | ./references/estimation.md |
| Cross-tabulations (svytable) | ./references/estimation.md |
| Chi-squared test (svychisq) | ./references/estimation.md |
| svyglm() linear | ./references/regression.md |
| svyglm() logistic | ./references/regression.md |
| svyglm() Poisson | ./references/regression.md |
| svyolr() ordinal logistic | ./references/regression.md |
| svycoxph() Cox PH | ./references/regression.md |
| Model comparison / update() | ./references/regression.md |
| Marginal effects without emmeans | ./references/regression.md |
| Odds ratios and IRR | ./references/regression.md |
| svrepdesign() | ./references/replication.md |
| as.svrepdesign() | ./references/replication.md |
| BRR / Fay's method | ./references/replication.md |
| Jackknife (JK1, JKn) | ./references/replication.md |
| Bootstrap replicate weights | ./references/replication.md |
| ACS PUMS successive difference | ./references/replication.md |
| Domain estimation (svyby) | ./references/domains.md |
| Subsetting designs (subset=) | ./references/domains.md |
| Interaction domains | ./references/domains.md |
| Lonely PSU handling | ./references/gotchas.md |
| Degrees of freedom | ./references/gotchas.md |
| WLS is not survey regression | ./references/gotchas.md |
| subset() vs filter() | ./references/gotchas.md |
| Calibration (calibrate, rake, postStratify) | ./references/gotchas.md |
| Weight selection | ./references/gotchas.md |
When the survey package is used as a primary analytical tool, include in the report's Software & Tools references:
Lumley, T. (2004). "Analysis of Complex Survey Samples." Journal of Statistical Software, 9(8), 1-19.
Lumley, T. (2023). survey: Analysis of Complex Survey Samples. R package version 4.5.
Cite when: survey is used for survey-weighted estimation with complex survey designs (strata, PSU, replicate weights). Do not cite when: Only loaded but no survey estimation performed.
还没有评价。欢迎分享你的使用感受。
无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。
还没有评论。来写第一条吧。
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.
中文简介正在准备中。当前显示原文说明。