Rdd 标志

Rdd

社区
ericluo04
rdd

Design, estimate, validate, and write up a regression discontinuity analysis, in both the continuity and local-randomization frameworks, with the full falsification battery and a refusal rule for designs that fail validation. TRIGGER on "regression discontinuity", "RDD", "running variable", "score cutoff", "rdrobust", "bandwidth selection", "McCrary test", "density test", "fuzzy RD", "regression kink", "local randomization", "donut", "geographic RD", "boundary discontinuity", "multiple cutoffs", "heaping", "rddensity", "rdlocrand", "RDHonest", or any setting where treatment switches at a known score threshold (loyalty tiers, spend thresholds, ranking cutoffs, algorithmic triggers, eligibility scores, age or tenure rules).

概览

发布者ericluo04
代码仓库claude-academic-workflow
技能名称rdd
星标数
26
复刻数
3
附带文件
3
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 3 个附带文件

    模型执行任务时可读取的脚本、模板和参考资料。这些文件为只读文件,绝不会被执行。

  • 开源

    由 ericluo04 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Rdd AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/ericluo04/claude-academic-workflow/tree/main/skills/rdd
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/ericluo04/claude-academic-workflow.git /tmp/claude-academic-workflow
mkdir -p .claude/skills
cp -r /tmp/claude-academic-workflow/skills/rdd .claude/skills/rdd
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Rdd,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Rdd。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Rdd 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

Regression discontinuity

An opinionated RD workflow grounded in a read canon (references/canon.md): the Cattaneo-Titiunik Annual Review of Economics survey and its applied companion, the Cattaneo-Keele-Titiunik guide, which includes a real failed design this skill uses as its refusal template. Deliverable: the recommendation with its citation, the R estimation and diagnostics code, and a methods paragraph. The skill stops at the four stop points in ../causal-design/references/shared-rules.md (section "Stop points") and puts each choice to the user.

Current as of 2026-10-09; refresh per shared-rules (../causal-design/references/shared-rules.md, section "Refresh path"). Nothing enters the canon without the user's approval.

Design shapes and the case that anchors each

Each canonical case is a precedent a methods section can cite; details.md says what each teaches.

Design shapeCanonical caseMarketing analogueWhat kills it
Age or tenure eligibility ruleCard, Dobkin, Maestas 2008trial expiry, anniversary status rolloffsomething else switches at the same threshold
Agency-measured score, sharpHansen 2015churn-score retention offersreps or managers override the rule off-cutoff
Heaped or rounded scoreAlmond et al. 2010; Barreca et al. 2011, 2016spend thresholds recorded in whole dollarsexcess mass at round values that the density test misses
Share crossing a fixed barLee, Moretti, Butler 2004seller badge above an on-time-delivery ratepredetermined covariates already jump in the smallest window
Admission cutoff, fuzzy first stageHoekstra 2009lead-score outreach with rep discretiona first stage too weak to carry the ratio
Boundary or geographic RDBlack 1999DMA advertising bordersthe border sorts households, or ads spill across it

The design gate: is this an RD at all?

An RD requires a score, a known cutoff, and a treatment rule that existed ex ante and is verifiable. Before any estimation, write the qualitative account: who computes the score, was the cutoff public, can agents precisely control their score near it. Precise manipulation is the most important threat. Lab-measured or third-party-computed scores resist it; self-influenced scores (customer spend near a tier threshold, follower counts near a monetization bar) invite exactly the sorting the density test detects, so the falsification battery carries more weight in marketing settings than in the medical originals.

One more gate question, and the one sharp designs skip: list every rule, benefit, message, and flag that changes at this exact threshold, and say which of them is the treatment. Medicare starts at 65 and so does retirement, so Card, Dobkin, and Maestas (2008) went to a third dataset on the same running variable (the pooled March CPS 1996-2004, pp. 2247-2248) and showed employment does not jump. When the confounder is not in your data, find a dataset on the same score where it is.

State the no-interference assumption: one unit's side of the cutoff does not change another unit's outcome. A seller badge or a loyalty tier can shift the competitors and peers sitting just below the cutoff. When that is plausible, the estimate mixes the direct effect with a spillover onto the comparison group, and the price is that the RD no longer identifies the direct effect alone. Name the channel in the write-up. Spillover designs belong to the field-experiment skill's interference material.

Two red flags come from the failed Oncotype-DX application in Cattaneo-Keele-Titiunik (2023). The guide read the take-up jumps at scores 24 and 25 as evidence the guideline was not followed. It rejected the design on the weak first stage (F = 1.51) and on imbalance in the smallest windows. Treating the first flag as disqualifying on its own is this skill's judgment. Off-cutoff jumps mean the official cutoff is not the rule that assigns treatment.

  1. Treatment take-up jumps at score values away from the official cutoff (the rule was soft: reps contact leads below the threshold, managers grant status matches early). Plot take-up against the score before anything else.
  2. Covariate imbalance already in the smallest window around the cutoff: disqualifying when the imbalanced covariate plausibly drives the outcome (the balance battery's standard, below), otherwise a serious flag that demands an explanation before proceeding.

When a design fails, say so and decline to report an effect; the guide's own verdict on its failed application ("the evidence does not support an RD analysis") is the template. Route the question back to causal-design for another identification strategy.

Triage: two frameworks, and which one leads

Sharp vs fuzzy is a fact of the institution, not a choice: sharp when the rule binds mechanically (a trial expires, a discount ends at an anniversary), fuzzy whenever anyone can cross their assignment (overrides, opt-ins). Under fuzziness always report both ITT effects (on take-up and on the outcome) alongside the fuzzy ratio.

Continuity vs local randomization is decided by the score:

  • Continuous score, many observations near the cutoff: continuity framework with local polynomials leads; local randomization is the robustness complement.
  • Discrete score (rule of thumb: roughly 30 or fewer distinct values) or very few observations near the cutoff: local randomization leads. Continuity methods there extrapolate from the nearest mass points and their effective sample size is the number of mass points, not the number of observations. Discrete running variables (weeks of tenure, order counts, months since signup) are the norm in marketing data, which makes this branch more common than the econ literature suggests.
  • Local randomization needs a stronger and different assumption (potential outcomes unrelated to the score inside the window), which must be argued. The two are not nested: local randomization stays valid for discrete scores where continuity methods may fail (Cattaneo-Keele-Titiunik 2023, sec. 2.3).

When both frameworks apply, run both; agreement is a robustness result, and the local randomization CIs covering the continuity point estimate counts as consistency. Expect the window to be far narrower than the bandwidth (in the guide's HIV application, 121 patients vs 2,593), so a local-randomization null alongside a significant continuity estimate can be a power difference, not a contradiction.

The consensus recipe (continuity framework)

Local linear regression, triangular kernel, MSE-optimal bandwidth, robust bias-corrected confidence intervals (Calonico-Cattaneo-Titiunik). Report both the conventional and the robust interval. The one-line justification: in the survey's back-of-the-envelope calculation (Cattaneo and Titiunik 2022), conventional 95 percent intervals at the MSE-optimal bandwidth cover only about 80 percent, and bias correction with the matching variance adjustment restores coverage at the same bandwidth. Two things get called robust: Cunningham, The Mixtape, online ch. 6 sec. 6.6, moves between heteroskedasticity-robust OLS standard errors and rdrobust's Robust row without flagging the difference, and this skill keeps them apart because HC-robust errors leave the point estimate alone while rdrobust's Robust row recenters on the bias-corrected estimate and widens the interval by the variance of the bias estimate.

Hard rules from the review, stated as prohibitions because that is how it states them:

  • Bandwidths must be data-driven and criterion-optimal; choosing one by hand "is discouraged." MSE-optimal for the point estimate, CE-optimal when the interval is the object. Distinct left/right bandwidths are available when curvature differs by side (Arai and Ichimura), and the selectors have clustered variants. The simple RBC implementation runs inference at polynomial order p+1 with the MSE-optimal bandwidth for order p. The Mixtape (online ch. 6 sec. 6.6) replicates Hansen 2015 with hand-picked bandwidths and a rectangular kernel, which is how RD was done before 2014; this skill refuses that as a primary specification and keeps it only for reproducing a paper that predates the criterion-optimal machinery.
  • Never cluster standard errors on the running variable. Lee 2008 and Lee and Card 2008 recommended the practice. This skill states it as a prohibition because Kolesar and Rothe 2018 show that the confidence interval clustered on a discrete score can undercover, with coverage as low as 58 percent at a nominal 95 percent (p. 2279). Use heteroskedasticity-robust variance, honest intervals for a discrete score (RDHonestBME, below), and cluster only on a real assignment unit that is not the score. Replicating or refereeing an older RD, expect to find this and fix it. The family's clustering and multiplicity rules (cluster level, few clusters, a multiplicity statement for the balance battery) are in ../causal-design/references/shared-rules.md.
  • Global polynomial fits are visualization only, never estimation (Gelman-Imbens): boundary behavior, counterintuitive weighting, overfitting.
  • Polynomial order: p = 1 default, p = 2 and a uniform kernel as the robustness checks, never high order. A data-driven choice of order exists (Pei, Lee, Card, and Weber). Underfitting biases in the other direction. Curvature is handled by narrowing the window, since the common MSE-optimal bandwidth shrinks as the curvature difference across the cutoff rises (Imbens and Kalyanaraman 2012). h_MSE also grows with p, so the p = 2 check runs on a wider window and a different effective sample. When p = 2 moves the estimate, check the window. The Mixtape's numbers for both points (Tables 6.1 and 6.8) are in references/details.md, section "Polynomial order: the Mixtape numbers".
  • Covariates are for precision only (Calonico, Cattaneo, Farrell, and Titiunik 2019); they cannot restore identification of the canonical RD parameter, and adjusting an invalid design changes the parameter rather than rescuing it. The point estimate should barely move when covariates enter; a large move signals imbalance.

The local-randomization recipe

Select the window by nested covariate-balance tests, then difference in means inside it, with Fisherian randomization inference when the window holds few observations (exact under the sharp null) and Neyman or super-population inference when it is well populated. Window-selection mechanics, thresholds, and what a narrow window does to power: references/details.md.

Fuzzy designs: the IV discipline applies

The fuzzy estimand is a complier average effect at the cutoff under relevance, exclusion, and monotonicity, so the iv skill's habits transfer:

  • Test the first stage inside the bandwidth or window, never on the full sample; the full-sample F overstates strength. The guide's contrast is the anchor: F around 698 in the valid design against F = 1.51 in the failed one, where the first-stage effect is 0.15 with a Fisherian p-value of 0.32. An in-bandwidth first-stage F that is neither the strong nor the hopeless extreme goes to the iv skill's ladder for reading F. The weak-first-stage intervals come from RD-native tools. In the window, use rdrandinf(fuzzy = list(d, "ar")), whose default statistic is Anderson-Rubin. In the continuity framework, use the bias-aware confidence sets of Noack and Rothe (2024), which are built like Anderson-Rubin sets and stay valid under weak identification. Do not report the 2SLS t.
  • Argue exclusion qualitatively and concretely: it fails if crossing the cutoff changes behavior through anything other than treatment (a low churn score triggering a retention call AND a flag another team acts on).
  • Monotonicity: safe when crossing the threshold moves treatment in one direction only; suspect when overrides run in both directions (the failed-design pattern above, reps contacting below-threshold leads while managers grant early crossings, is exactly the defiers case); one-sided noncompliance buys it for free.
  • Run fuzzy-ratio balance tests: instrument strength amplifies covariate bias, so imbalance invisible to ITT balance can surface in the ratio.
  • Use one MSE-optimal bandwidth for the ratio, not separate ones for numerator and denominator.

Falsification battery

Run them in this order. Each check's bandwidth convention and what its failure means are in references/details.md, section "Falsification checklist with per-check conventions".

  1. Qualitative manipulation account.
  2. Density continuity test (rddensity) plus the exact binomial count test. When a density jump cannot be explained, report the manipulation-robust bounds of Gerard, Rokkanen, and Rothe (2020) or walk away.
  3. Heaping: the raw histogram of the score.
  4. Covariate and placebo-outcome balance. A failure on a covariate that plausibly drives the outcome invalidates the design, and the verdict is to walk away rather than to adjust.
  5. Placebo cutoffs.
  6. Donut hole.
  7. Bandwidth and window sensitivity.

When a null matters, report minimum detectable effects (rdpower), never ex-post power from the observed effect.

The live dispute, carried honestly

Robust bias correction (this canon's school) vs honest uniform-in-bias inference (Armstrong-Kolesar, Imbens-Wager; R package RDHonest). The honest school bounds the second derivative by a constant M and gets uniformly valid intervals; the canon's objection is that a data-driven M destroys the uniformity that motivates the method, and a manual M is equivalent to choosing the bandwidth by hand. RDHonest has two data-driven routes. RDSmoothnessBound() estimates a lower bound on M, and RDHonest() falls back to the Armstrong-Kolesár (2020) rule of thumb when M is omitted (MROT, confirmed in the 1.0.2 CRAN source). Default here: RBC. When a referee or coauthor asks for honest intervals, report RDHonest alongside with the M choice justified in text, and cite both sides.

The honest school's fuzzy answer is Noack and Rothe (2024). Their bias-aware confidence sets match the usual procedures under strong identification and a continuous score. They stay valid with a discrete score, a donut, or a weak first stage, where the delta-method interval relies on approximations that can fail. Report them when the in-bandwidth first stage is weak. They are not on CRAN (index checked 2026-10-09). The authors' FRD package is a Windows binary on Noack's site, and we have not checked it. A 2025 preprint (Ghosh, Imbens, and Wager, PLRD) argues that widely used RD intervals often behave suboptimally in simulations calibrated to twelve published applications. In its v3, rdrobust's RBC intervals undercover in some calibrated designs and at n = 500 (Tables 1 and 3).

Extensions, briefly

  • Kink designs: same machinery on first derivatives; identification is more delicate.
  • Multiple cutoffs or scores (tiered loyalty programs): cutoff-specific effects or normalize-and-pool (rdmulti), with the pooled estimand's interpretation checked.
  • Geographic or boundary RD (DMA advertising borders): rd2d (Cattaneo, Titiunik, and Yu 2025) estimates effects along the boundary from each unit's two-dimensional location, with uniform inference over boundary points.
  • Heterogeneity (subgroup effects at the cutoff): rdhte (Calonico, Cattaneo, Farrell, Palomba, and Titiunik 2025) fits a fully interacted local linear model with robust bias-corrected inference and tests group differences, where applied work has used ad hoc approaches.
  • Repeated thresholds (monthly tier evaluations, where a unit can cross the cutoff many times): a static RD misreads the long-run effect. Hsu and Shen (2024) give identification and inference for dynamic RD under heterogeneous effects.
  • RD in time: hard to justify as standard RD; the local-randomization framework is the adaptation when it works at all. Prefer did or synthetic-control for policy-date designs.
  • Extrapolation beyond the cutoff LATE needs added assumptions, and the menu is in references/details.md. Say which one when claiming anything away from the cutoff. Absent one, the methods paragraph says the estimate is local to the cutoff, full stop.

R implementation

The complete runnable pipeline is scripts/rdd_template.R (estimation in both frameworks, fuzzy diagnostics, the full falsification battery, power/MDE), with every call verified against the rdpackages suite. The core:

r
library(rdrobust); library(rddensity); library(rdlocrand)
rdplot(y, x, c = cutoff)                      # anatomy first
summary(rdrobust(y, x, c = cutoff))           # sharp: local linear, triangular, MSE-h, RBC
summary(rdrobust(d, x, c = cutoff))           # first stage / ITT on take-up
summary(rdrobust(y, x, c = cutoff, fuzzy = d))# fuzzy ratio
summary(rddensity(x, c = cutoff))             # manipulation
w <- rdwinselect(x, Z, cutoff = cutoff)       # local-randomization window
rdrandinf(y, x, cutoff = cutoff, wl = w$w_left, wr = w$w_right)

Four figures carry a credible RD: the density of the score, take-up against the score, covariate balance, and the outcome in bin means. If you cannot see the effect in the bin means you are underpowered or it is not there. Report the estimate against the mean of the dependent variable, so a small coefficient on a large base reads as a precise null (0.6 points on an 84.6 percent base, in the Mixtape's balance table, online ch. 6 sec. 6.6, Table 6.6).

Package index with versions and links in references/details.md. Stata and Python mirrors of the whole suite live at rdpackages.github.io; the guide ships full replication code in all three.

Methods paragraph template

Report each effect with the results sentence in ../causal-design/references/shared-rules.md (section "Results sentence"): magnitude, direction, a benchmark, and the calibration vocabulary.

Treatment assignment changes discontinuously at [cutoff] in [score], a rule set by [institution] before the outcomes we study, and units [cannot / can only imprecisely] control their score near it. The estimand is [the average effect of treatment for units at the cutoff (sharp) / the average effect for compliers at the cutoff (fuzzy)]. We estimate the RD effect with local linear regression, a triangular kernel, and an MSE-optimal bandwidth of [h] on [each side / the left and right] ([N_left] and [N_right] observations inside it), and report robust bias-corrected confidence intervals (Calonico, Cattaneo, and Titiunik 2014; Cattaneo and Titiunik 2022). Standard errors use [the nearest-neighbor heteroskedasticity-robust variance / CR3 variance clustered by [unit], with [G] clusters]. [In the local-randomization framework, the window [w_left, w_right] holds [N_w] observations, and the Fisherian difference in means is [estimate] (p = [p]).] We validate the design with the Cattaneo-Jansson-Ma density test and an exact binomial test, covariate balance at the cutoff with per-covariate bandwidths, placebo cutoffs, donut-hole estimates, and bandwidth sensitivity [and, for the fuzzy design, verify first-stage strength within the estimation bandwidth and report intention-to-treat effects alongside the complier estimate]. The estimate is local to the cutoff; a limitation of this design is that it does not identify effects for [units far from the threshold], and I extrapolate only [not at all / under the stated assumption], which costs [generalizability across the score distribution].

Every claim traces to references/canon.md; keys live in ../causal-design/references/causal.bib.

Handoffs

  • causal-design: whether an RD exists at all; where to go when the design gate fails.
  • iv: the fuzzy branch's in-bandwidth first stage and exclusion argument live here; weak-instrument inference (the F ladder, AR/CLR intervals) lives in iv, along with many-instrument and shift-share logic.
  • did / synthetic-control: policy-date designs masquerading as RD in time.
  • Preregistration: the user writes it themselves; this skill supplies the RD field list for an upcoming threshold change.

附带文件

技能加载后,模型会按需读取这些文件。它们仅作为可读文件提供,绝不会被执行。

常见问题

Rdd AI 技能有什么作用?

Design, estimate, validate, and write up a regression discontinuity analysis, in both the continuity and local-randomization frameworks, with the full falsification battery and a refusal rule for designs that fail validation. TRIGGER on "regression discontinuity", "RDD", "running variable", "score cutoff", "rdrobust", "bandwidth selection", "McCrary test", "density test", "fuzzy RD", "regression kink", "local randomization", "donut", "geographic RD", "boundary discontinuity", "multiple cutoffs", "heaping", "rddensity", "rdlocrand", "RDHonest", or any setting where treatment switches at a kn...

为什么在 TypingMind 中使用 Rdd?

因为您只需安装一次,就能搭配任何模型使用。Rdd 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Rdd?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/ericluo04/claude-academic-workflow/tree/main/skills/rdd。TypingMind 会读取其中的 SKILL.md,打包相关文件,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Rdd?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Rdd 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Rdd 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Rdd AI 技能免费吗?

ericluo04 已在 GitHub 上发布了该技能。请查看代码仓库了解许可条款。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇