Charls Reproduce logo

Charls Reproduce

Community
xjtulyc
charls-reproduce

CHARLS (China Health and Retirement Longitudinal Study) database-specific knowledge for reproducing published papers. Use when reproducing or analyzing papers that use CHARLS data, including variable mapping from harmonized to raw questionnaire items, cognitive function scoring (episodic memory, mental status, TICS), CESD-10 depression screening, social isolation index construction, and chronic disease coding. Also use for any CHARLS data cleaning, variable construction, or cohort selection task.

Overview

Publisherxjtulyc
RepositoryMedgeClaw
Skill namecharls-reproduce
Stars
617
Forks
134
Bundled files
1
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 1 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by xjtulyc on GitHub. Read the source before you install it.

Installation

Install the Charls Reproduce AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/xjtulyc/MedgeClaw/tree/main/skills/charls-reproduce
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/xjtulyc/MedgeClaw.git /tmp/MedgeClaw
mkdir -p .claude/skills
cp -r /tmp/MedgeClaw/skills/charls-reproduce .claude/skills/charls-reproduce
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Charls Reproduce in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Charls Reproduce on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Charls Reproduce is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

CHARLS Reproduce — CHARLS 数据库复现指南

CHARLS 概览

项目说明
全称China Health and Retirement Longitudinal Study (中国健康与养老追踪调查)
官网https://charls.pku.edu.cn/
覆盖全国 150 县级单位、450 社区,45 岁以上居民
波次wave1(2011), wave2(2013), wave3(2015), wave4(2018), wave5(2020)
格式Stata (.dta), 也有 harmonized 版本

Harmonized 数据集 vs 原始数据

大多数 CHARLS 论文使用原始问卷模块数据,变量名以 CHARLS 问卷编号命名(如 dc009s1)。但很多用户拿到的是 harmonized 数据集(合并所有波次,变量已清洗重命名)。

识别方法:

  • 如果有 wave 列且包含 wave1-wave5 → harmonized 数据
  • 如果有 dc009s1, be001, sc004_s1 等原始变量名 → 原始数据
  • harmonized 数据通常 ~10 万行(所有波次堆叠),原始数据每波 ~2 万行

关键差异: 变量名完全不同,缺失模式不同,编码方式不同。

核心变量映射表

认知功能

论文常用名原始变量Harmonized 变量范围说明
即时回忆dc009s1–dc009s10imrc0-1010 个词即时回忆正确数
延迟回忆dc012s1–dc012s10dlrc0-10延迟回忆正确数
情景记忆 (EM)自行计算recall 或 (imrc+dlrc)/20-10注意: recall = (imrc+dlrc)/2
Serial 7dc024 (5 次减法)ser70-5100 连续减 7,正确次数
日期定向dc003-dc006orient0-4= dw + dy + mo + yr(4 个二分项之和)
画图dc014draw0-1重画展示图形是否正确
心理状态 (MS)自行计算ser7 + orient + draw0-10重要: 见下方详解
总认知分自行计算total_cognition0-21但 ≠ imrc+dlrc+ser7+orient+draw
心理状态 (Mental Status) 构建详解

论文中 MS 通常定义为 TICS 题目总分 = Serial 7 + 日期定向 + 画图 = 0-10。

但注意:

  • orient = dw + dy + mo + yr(4 项,0-4),不含 ds(day of season)
  • 验证方法: orient == dw + dy + mo + yr 应 100% 吻合
  • 如果论文 MS 均值 ~5-7: 使用 ser7 + orient + draw(0-10)
  • 如果论文 MS 均值 ~3-4: 可能只用了 orient + draw(0-5),不含 ser7
  • ser7 缺失率高(Wave1 约 19%),如果样本量偏差大,考虑排除 ser7

关键经验: ser7 是 MS 定义中缺失率最高的子项。 如果筛选后样本量比论文少很多,先检查是否因 ser7 缺失。 尝试 ms = orient + draw 看样本量是否更接近论文。

抑郁 (CESD-10)

论文常用名原始变量Harmonized 变量范围
CESD-10 总分dc002 系列 (10 题)cesd100-30
抑郁分级CESD ≥ 10cesd10 >= 10二分

CESD-10 的 10 个题目中第 5 题(充满希望)和第 8 题(感到快乐)为反向计分。 harmonized 数据的 cesd10 已经处理好反向计分。

社会隔离

社会隔离指数通常由 4 个二分维度加总(0-4):

维度原始变量Harmonized 变量得 1 分条件
婚姻be001marry非"已婚"状态
子女联系sc004_s1 等kcntf(面对面) + kcntpm(电话邮件)面对面和电话都无
居住地区resid / rsuburbhrural 或 rural2农村
社会活动dc045_s1 等socwk 或 act_1-act_8不参加
婚姻变量编码

marry 的可能值(harmonized 中文标签):

已婚          → 0(有伴侣同居)
已婚但不住在一起 → 视论文定义(通常算 0 或 1)
丧偶          → 1
离异          → 1
分居          → 1
从未结婚       → 1
同居          → 0

关键: "已婚但不住在一起"的编码需要根据论文定义判断。 如果论文说"unmarried or not living with a partner",则算 1。

子女联系频率

harmonized 数据中没有直接的联系频率变量,只有:

  • kcntf: 是否与子女面对面联系(是/否)
  • kcntpm: 是否与子女电话/邮件联系(是/否)
  • kcnt: 是否与子女有任何联系(是/否)
  • hchild: 子女数量

原始数据有具体频率(每周/每月/每年),harmonized 只保留了二分变量。

经验: 如果论文用"每周少于一次"作为阈值,用 harmonized 数据只能近似。 kcntf != '是' and kcntpm != '是' 是合理的近似。

农村/城市
  • hrural: 户籍所在地(农村/城市),每个人在所有波次都一样
  • rural2: 实际居住地(农村/城市),可能与户籍不同

hrural 和 rural2 有交叉不一致的情况。论文通常用 hrural。

人口学与健康变量

论文变量Harmonized 变量编码说明
年龄age连续;140 个缺失值(Wave1)
性别ragender中文标签"男性"/"女性";2 个缺失
教育raeducl3 类: "低于初中学历"/"高中和职业培训"/"高等教育"
教育(细分)raeduc_c4 类: "未完成小学"/"小学"/"中学"/"高中及以上"
BMIbmi连续;有异常值(>100),需过滤 10-60 范围
高血压hibpe"是"/"否";基于"医生曾告知"
糖尿病diabe"是"/"否"
心脏病hearte"是"/"否";含冠心病、心肌梗死等
脑卒中stroke"是"/"否"
当前吸烟smoken"是"/"否"(当前是否吸烟)
曾经吸烟smokev"是"/"否"(是否曾经吸过烟)
过去一年饮酒drinkl"是"/"否"
曾经饮酒drinkev"是"/"否"

社会活动变量

Harmonized 变量含义频率变量
act_1 / social1与朋友互动freq_act_1: 1=几乎每天, 2=每周, 3=不经常, 4=从不
act_2 / social2打牌/麻将/下棋freq_act_2
act_3 / social3参加社区组织freq_act_3
act_4 / social4志愿/慈善活动freq_act_4
act_5 / social5上课/教育培训freq_act_5
act_6 / social6炒股freq_act_6
act_7 / social7上网freq_act_7
act_8 / social8其他freq_act_8
socwk是否参加任何社会活动(汇总)—

日期定向子变量

变量含义纳入 orient
dw星期几 (day of week)✅
dy日 (day)✅
mo月 (month)✅
yr年 (year)✅
ds季节 (day of season)❌ 不在 orient 中

验证: orient == dw + dy + mo + yr 应 100% 吻合。

常见缺失率(Wave1 参考)

变量缺失数缺失率影响
age1400.8%低
ragender2<0.1%低
imrc3,50519.8%高
dlrc3,62620.5%高
ser73,42519.3%高 — 认知筛选的主要杀手
orient2,57114.5%中
draw1,88010.6%中
cesd101,6719.4%中
bmi4,07723.0%高
socwk1,4848.4%中

关键: imrc、dlrc、ser7 的缺失率都在 ~20%。 如果论文要求所有认知变量同时不缺失,实际排除量会远超直觉。 有些论文可能只用了 EM(不含 MS)或只用了部分 MS 子项来降低缺失。

样本筛选经验

标准流程

python
w1 = df[df['wave'] == 'wave1'].copy()

# Step 1: 年龄筛选
step1 = w1[w1['age'] >= 50]

# Step 2: 认知完整 — 分开检查,找出缺失的主要来源
for v in ['imrc', 'dlrc', 'ser7', 'orient', 'draw']:
    na_count = step1[v].isna().sum()
    print(f"  {v} 缺失: {na_count} ({na_count/len(step1)*100:.1f}%)")

# 先排核心因变量缺失(EM),再排 MS
step2a = step1.dropna(subset=['imrc', 'dlrc'])  # EM 核心
step2b = step2a.dropna(subset=['orient', 'draw'])  # MS 基础项
step2c = step2b.dropna(subset=['ser7'])  # 可选: 如果 MS 含 ser7

# Step 3-5: 后续筛选...

样本量调试策略

如果样本量与论文偏差 >10%:

  1. 检查各变量缺失贡献: 哪个变量排除了最多人?
  2. 尝试不同的 MS 定义:
    • ms = ser7 + orient + draw(标准,但 ser7 缺失率高)
    • ms = orient + draw(不含 ser7,缺失率低)
    • 只要求 EM 不缺失,不要求 MS 不缺失
  3. 检查婚姻编码: "已婚但不住在一起"算已婚还是未婚?
  4. 检查 BMI 异常值: 原始 BMI 有 >100 的值,是否被论文保留?

Wave 间数据合并

python
# 提取 Wave1 基线
w1 = df[df['wave'] == 'wave1'].copy()

# 提取 Wave3 结局
w3 = df[df['wave'] == 'wave3'].copy()
w3_outcome = w3[['ID', 'target_var']].rename(columns={'target_var': 'target_var_w3'})

# 合并
merged = w1.merge(w3_outcome, on='ID', how='left')
# 随访缺失 = merge 后 target_var_w3 为 NaN

标准化 OLS 回归模板

python
import statsmodels.formula.api as smf
from sklearn.preprocessing import StandardScaler

# 标准化所有变量(因变量 + 自变量 → 得到标准化 beta)
all_vars = [dv] + ivs
df_std = df[all_vars].copy()
for col in df_std.columns:
    df_std[col] = (df_std[col] - df_std[col].mean()) / df_std[col].std()

# 交互项在标准化后构建
df_std['interaction'] = df_std['var1'] * df_std['var2']

# OLS + HC3
formula = f'{dv} ~ ' + ' + '.join(ivs)
model = smf.ols(formula, data=df_std).fit(cov_type='HC3')

环境注意事项

  • 数据文件可能在 Docker 容器内,注意路径映射
  • Stata .dta 读取: pd.read_stata(),category 变量会自动转为中文标签
  • 大文件(>50MB)读取较慢,首次加载后考虑缓存为 parquet

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Charls Reproduce AI skill do?

CHARLS (China Health and Retirement Longitudinal Study) database-specific knowledge for reproducing published papers. Use when reproducing or analyzing papers that use CHARLS data, including variable mapping from harmonized to raw questionnaire items, cognitive function scoring (episodic memory, mental status, TICS), CESD-10 depression screening, social isolation index construction, and chronic disease coding. Also use for any CHARLS data cleaning, variable construction, or cohort selection task.

Why use Charls Reproduce on TypingMind?

Because you install it once and use it with any model. Charls Reproduce is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Charls Reproduce in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/xjtulyc/MedgeClaw/tree/main/skills/charls-reproduce. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Charls Reproduce?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Charls Reproduce?

As many as you like. As long as a model supports skills, you can use Charls Reproduce with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Charls Reproduce AI skill free?

It is published on GitHub by xjtulyc. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇