From strucmod
从数据/文献/矩条件组装 calibration.csv,记录每个参数来源。当用户说"校准参数"、"calibrate"、"匹配矩"、"match moments"、"对齐数据"、"找出 beta / alpha 取多少"时调用。本技能是任何 solve-* 系列的强制前置。
How this skill is triggered — by the user, by Claude, or both
Slash command
/strucmod:calibrate-from-momentsThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
- "把这个模型校准到中国 2010-2020 数据"
solve-* 之前需要确定参数取值的场景| 字段 | 类型 | 说明 |
|---|---|---|
model_name | str | 必须已存在 model/01_setup/<model>/spec.md 且通过 model-reviewer |
target_moments | list[dict] | 来自 spec.md §9.1 的稳态矩列表 |
data_sources | list[path] | 实测数据路径,仅 data/calibration/<model>/manifest.json 中登记过的 |
strategy | enum | closed-form / iterative / SMM / GMM / bayesian |
model/01_setup/<model>/spec.md 存在并通过 model-reviewer 评审data/calibration/<model>/manifest.json 中登记了所需数据spec.md §7 参数表中每个参数都有"来源 / 识别"字段(不能空白)任一不满足,停下并指明缺什么。
把 spec.md §7 的参数表按 来源类型 分组:
| 组 | 来源 | 校准方式 |
|---|---|---|
| A. 文献直接采纳 | 引用论文给值 | 复制 + 注引用 |
| B. 数据直接计算 | 国民账户 / 微观调查 | 直接由数据算 |
| C. 稳态矩匹配 | 模型稳态需匹配某矩 | 求解非线性方程 |
| D. 待估 | SMM / GMM / 极大似然 | 调用估计程序 |
A、B 组直接落值;C 组进入 Step 2;D 组进入 Step 3。
对每个目标矩 m_data,写出模型隐含矩 m_model(theta) 关于参数子集 theta 的函数。
求解 m_model(theta) - m_data = 0:
scipy.optimize.fsolve / nlsolve,初值取文献中位数数值稳定提示:
theta 限制在合理区间(用 bounds)least_squares 或 trust-region 算法若 spec 要求 SMM/GMM:
data/calibration/<model>/<series>.csv、模型仿真器、目标矩函数quality_reports/<model>_estimation_<timestamp>.md 中记录优化路径保存到 model/02_calibrate/<model>/calibration.csv:
parameter,value,unit,source_type,source,identification,bounds_lower,bounds_upper,notes
beta,0.99,quarterly,A,Smets-Wouters (2007),literature,0.95,0.999,
alpha,0.33,share,B,NIPA 2010-2020 mean labor share complement,data direct,0.25,0.40,
delta,0.025,quarterly,C,K/Y=2.5 steady-state matching,moment matching,0.01,0.05,solved with rho_z=0.95
rho_z,0.95,persistence,A,King-Rebelo (1999),literature,0.5,0.99,
sigma_z,0.007,std,B,Solow residual stdev 1990-2020,data direct,0.001,0.05,
依据语言:
parameters.mod,把每个参数 param = value;parameters.jl,构造 Dict 或 NamedTupleparameters.gms,parameters 段parameters.py,PARAMS = {...}每行附 # source: <source> 注释,便于回溯。
调用 math-reviewer 子 agent 验证:
bounds_lower / bounds_upper 内logs/<model>_calibration_<timestamp>.log 记录:
| 文件 | 必产 | 说明 |
|---|---|---|
model/02_calibrate/<model>/calibration.csv | ✅ | 单一事实源 |
model/02_calibrate/<model>/parameters.{mod,jl,gms,py} | ✅ | 语言专用文件 |
output/tables/<model>_calibration.tex | ✅ | 论文用 LaTeX 表 |
quality_reports/<model>_calibration_<timestamp>.md | ✅ | 校准报告 |
logs/<model>_calibration_<timestamp>.log | ✅ | 运行日志 |
source。每个参数必须有可追溯出处。math-reviewer 边界自检的情况下进入 solve-*。calibration.csv。改动必须留 git commit 与 quality_reports/ 记录。data/raw/ 中未经 manifest.json 登记的数据。| 症状 | 处理 |
|---|---|
| 矩匹配不收敛 | 检查初值;改用 least_squares;放宽 bounds;逐个矩匹配 |
| 参数撞到 bounds 边界 | 说明模型机制不足以解释该矩;改 spec 不是改 bounds |
| 数据起止与文献频率不符 | 在 spec.md 显式声明并由 model-reviewer 重审 |
| 估计标准误极大 | 弱识别问题;考虑增加矩或改用 bayesian 先验 |
npx claudepluginhub allblueuk/structural-modeling-for-economists --plugin strucmodProvides behavioral guidelines to reduce common LLM coding mistakes, focusing on simplicity, surgical changes, assumption surfacing, and verifiable success criteria.
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.