Replicate Study Skill
You are assisting a medical researcher in replicating an existing published study's methodology
on a different database. This is a common research strategy: take a validated methodology from
Paper A (e.g., NHIS cohort study) and apply it to Database B (e.g., KNHANES, NHANES, or another
cohort) to produce a new paper with the same analytical rigor.
When to Use
- Researcher has a published paper they want to replicate on their own data
- Swapping exposure/outcome variables within the same DB
- Cross-national replication (e.g., Korean study → US data, or vice versa)
- Extending a single-institution study to a national cohort
Inputs
- Source paper: PDF, DOI, or markdown of the paper to replicate
- Target database path: CSV/SAS data file(s) to use
- Harmonization table (optional): CSV mapping source → target variables
- Default:
${SKILL_DIR}/references/harmonization_knhanes_nhanes.csv (if KNHANES↔NHANES)
Reference Files
${SKILL_DIR}/references/methodology_extraction_template.md — checklist for extracting study design
${SKILL_DIR}/references/harmonization_knhanes_nhanes.csv — KNHANES↔NHANES variable mapping (67 rows)
${SKILL_DIR}/references/harmonization_3country.csv — KNHANES+NHANES+CHNS 3-country mapping (45 rows, if available)
- Upstream templates (read on demand):
medsci-skills/skills/write-paper/references/paper_types/nhis_cohort.md
medsci-skills/skills/write-paper/references/paper_types/cross_national.md
medsci-skills/skills/analyze-stats/references/analysis_guides/survey_weighted.md
medsci-skills/skills/analyze-stats/references/analysis_guides/propensity_score.md
Workflow
Phase 1: Source Paper Analysis
- Read the source paper (PDF → text, or markdown).
- Extract methodology using the extraction template:
- Study design: cohort / cross-sectional / case-control
- Database: name, country, years, N
- Population: inclusion/exclusion criteria, age range
- Exposure: variable name, definition, coding
- Outcome: variable name, definition, coding
- Covariates: full list with definitions
- Statistical methods: regression type, adjustment model, subgroup analyses
- Survey design: weights, strata, PSU (if applicable)
- Sensitivity analyses: list all
- Output: structured extraction summary for user review.
Phase 2: Variable Mapping
- Load the harmonization table (CSV with columns: domain, concept, source_var, target_var, notes).
- For each extracted variable (exposure, outcome, covariates):
- Find the matching row in the harmonization table
- Flag: DIRECT_MATCH / RECODE_NEEDED / NOT_AVAILABLE / PROXY_AVAILABLE
- Generate a mapping report:
- Green: directly available (no recoding)
- Yellow: available but needs recoding (document transformation)
- Red: not available in target DB (propose proxy or exclusion)
- Output: variable mapping table for user approval.
Phase 3: Code Generation
- Generate analysis code (Python with
pandas + R via subprocess for survey-weighted):
a. Data loading & cleaning: read target DB, apply inclusion/exclusion
b. Variable derivation: recode variables per mapping table
c. Survey design setup: define svydesign object (strata, PSU, weights)
d. Table 1: demographics by exposure group (weighted)
e. Main analysis: replicate the primary model (logistic/Cox/linear regression)
f. Subgroup analyses: if specified in source paper
g. Sensitivity analyses: replicate all listed in source paper
- Use
/analyze-stats templates where available (survey_weighted, propensity_score).
- All code must be self-contained and reproducible.
Phase 4: Difference Report
Generate a structured difference report documenting:
| Section |
Content |
| Study Design |
Same / Modified (explain) |
| Database |
Source DB → Target DB (N, years, country) |
| Population |
Inclusion/exclusion differences |
| Variable Mapping |
Full mapping table with match status |
| Unavailable Variables |
What's missing and how handled |
| Methodological Differences |
Any forced changes (e.g., BMI cutoffs, LDL calculation) |
| Expected Differences |
Why results may differ (population, measurement, cultural) |
Save as replication_report.md in the working directory.
Phase 5: Validation Checklist
Before reporting completion, verify:
Critical Rules
- Never pool data across surveys. Analyze each country's data with its own survey design.
- Document every deviation from the source methodology in the difference report.
- Asian BMI cutoffs (≥25 for obesity) when analyzing Korean data, even if source used WHO (≥30).
- LDL calculation: note if source used direct measurement vs Friedewald.
- Weighted analysis is mandatory for KNHANES/NHANES — never run unweighted models.
- IRB: note that KNHANES/NHANES are de-identified public data (IRB exempt or waived).
- Outdated source definitions: if the source paper used a pre-2023 definition that has since been superseded (e.g., NAFLD → MASLD 2023, CKD-EPI 2009 → 2021 race-free), call
/define-variables to cross-check whether to mirror the legacy definition (pure replication) or upgrade to current (extension). Document the choice explicitly in the difference report.
Output Files
{working_dir}/
├── replication_report.md — Structured difference report
├── variable_mapping.csv — Variable mapping table with match status
├── analysis_code.py — Main analysis script (Python + R calls)
├── analysis_code.R — R script for survey-weighted analysis
└── results/
├── table1.csv — Demographics table
├── main_results.csv — Primary analysis results
└── subgroup_results.csv — Subgroup analysis results (if applicable)
Example Invocation
/replicate-study
Source paper: Joo 2026 (Psychiatry Research) — depression/diabetes cross-national
Target DB: /path/to/knhanes/HN18.csv
Harmonization: /path/to/harmonization_knhanes_nhanes.csv
Anti-Hallucination
- Never fabricate variable names, dataset column names, or variable codings. If a variable mapping is uncertain, output
[VERIFY: variable_name] and ask the user to confirm against the data dictionary.
- Never fabricate statistical results — no invented p-values, effect sizes, confidence intervals, or sample sizes. All numbers must come from executed code output.
- Never generate references from memory. Use
/search-lit for all citations.
- If a function, package, or API does not exist or you are unsure, say so explicitly rather than guessing.
1---2name: replicate-study3description: Replicate an existing cohort study's methodology on a different database. Extracts study design from a source paper, maps variables to the target DB via harmonization table, generates analysis code, and produces a replication difference report.4triggers: replicate study, replicate paper, 논문 복제, 방법론 복제, reproduce study, replication, 다른 DB로, swap database, 데이터 교체5tools: Read, Write, Edit, Bash, Grep, Glob6model: opus7metadata:8 source: https://skillmd.com/skills/aperivue/replicate-study9---1011# Replicate Study Skill1213You are assisting a medical researcher in replicating an existing published study's methodology14on a different database. This is a common research strategy: take a validated methodology from15Paper A (e.g., NHIS cohort study) and apply it to Database B (e.g., KNHANES, NHANES, or another16cohort) to produce a new paper with the same analytical rigor.1718## When to Use1920- Researcher has a published paper they want to replicate on their own data21- Swapping exposure/outcome variables within the same DB22- Cross-national replication (e.g., Korean study → US data, or vice versa)23- Extending a single-institution study to a national cohort2425## Inputs26271. **Source paper**: PDF, DOI, or markdown of the paper to replicate282. **Target database path**: CSV/SAS data file(s) to use293. **Harmonization table** (optional): CSV mapping source → target variables30 - Default: `${SKILL_DIR}/references/harmonization_knhanes_nhanes.csv` (if KNHANES↔NHANES)3132## Reference Files3334- `${SKILL_DIR}/references/methodology_extraction_template.md` — checklist for extracting study design35- `${SKILL_DIR}/references/harmonization_knhanes_nhanes.csv` — KNHANES↔NHANES variable mapping (67 rows)36- `${SKILL_DIR}/references/harmonization_3country.csv` — KNHANES+NHANES+CHNS 3-country mapping (45 rows, if available)37- Upstream templates (read on demand):38 - `medsci-skills/skills/write-paper/references/paper_types/nhis_cohort.md`39 - `medsci-skills/skills/write-paper/references/paper_types/cross_national.md`40 - `medsci-skills/skills/analyze-stats/references/analysis_guides/survey_weighted.md`41 - `medsci-skills/skills/analyze-stats/references/analysis_guides/propensity_score.md`4243## Workflow4445### Phase 1: Source Paper Analysis46471. Read the source paper (PDF → text, or markdown).482. Extract methodology using the extraction template:49 - **Study design**: cohort / cross-sectional / case-control50 - **Database**: name, country, years, N51 - **Population**: inclusion/exclusion criteria, age range52 - **Exposure**: variable name, definition, coding53 - **Outcome**: variable name, definition, coding54 - **Covariates**: full list with definitions55 - **Statistical methods**: regression type, adjustment model, subgroup analyses56 - **Survey design**: weights, strata, PSU (if applicable)57 - **Sensitivity analyses**: list all583. Output: structured extraction summary for user review.5960### Phase 2: Variable Mapping61621. Load the harmonization table (CSV with columns: domain, concept, source_var, target_var, notes).632. For each extracted variable (exposure, outcome, covariates):64 - Find the matching row in the harmonization table65 - Flag: DIRECT_MATCH / RECODE_NEEDED / NOT_AVAILABLE / PROXY_AVAILABLE663. Generate a **mapping report**:67 - Green: directly available (no recoding)68 - Yellow: available but needs recoding (document transformation)69 - Red: not available in target DB (propose proxy or exclusion)704. Output: variable mapping table for user approval.7172### Phase 3: Code Generation73741. Generate analysis code (Python with `pandas` + R via `subprocess` for survey-weighted):75 a. **Data loading & cleaning**: read target DB, apply inclusion/exclusion76 b. **Variable derivation**: recode variables per mapping table77 c. **Survey design setup**: define svydesign object (strata, PSU, weights)78 d. **Table 1**: demographics by exposure group (weighted)79 e. **Main analysis**: replicate the primary model (logistic/Cox/linear regression)80 f. **Subgroup analyses**: if specified in source paper81 g. **Sensitivity analyses**: replicate all listed in source paper822. Use `/analyze-stats` templates where available (survey_weighted, propensity_score).833. All code must be self-contained and reproducible.8485### Phase 4: Difference Report8687Generate a structured difference report documenting:8889| Section | Content |90|---------|---------|91| Study Design | Same / Modified (explain) |92| Database | Source DB → Target DB (N, years, country) |93| Population | Inclusion/exclusion differences |94| Variable Mapping | Full mapping table with match status |95| Unavailable Variables | What's missing and how handled |96| Methodological Differences | Any forced changes (e.g., BMI cutoffs, LDL calculation) |97| Expected Differences | Why results may differ (population, measurement, cultural) |9899Save as `replication_report.md` in the working directory.100101### Phase 5: Validation Checklist102103Before reporting completion, verify:104105- [ ] All source paper covariates accounted for (mapped, proxied, or documented as missing)106- [ ] Survey weights correctly applied (NEVER analyze unweighted if source used weights)107- [ ] Obesity/BMI cutoffs match target population standards (Asian vs WHO)108- [ ] Fasting requirements matched (fasting glucose, lipids)109- [ ] Age restrictions applied correctly110- [ ] Code runs without errors on target data111- [ ] Output tables match source paper structure112113## Critical Rules1141151. **Never pool data across surveys**. Analyze each country's data with its own survey design.1162. **Document every deviation** from the source methodology in the difference report.1173. **Asian BMI cutoffs** (≥25 for obesity) when analyzing Korean data, even if source used WHO (≥30).1184. **LDL calculation**: note if source used direct measurement vs Friedewald.1195. **Weighted analysis is mandatory** for KNHANES/NHANES — never run unweighted models.1206. **IRB**: note that KNHANES/NHANES are de-identified public data (IRB exempt or waived).1217. **Outdated source definitions**: if the source paper used a pre-2023 definition that has since been superseded (e.g., NAFLD → MASLD 2023, CKD-EPI 2009 → 2021 race-free), call `/define-variables` to cross-check whether to mirror the legacy definition (pure replication) or upgrade to current (extension). Document the choice explicitly in the difference report.122123## Output Files124125```126{working_dir}/127├── replication_report.md — Structured difference report128├── variable_mapping.csv — Variable mapping table with match status129├── analysis_code.py — Main analysis script (Python + R calls)130├── analysis_code.R — R script for survey-weighted analysis131└── results/132 ├── table1.csv — Demographics table133 ├── main_results.csv — Primary analysis results134 └── subgroup_results.csv — Subgroup analysis results (if applicable)135```136137## Example Invocation138139```140/replicate-study141142Source paper: Joo 2026 (Psychiatry Research) — depression/diabetes cross-national143Target DB: /path/to/knhanes/HN18.csv144Harmonization: /path/to/harmonization_knhanes_nhanes.csv145```146147## Anti-Hallucination148149- **Never fabricate variable names, dataset column names, or variable codings.** If a variable mapping is uncertain, output `[VERIFY: variable_name]` and ask the user to confirm against the data dictionary.150- **Never fabricate statistical results** — no invented p-values, effect sizes, confidence intervals, or sample sizes. All numbers must come from executed code output.151- **Never generate references from memory.** Use `/search-lit` for all citations.152- If a function, package, or API does not exist or you are unsure, say so explicitly rather than guessing.