agentsclimarketplace

Psy ana coder

Skill soupandpsy/amazing-psycoder-skills/amazing-psycoder/psy-ana-coder

AI skills for psychology experiment programming and data analysis, from task design and code generation to reproducible statistical workflows.

Install
npx -y skills add soupandpsy/amazing-psycoder-skills --skill psy-ana-coder

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

What its author says it does

Copied from the file, not written here

Use for generating data analysis scripts (R or Python) from a completed analysis config YAML. Reads the analysis config and generates reproducible scripts with inline documentation, statistical modeling, assumption checks, sensitivity analysis, publication-quality figures, and reports. Does NOT design analyses — that is psy-ana-designer's job. Trigger for 生成分析代码、analysis script、R分析、Python分析 / 分析コード生成、R分析コード / Analyse-Code generieren, R-Analyse, Python-Analyse / generer code analyse, analyse R, analyse Python.

SKILL.md

11.2 KB, as published. Nobody here has run it

Analysis Coder

Version

v1.3 — stable, 2026-06-10. Sub-skill of amazing-psycoder.

Purpose

Receives the analysis config YAML produced by psy-ana-designer, and generates either R or Python analysis scripts according to the user's language preference. R and Python share the same analysis logic — config field mapping, model selection, figure types, and report structure are fully identical; the only differences lie in the specific API calls.

Does not design analyses — only implements a confirmed analysis plan.

Platform Routing

Analysis config YAML
       │
       ├── User language = R      → r/     (tidyverse, lme4, ggplot2, RMarkdown)
       └── User language = Python → python/ (pandas, statsmodels, seaborn, Jupyter)

Each platform includes 4 components: spec/ (API specification + anti-patterns), mapping/ (config-to-code mappings), checklist/ (audit checklist items), demo/ (complete example).

Phase 0: Config Ingestion & Validation

Goal: Receive and validate the analysis config YAML, and confirm the language preference.

0.1 Receive Config

"Please provide the analysis config YAML generated by psy-ana-designer. You may paste its content, or provide a file path (e.g., analysis_config.yaml)."

Validate immediately after reading the config:

  • version field exists and is compatible (currently supports v1.0)
  • Required fields: design.design_type, design.dvs, model.seed
  • At least one questions[] entry
  • Field types are correct (rt_lower is numeric, correction is an allowed value, etc.)

Validation failure → list missing/incorrect fields, ask the user to correct and re-submit. Do not proceed.

0.2 Language Confirmation

"Should the analysis script use R or Python?"

Route to the corresponding platform (r/ or python/) based on the answer. If the user has no preference, default to R (more mature ecosystem).

0.3 Generate Preview

Display the generation plan:

  • Platform: R / Python
  • Model: {model types extracted from config}
  • Figures: {figure list extracted from config}
  • Output files: analysis.R/py + report.Rmd/ipynb

"Confirm the plan above is correct? Then code generation will begin."

After user confirmation, proceed to generation.

Red Lines

#Rule
1Seed not set → do not deliver
2Exclusion log missing → do not deliver
3Assumption test code missing → do not deliver
4Effect size code missing → do not deliver
5Multiple comparison scheme not reflected → do not deliver
6Environment info (sessionInfo/sys.version) not output → do not deliver
7Never generate code with hardcoded paths
8Comment language MUST match user language → do not deliver

Shared Analysis Logic

The logic below applies to both R and Python equally. For platform-specific API mappings, see each platform's mapping/ file.

Comment Language Specification (Highest Priority)

All generated code comments must use the user's language. Chinese user → Chinese comments, English user → English comments. Comments should explain "why this is done" rather than merely "what is done."

Each step's comments should include:

  • The purpose of this step (why this step is necessary)
  • The meaning of key parameters (e.g., "RT lower bound of 150 ms; values below this are treated as anticipatory responses")
  • The rationale for the chosen statistical method (e.g., "Using lmer instead of paired t-test because it can leverage all trial-level data")
  • Result interpretation hints (e.g., "p > 0.05 indicates failure to reject the normality assumption")

The comment style follows "pedagogical comments" — enabling a colleague unfamiliar with this analysis method to understand what every step does and why it is done.

12-Step Script Structure

1. Title comment    Experiment name, model, date, seed
2. Environment setup    Package loading, seed, global options
3. Data import    Read + column name validation (missing column → error)
4. Data cleaning   RT filtering → correct trials → participant exclusion → SD exclusion → missing data handling
5. Exclusion log    Print exclusion counts and proportions at each step
6. Descriptive stats    n, mean, sd, se, ci95, median, mad, grouped by condition
7. Assumption tests    Shapiro-Wilk + QQ plot + Levene/Mauchly (as needed)
8. Statistical modeling    t-test / ANOVA / lmer / glmer / Bayes (per config selection)
9. Effect size      Cohen's d / η²p / R² / OR
10. Post-hoc comparisons   Estimated marginal means + multiple comparison correction
11. Figure generation   Raincloud / individual lines / boxplot / interaction plot → save to disk
12. Environment info    Version + package versions

(This is Phase 1 — the generation phase executed after Phase 0 validation passes.)

Priority: questions[].user_choice > decision tree default. If the designer explicitly chose a method (user_choice = method_a or method_b), use that method directly without running the decision tree below. Only use the decision tree when user_choice is unset or empty.

Model Selection Decision Tree

What is design.dvs[].type?
  ├── continuous (RT/score)
  │     ├── design.design_type = within
  │     │     ├── specified in questions → use the specified model
  │     │     └── not specified → default lmer / MixedLM
  │     └── design.design_type = between
  │           └── default Welch t-test / oneway.test
  │
  └── binary (accuracy)
        ├── any condition accuracy > 90% or < 10%
        │     └── force glmer(binomial) / Logit — ANOVA disallowed
        └── accuracy between 10-90%
              └── recommend glmer/Logit, ANOVA acceptable (note limitation)

Formula validation: Before using model_formula, verify:

  • Within-subjects design → formula must include (1+condition|subject) or a similar random-effects term
  • Binary DV → must use glmer/binomial, may not use lmer
  • Variable names in the formula must exist in the data columns Validation failure → use the decision tree default model, output warning with explanation.

Data Aggregation Rules

AnalysisAggregation Level
Paired t-testSubject × Condition means
lmer / MixedLMTrial level (no aggregation)
Descriptive statisticsCondition
Participant exclusionSubject

Defaults for Missing Fields

Missing FieldDefault Behavior
cleaning.rt_lower150
cleaning.rt_upper3000
cleaning.accuracy_min0.6
cleaning.trial_exclusion2.5
cleaning.missing_policylistwise
model.contrasttreatment
model.correctionbonferroni
output.report_formatRMarkdown (R) / Jupyter (Python)
output.figuresraincloud + individual
output.effect_sizesauto-select based on model type
When using defaults, output warning: ⚠️ config did not specify {field}, using default {default}

Figure Mapping

See psy-ana-designer's plots/ directory (48 detailed figure specifications) and the R ↔ Python mapping table in this document.

Figure TypeWhen to UseElements
RaincloudWithin-subjects two-groupViolin + boxplot + individual scatter
Individual linesWithin-subjectsOne line per person + red mean
Boxplot + scatterMulti-groupBoxplot + jitter
Interaction plotMulti-factorGrouped lines + error bars
QQ plotNormality testTheoretical quantiles vs actual

Effect Size Quick Reference

MethodMetricInterpretation
t-testCohen's d + 95%CI0.2 small, 0.5 medium, 0.8 large
ANOVAη²p0.01 small, 0.06 medium, 0.14 large
Mixed modelMarginal + Conditional R²Fixed + overall
Logistic modelOdds Ratio + 95%CIOR>1 odds increase

Multiple Comparison Schemes

MethodCharacteristics
BonferroniMost conservative, p × number of comparisons
FDR (BH)Controls false discovery rate, exploratory
Tukey HSDAll pairwise comparisons
UncorrectedOnly for pre-registered single hypothesis

Sensitivity Analysis

For each scientific question, compare method A vs B for conclusion consistency. Flag when results are inconsistent and require further investigation.

Report Template

Generate reproducible report: R → RMarkdown/Quarto, Python → Jupyter Notebook. Includes: title, exclusion summary, descriptive statistics, model results, figures, environment info.


R ↔ Python Mapping

OperationRPython
Data importreadr::read_csv()pandas.read_csv()
Filterfilter(col > x)df[df['col'] > x]
Group summarygroup_by() %>% summarise()df.groupby().agg()
Pipe%>%Chained calls
Paired t-testt.test(y~x, paired=TRUE)scipy.stats.ttest_rel(a,b)
Independent t-testt.test(y~x, var.equal=FALSE)scipy.stats.ttest_ind(a,b)
Within-subjects ANOVAafex::aov_ez()pingouin.rm_anova()
Between-subjects ANOVAoneway.test(y~x)scipy.stats.f_oneway()
Mixed modellme4::lmer()statsmodels.MixedLM()
Logistic mixedlme4::glmer(binomial)statsmodels.Logit() + RE
Normalityshapiro.test()scipy.stats.shapiro()
Homogeneity of varianceleveneTest()scipy.stats.levene()
Cohen's deffectsize::cohens_d()pingouin.compute_effsize()
η²effectsize::eta_squared()pingouin.anova(detailed=True)
R² (mixed)performance::r2()Manual calculation
Estimated marginal meansemmeans::emmeans()statsmodels pairwise
Post-hoc comparisonspairs(emm, adjust=)multipletests(pvals, method=)
Raincloud plotggrain::geom_rain()ptitprince.RainCloud()
Save figureggsave()plt.savefig()
Seedset.seed()np.random.seed()
Environment infosessionInfo()sys.version + pip freeze

Routing

Analysis config YAML (input)
       │
       ├── Target=R      → r/spec/ + r/mapping/
       │                  → Generate: analysis.R + report.Rmd → save to output.save_path/
       └── Target=Python → python/spec/ + python/mapping/
                          → Generate: analysis.py + report.ipynb → save to output.save_path/
       │
       ▼
psy-ana-reviewer (audit)

After generation: Code has been saved to {output.save_path}/.

"Code generation complete. Next step: input /psy-ana-reviewer and provide the generated script path for audit."

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.