@brainpilot/skills 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (229) hide show
  1. package/dist/index.d.ts +6 -0
  2. package/dist/index.d.ts.map +1 -0
  3. package/dist/index.js +28 -0
  4. package/dist/index.js.map +1 -0
  5. package/package.json +35 -0
  6. package/skills/01_Meta-Skills/contribute-skill/SKILL.md +277 -0
  7. package/skills/01_Meta-Skills/contribute-skills-via-pr/SKILL.md +163 -0
  8. package/skills/01_Meta-Skills/paper-to-skill/SKILL.md +435 -0
  9. package/skills/01_Meta-Skills/paper-to-skill/references/extraction-guide.md +286 -0
  10. package/skills/01_Meta-Skills/paper-to-skill/references/skill-template.md +250 -0
  11. package/skills/01_Meta-Skills/repo-to-skill/SKILL.md +289 -0
  12. package/skills/01_Meta-Skills/share-case/SKILL.md +253 -0
  13. package/skills/01_Meta-Skills/share-usage/README.md +63 -0
  14. package/skills/01_Meta-Skills/share-usage/SKILL.md +395 -0
  15. package/skills/01_Meta-Skills/verify-skill/SKILL.md +331 -0
  16. package/skills/02_Cross-Domain_Foundation/cogsci-power-analysis/SKILL.md +194 -0
  17. package/skills/02_Cross-Domain_Foundation/cogsci-power-analysis/references/effect-sizes.md +352 -0
  18. package/skills/02_Cross-Domain_Foundation/cogsci-power-analysis/references/sample-size-guide.md +407 -0
  19. package/skills/02_Cross-Domain_Foundation/cogsci-statistics/SKILL.md +361 -0
  20. package/skills/02_Cross-Domain_Foundation/cogsci-statistics/references/common-analyses.md +517 -0
  21. package/skills/02_Cross-Domain_Foundation/cogsci-visualization/SKILL.md +292 -0
  22. package/skills/02_Cross-Domain_Foundation/cogsci-visualization/references/plot-recipes.md +709 -0
  23. package/skills/02_Cross-Domain_Foundation/research-literacy/SKILL.md +286 -0
  24. package/skills/02_Cross-Domain_Foundation/research-literacy/references/common-assumptions.md +320 -0
  25. package/skills/02_Cross-Domain_Foundation/research-literacy/references/planning-template.md +143 -0
  26. package/skills/03_Cognitive_Psychology/alternative-uses-task-designer/SKILL.md +197 -0
  27. package/skills/03_Cognitive_Psychology/alternative-uses-task-designer/references/instruction-templates.md +60 -0
  28. package/skills/03_Cognitive_Psychology/cognitive-paradigm-design/SKILL.md +246 -0
  29. package/skills/03_Cognitive_Psychology/cognitive-paradigm-design/references/classic-paradigms.md +435 -0
  30. package/skills/03_Cognitive_Psychology/cognitive-paradigm-design/references/design-principles.md +256 -0
  31. package/skills/03_Cognitive_Psychology/creativity-self-efficacy-mediation/SKILL.md +270 -0
  32. package/skills/03_Cognitive_Psychology/creativity-self-efficacy-mediation/references/lavaan-templates.md +172 -0
  33. package/skills/03_Cognitive_Psychology/divergent-thinking-scoring/SKILL.md +238 -0
  34. package/skills/03_Cognitive_Psychology/divergent-thinking-scoring/references/scoring-rubric.md +143 -0
  35. package/skills/03_Cognitive_Psychology/drift-diffusion-model/SKILL.md +203 -0
  36. package/skills/03_Cognitive_Psychology/drift-diffusion-model/references/fitting-guide.md +571 -0
  37. package/skills/03_Cognitive_Psychology/drift-diffusion-model/references/model-variants.md +427 -0
  38. package/skills/03_Cognitive_Psychology/evidence-accumulation-selector/SKILL.md +310 -0
  39. package/skills/03_Cognitive_Psychology/evidence-accumulation-selector/references/ez-diffusion-formulas.md +137 -0
  40. package/skills/03_Cognitive_Psychology/signal-detection-analysis/SKILL.md +300 -0
  41. package/skills/03_Cognitive_Psychology/signal-detection-analysis/references/application-guide.md +278 -0
  42. package/skills/03_Cognitive_Psychology/signal-detection-analysis/references/sdt-formulas.md +318 -0
  43. package/skills/03_Cognitive_Psychology/visual-search-array-generator/SKILL.md +283 -0
  44. package/skills/03_Cognitive_Psychology/visual-search-array-generator/references/array-generation-parameters.yaml +111 -0
  45. package/skills/04_Psycholinguistics/reading-time-analysis/SKILL.md +301 -0
  46. package/skills/04_Psycholinguistics/reading-time-analysis/references/measure-computation-guide.md +195 -0
  47. package/skills/04_Psycholinguistics/self-paced-reading-designer/SKILL.md +257 -0
  48. package/skills/04_Psycholinguistics/self-paced-reading-designer/references/analysis-guide.md +356 -0
  49. package/skills/04_Psycholinguistics/self-paced-reading-designer/references/region-segmentation.md +266 -0
  50. package/skills/04_Psycholinguistics/sentence-stimulus-norming/SKILL.md +346 -0
  51. package/skills/04_Psycholinguistics/sentence-stimulus-norming/references/lexical-databases-guide.md +184 -0
  52. package/skills/05_EEG_ERP/eeg-paradigm-designer/SKILL.md +226 -0
  53. package/skills/05_EEG_ERP/eeg-paradigm-designer/references/component-paradigm-map.md +276 -0
  54. package/skills/05_EEG_ERP/eeg-paradigm-designer/references/timing-parameters.md +244 -0
  55. package/skills/05_EEG_ERP/eeg-preprocessing-pipeline-guide/SKILL.md +367 -0
  56. package/skills/05_EEG_ERP/eeg-preprocessing-pipeline-guide/references/parameter-lookup-tables.md +138 -0
  57. package/skills/05_EEG_ERP/erp-analysis/SKILL.md +185 -0
  58. package/skills/05_EEG_ERP/erp-analysis/references/erp-components.md +447 -0
  59. package/skills/05_EEG_ERP/erp-analysis/references/preprocessing-pipeline.md +277 -0
  60. package/skills/05_EEG_ERP/erp-analysis/references/statistical-approaches.md +351 -0
  61. package/skills/05_EEG_ERP/mne-python-guide/SKILL.md +174 -0
  62. package/skills/05_EEG_ERP/mne-python-guide/references/decoding.md +178 -0
  63. package/skills/05_EEG_ERP/mne-python-guide/references/io_formats.md +160 -0
  64. package/skills/05_EEG_ERP/mne-python-guide/references/preprocessing.md +259 -0
  65. package/skills/05_EEG_ERP/mne-python-guide/references/simulation.md +173 -0
  66. package/skills/05_EEG_ERP/mne-python-guide/references/source_localization.md +234 -0
  67. package/skills/05_EEG_ERP/mne-python-guide/references/statistics.md +196 -0
  68. package/skills/05_EEG_ERP/mne-python-guide/references/time_frequency.md +165 -0
  69. package/skills/05_EEG_ERP/mne-python-guide/references/visualization.md +175 -0
  70. package/skills/06_fMRI_Neuroimaging/brain-connectivity-modeler/SKILL.md +317 -0
  71. package/skills/06_fMRI_Neuroimaging/brain-connectivity-modeler/references/method-implementation-guide.md +116 -0
  72. package/skills/06_fMRI_Neuroimaging/fmri-glm-analysis-guide/SKILL.md +296 -0
  73. package/skills/06_fMRI_Neuroimaging/fmri-glm-analysis-guide/references/design-matrix-guide.md +214 -0
  74. package/skills/06_fMRI_Neuroimaging/fmri-glm-analysis-guide/references/statistical-inference.md +288 -0
  75. package/skills/06_fMRI_Neuroimaging/fmri-preprocessing-pipeline-guide/SKILL.md +274 -0
  76. package/skills/06_fMRI_Neuroimaging/fmri-preprocessing-pipeline-guide/references/quality-control.md +336 -0
  77. package/skills/06_fMRI_Neuroimaging/fmri-preprocessing-pipeline-guide/references/step-by-step-pipeline.md +380 -0
  78. package/skills/06_fMRI_Neuroimaging/fmri-task-design-guide/SKILL.md +264 -0
  79. package/skills/06_fMRI_Neuroimaging/fmri-task-design-guide/references/design-optimization-examples.md +114 -0
  80. package/skills/06_fMRI_Neuroimaging/neural-decoding-analysis/SKILL.md +273 -0
  81. package/skills/06_fMRI_Neuroimaging/neural-decoding-analysis/references/decoding-methods.md +170 -0
  82. package/skills/06_fMRI_Neuroimaging/neural-decoding-analysis/references/rsa-guide.md +266 -0
  83. package/skills/06_fMRI_Neuroimaging/pycortex-guide/SKILL.md +123 -0
  84. package/skills/06_fMRI_Neuroimaging/pycortex-guide/references/database-subjects.md +179 -0
  85. package/skills/06_fMRI_Neuroimaging/pycortex-guide/references/dataset-types.md +208 -0
  86. package/skills/06_fMRI_Neuroimaging/pycortex-guide/references/freesurfer-fmriprep.md +162 -0
  87. package/skills/06_fMRI_Neuroimaging/pycortex-guide/references/mapping-transforms.md +181 -0
  88. package/skills/06_fMRI_Neuroimaging/pycortex-guide/references/mni-utils.md +207 -0
  89. package/skills/06_fMRI_Neuroimaging/pycortex-guide/references/surface-analysis.md +219 -0
  90. package/skills/06_fMRI_Neuroimaging/pycortex-guide/references/visualization.md +251 -0
  91. package/skills/07_Computational_Modeling/act-r-model-builder/SKILL.md +297 -0
  92. package/skills/07_Computational_Modeling/act-r-model-builder/references/model-patterns.md +197 -0
  93. package/skills/07_Computational_Modeling/act-r-model-builder/references/parameter-table.yaml +204 -0
  94. package/skills/07_Computational_Modeling/bayesian-cognitive-model-builder/SKILL.md +294 -0
  95. package/skills/07_Computational_Modeling/bayesian-cognitive-model-builder/references/diagnostics-checklist.md +351 -0
  96. package/skills/07_Computational_Modeling/bayesian-cognitive-model-builder/references/prior-selection-guide.md +241 -0
  97. package/skills/07_Computational_Modeling/parameter-recovery-checker/SKILL.md +269 -0
  98. package/skills/07_Computational_Modeling/parameter-recovery-checker/references/recovery-diagnostics.md +207 -0
  99. package/skills/08_Computational_Neuroscience/brain-connectivity-modeler/SKILL.md +317 -0
  100. package/skills/08_Computational_Neuroscience/brain-connectivity-modeler/references/method-implementation-guide.md +116 -0
  101. package/skills/08_Computational_Neuroscience/neural-decoding-analysis/SKILL.md +273 -0
  102. package/skills/08_Computational_Neuroscience/neural-decoding-analysis/references/decoding-methods.md +170 -0
  103. package/skills/08_Computational_Neuroscience/neural-decoding-analysis/references/rsa-guide.md +266 -0
  104. package/skills/08_Computational_Neuroscience/neural-population-analysis-guide/SKILL.md +305 -0
  105. package/skills/08_Computational_Neuroscience/neural-population-analysis-guide/references/data-requirements.md +60 -0
  106. package/skills/08_Computational_Neuroscience/neural-population-analysis-guide/references/method-comparison.md +151 -0
  107. package/skills/08_Computational_Neuroscience/spiking-network-model-builder/SKILL.md +376 -0
  108. package/skills/08_Computational_Neuroscience/spiking-network-model-builder/references/hh-parameters.md +117 -0
  109. package/skills/08_Computational_Neuroscience/spiking-network-model-builder/references/network-regimes.md +130 -0
  110. package/skills/09_Cellular_Molecular_Neuroscience/calcium-imaging-analysis-guide/SKILL.md +258 -0
  111. package/skills/09_Cellular_Molecular_Neuroscience/calcium-imaging-analysis-guide/references/indicator-parameters.md +242 -0
  112. package/skills/09_Cellular_Molecular_Neuroscience/calcium-imaging-analysis-guide/references/pipeline-details.md +211 -0
  113. package/skills/09_Cellular_Molecular_Neuroscience/optogenetics-protocol-designer/SKILL.md +261 -0
  114. package/skills/09_Cellular_Molecular_Neuroscience/optogenetics-protocol-designer/references/opsin-catalog.md +124 -0
  115. package/skills/09_Cellular_Molecular_Neuroscience/optogenetics-protocol-designer/references/stimulation-parameters.md +304 -0
  116. package/skills/10_Clinical_Neuropsychology/lesion-symptom-mapping-guide/SKILL.md +367 -0
  117. package/skills/10_Clinical_Neuropsychology/lesion-symptom-mapping-guide/references/disconnection-guide.md +152 -0
  118. package/skills/10_Clinical_Neuropsychology/lesion-symptom-mapping-guide/references/vlsm-pipeline.md +182 -0
  119. package/skills/10_Clinical_Neuropsychology/neuropsych-battery-selector/SKILL.md +250 -0
  120. package/skills/10_Clinical_Neuropsychology/neuropsych-battery-selector/references/deficit-profiles.md +302 -0
  121. package/skills/10_Clinical_Neuropsychology/neuropsych-battery-selector/references/test-catalog.md +304 -0
  122. package/skills/11_Developmental_Cognition/infant-looking-time-designer/SKILL.md +345 -0
  123. package/skills/11_Developmental_Cognition/infant-looking-time-designer/references/age-parameters.yaml +186 -0
  124. package/skills/12_Social_Cognition/tom-task-selector/SKILL.md +379 -0
  125. package/skills/12_Social_Cognition/tom-task-selector/references/task-database.md +317 -0
  126. package/skills/13_Visualization/nature-figure/README.md +442 -0
  127. package/skills/13_Visualization/nature-figure/SKILL.md +60 -0
  128. package/skills/13_Visualization/nature-figure/assets/chart-atlas/atlas-01-bar-charts.png +0 -0
  129. package/skills/13_Visualization/nature-figure/assets/chart-atlas/atlas-02-line-trends.png +0 -0
  130. package/skills/13_Visualization/nature-figure/assets/chart-atlas/atlas-03-heatmaps.png +0 -0
  131. package/skills/13_Visualization/nature-figure/assets/chart-atlas/atlas-04-scatter-bubble.png +0 -0
  132. package/skills/13_Visualization/nature-figure/assets/chart-atlas/atlas-05-radar-polar.png +0 -0
  133. package/skills/13_Visualization/nature-figure/assets/chart-atlas/atlas-06-distributions.png +0 -0
  134. package/skills/13_Visualization/nature-figure/assets/chart-atlas/atlas-07-forest-interval.png +0 -0
  135. package/skills/13_Visualization/nature-figure/assets/chart-atlas/atlas-08-area-stacked.png +0 -0
  136. package/skills/13_Visualization/nature-figure/assets/chart-atlas/atlas-09-image-plates.png +0 -0
  137. package/skills/13_Visualization/nature-figure/assets/chart-atlas/atlas-10-network-matrix.png +0 -0
  138. package/skills/13_Visualization/nature-figure/assets/figures4papers/assets/Dispersion_motivation.png +0 -0
  139. package/skills/13_Visualization/nature-figure/assets/figures4papers/assets/Dispersion_observation.png +0 -0
  140. package/skills/13_Visualization/nature-figure/assets/figures4papers/assets/Dispersion_observation_distillation.png +0 -0
  141. package/skills/13_Visualization/nature-figure/assets/figures4papers/assets/ImmunoStruct_contrastive.png +0 -0
  142. package/skills/13_Visualization/nature-figure/assets/figures4papers/assets/ImmunoStruct_results_CEDAR.png +0 -0
  143. package/skills/13_Visualization/nature-figure/assets/figures4papers/assets/ImmunoStruct_results_IEDB.png +0 -0
  144. package/skills/13_Visualization/nature-figure/assets/figures4papers/assets/ImmunoStruct_schematic.png +0 -0
  145. package/skills/13_Visualization/nature-figure/assets/figures4papers/assets/RNAGenScape_schematic.png +0 -0
  146. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_CellSpliceNet/figures/ablation.png +0 -0
  147. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_CellSpliceNet/figures/comparison.png +0 -0
  148. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_CellSpliceNet/plot_ablation.py +86 -0
  149. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_CellSpliceNet/plot_comparison.py +109 -0
  150. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Cflows/diffusion_swiss_roll.py +97 -0
  151. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Cflows/figures/diffusion_swiss_roll.png +0 -0
  152. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Cflows/figures/fig2_comparison_GeneRegulatory.pdf +0 -0
  153. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Cflows/figures/fig2_comparison_GeneRegulatory.png +0 -0
  154. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Cflows/figures/fig2_comparison_Trajectory.pdf +0 -0
  155. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Cflows/figures/fig2_comparison_Trajectory.png +0 -0
  156. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Cflows/figures/figX_comparison_Ablation.pdf +0 -0
  157. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Cflows/figures/figX_comparison_Ablation.png +0 -0
  158. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Cflows/plot_comparison_Ablation.py +64 -0
  159. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Cflows/plot_comparison_GeneRegulatory.py +74 -0
  160. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Cflows/plot_comparison_Trajectory.py +74 -0
  161. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Dispersion/figures/idea.png +0 -0
  162. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Dispersion/figures/illustration.png +0 -0
  163. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Dispersion/plot_idea.py +76 -0
  164. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Dispersion/plot_illustration.py +404 -0
  165. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_FPGM/figures/freq_prior.png +0 -0
  166. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_FPGM/plot_freq_prior.py +146 -0
  167. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_ImmunoStruct/figures/bars_ablation_Cancer.png +0 -0
  168. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_ImmunoStruct/figures/bars_ablation_IEDB.png +0 -0
  169. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_ImmunoStruct/figures/bars_comparison_Cancer.png +0 -0
  170. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_ImmunoStruct/figures/bars_comparison_IEDB.png +0 -0
  171. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_ImmunoStruct/plot_bars.py +216 -0
  172. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_ImmunoStruct/raw_data.py +125 -0
  173. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_RNAGenScape/figures/manifold.png +0 -0
  174. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_RNAGenScape/figures/manifold_holes.png +0 -0
  175. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_RNAGenScape/figures/results_comparison_optimization.png +0 -0
  176. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_RNAGenScape/figures/results_comparison_speed.png +0 -0
  177. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_RNAGenScape/figures/results_sweep.png +0 -0
  178. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_RNAGenScape/plot_comparison.py +228 -0
  179. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_RNAGenScape/plot_hole_manifold.py +82 -0
  180. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_RNAGenScape/plot_manifold.py +61 -0
  181. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_RNAGenScape/plot_sweep.py +77 -0
  182. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_VIGIL/figures/comparison_posttraining.png +0 -0
  183. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_VIGIL/figures/comparison_radar.png +0 -0
  184. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_VIGIL/plot_comparison_radar.py +173 -0
  185. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_VIGIL/plot_posttraining.py +82 -0
  186. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_brainteaser/figures/brute_force.png +0 -0
  187. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_brainteaser/figures/correctness_by_category.png +0 -0
  188. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_brainteaser/figures/correctness_by_subcategory.png +0 -0
  189. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_brainteaser/figures/rewriting.png +0 -0
  190. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_brainteaser/figures/selfcorrection_math.png +0 -0
  191. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_brainteaser/plot_brute_force.py +248 -0
  192. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_brainteaser/plot_correctness_by_category.py +132 -0
  193. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_brainteaser/plot_correctness_by_subcategory.py +131 -0
  194. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_brainteaser/plot_rewriting.py +105 -0
  195. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_brainteaser/plot_selfcorrection_math.py +99 -0
  196. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_ophthal_review/figures/composition_heatmap.png +0 -0
  197. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_ophthal_review/figures/trend_by_month.png +0 -0
  198. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_ophthal_review/plot_composition.py +81 -0
  199. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_ophthal_review/plot_trend.py +125 -0
  200. package/skills/13_Visualization/nature-figure/assets/gallery/fig1-material-mechanism-rich.png +0 -0
  201. package/skills/13_Visualization/nature-figure/assets/gallery/fig2-spatial-imaging-rich.png +0 -0
  202. package/skills/13_Visualization/nature-figure/assets/gallery/fig3-in-vivo-efficacy-rich.png +0 -0
  203. package/skills/13_Visualization/nature-figure/assets/gallery/fig4-single-cell-systems-rich.png +0 -0
  204. package/skills/13_Visualization/nature-figure/assets/gallery/fig5-validation-perturbation-rich.png +0 -0
  205. package/skills/13_Visualization/nature-figure/evals/evals.json +37 -0
  206. package/skills/13_Visualization/nature-figure/manifest.yaml +57 -0
  207. package/skills/13_Visualization/nature-figure/references/api.md +428 -0
  208. package/skills/13_Visualization/nature-figure/references/backend-selection.md +100 -0
  209. package/skills/13_Visualization/nature-figure/references/chart-types.md +281 -0
  210. package/skills/13_Visualization/nature-figure/references/common-patterns.md +350 -0
  211. package/skills/13_Visualization/nature-figure/references/demos.md +65 -0
  212. package/skills/13_Visualization/nature-figure/references/design-theory.md +436 -0
  213. package/skills/13_Visualization/nature-figure/references/figure-contract.md +93 -0
  214. package/skills/13_Visualization/nature-figure/references/nature-2026-observations.md +112 -0
  215. package/skills/13_Visualization/nature-figure/references/qa-contract.md +119 -0
  216. package/skills/13_Visualization/nature-figure/references/r-template-index.md +66 -0
  217. package/skills/13_Visualization/nature-figure/references/r-workflow.md +161 -0
  218. package/skills/13_Visualization/nature-figure/references/tutorials.md +251 -0
  219. package/skills/13_Visualization/nature-figure/static/core/contract.md +29 -0
  220. package/skills/13_Visualization/nature-figure/static/core/stance.md +37 -0
  221. package/skills/13_Visualization/nature-figure/static/fragments/backend/python.md +37 -0
  222. package/skills/13_Visualization/nature-figure/static/fragments/backend/r.md +44 -0
  223. package/skills/14_Writing/markdown-report-writing/SKILL.md +306 -0
  224. package/skills/14_Writing/markdown-report-writing/references/compatibility-matrix.md +72 -0
  225. package/skills/14_Writing/markdown-report-writing/references/templates.md +299 -0
  226. package/skills/15_Others/neuroimaging-power-guide/SKILL.md +324 -0
  227. package/skills/15_Others/neuroimaging-power-guide/references/effect-size-lookup-tables.md +102 -0
  228. package/skills/15_Others/neuroimaging-sample-size-calculator/SKILL.md +330 -0
  229. package/skills/15_Others/neuroimaging-sample-size-calculator/references/worked-examples.md +220 -0
@@ -0,0 +1,294 @@
1
+ ---
2
+ name: "bayesian-cognitive-model-builder"
3
+ description: "Domain-validated guidance for building hierarchical Bayesian cognitive models with Stan/PyMC: prior specification, model structure, MCMC diagnostics, and posterior predictive checks"
4
+ domain: "computational-cognitive-modeling"
5
+ version: "1.0.0"
6
+ papers:
7
+ - "Gelman et al., 2013"
8
+ - "Lee & Wagenmakers, 2014"
9
+ - "Kruschke, 2015"
10
+ - "Schad et al., 2021"
11
+ - "Vehtari et al., 2017"
12
+ - "Vehtari et al., 2021"
13
+ dependencies:
14
+ required:
15
+ - research-literacy
16
+ recommended:
17
+ - drift-diffusion-model
18
+ - signal-detection-analysis
19
+ review_status: "ai-generated"
20
+ ---
21
+
22
+ # Bayesian Cognitive Model Builder
23
+
24
+ ## Purpose
25
+
26
+ This skill encodes expert knowledge for building hierarchical Bayesian cognitive models using probabilistic programming languages (Stan, PyMC). It addresses the modeling decisions that require domain expertise beyond knowing Stan/PyMC syntax: how to choose priors that respect cognitive constraints, when to use hierarchical structure, how to diagnose MCMC pathologies, and how to evaluate model adequacy through posterior predictive checks.
27
+
28
+ A competent programmer without cognitive modeling training would get wrong: which prior families are appropriate for cognitive parameters (e.g., RT must be positive, learning rates bounded in [0,1]), when partial pooling outperforms complete pooling or no pooling, how to detect non-identifiability in cognitive models, and what constitutes adequate MCMC convergence for publishable results.
29
+
30
+ ## When to Use This Skill
31
+
32
+ - Building a generative model of a cognitive process (decision-making, learning, memory, perception) where parameters have psychological interpretations
33
+ - Estimating individual differences in cognitive parameters while borrowing strength across participants (hierarchical/multilevel models)
34
+ - Working with small samples or sparse data per participant where regularization through priors prevents overfitting
35
+ - Parameter uncertainty matters for your scientific conclusions (credible intervals, not just point estimates)
36
+ - Comparing competing cognitive models via information criteria (LOO-CV, WAIC) or Bayes factors
37
+ - Fitting established cognitive models (DDM, signal detection, reinforcement learning, multinomial processing trees) in a Bayesian framework
38
+
39
+ ## When NOT to Use This Skill
40
+
41
+ - If your model has a closed-form MLE and you have large, balanced samples, frequentist estimation may be simpler and adequate
42
+ - For purely predictive models where parameter interpretability is irrelevant (consider machine learning approaches)
43
+ - If you need a general-purpose Bayesian regression model without cognitive process parameters (see `cogsci-statistics` skill)
44
+ - For EEG/fMRI analysis pipelines without explicit cognitive models (see `erp-analysis` or `fmri-glm-analysis-guide` skills)
45
+
46
+ ## Research Planning Protocol
47
+
48
+ Before executing the domain-specific steps below, you MUST:
49
+
50
+ 1. **State the research question** -- What cognitive mechanism is this model capturing?
51
+ 2. **Justify the method choice** -- Why Bayesian (not MLE, not frequentist)? What alternatives were considered?
52
+ 3. **Declare expected outcomes** -- What parameter patterns would support vs. refute the hypothesis?
53
+ 4. **Note assumptions and limitations** -- What does this model assume about the cognitive process?
54
+ 5. **Present the plan to the user and WAIT for confirmation** before proceeding.
55
+
56
+ For detailed methodology guidance, see the `research-literacy` skill.
57
+
58
+
59
+ ## ⚠️ Verification Notice
60
+
61
+ This skill was generated by AI from academic literature. All parameters, thresholds, and citations require independent verification before use in research. If you find errors, please [open an issue](https://github.com/HaoxuanLiTHUAI/awesome_cognitive_and_neuroscience_skills/issues).
62
+
63
+ ## Model Structure Decision Tree
64
+
65
+ Choosing the right level of pooling is a fundamental modeling decision that a non-specialist routinely gets wrong.
66
+
67
+ ### Step 1: Do You Have Grouped Data?
68
+
69
+ If your data has a natural grouping structure (e.g., multiple trials per participant, participants within conditions), you need to decide on a pooling strategy. If not, fit a single model.
70
+
71
+ ### Step 2: Choose the Pooling Level
72
+
73
+ | Strategy | Structure | When Appropriate | Risk |
74
+ |----------|-----------|------------------|------|
75
+ | **Complete pooling** | One set of parameters for all participants | Large homogeneous groups, nuisance individual differences | Ignores meaningful individual variation; biased group estimates if heterogeneity exists (Gelman et al., 2013, Ch. 5) |
76
+ | **No pooling** | Separate parameters per participant | Many trials per participant (>200), individual-level inference is the goal | Noisy estimates for participants with few trials; no borrowing of strength (Gelman et al., 2013, Ch. 5) |
77
+ | **Partial pooling (hierarchical)** | Individual parameters drawn from group distribution | **Default choice** for cognitive modeling; few-to-moderate trials per participant; individual differences are scientifically meaningful | Requires MCMC; potential convergence issues with centered parameterization (Gelman et al., 2013, Ch. 5) |
78
+
79
+ > **Critical domain knowledge**: Hierarchical (partial pooling) models should be the default in cognitive science. They automatically regularize extreme individual estimates toward the group mean -- a property called "shrinkage" -- which is especially valuable with typical cognitive science sample sizes of 20-40 participants with 50-200 trials each (Lee & Wagenmakers, 2014, Ch. 8).
80
+
81
+ ### Step 3: Centered vs. Non-Centered Parameterization
82
+
83
+ For hierarchical models, the parameterization choice affects MCMC efficiency:
84
+
85
+ - **Centered parameterization**: `theta_j ~ Normal(mu, sigma)`. Use when there are many observations per group (>100 trials per participant) and the data are informative relative to the prior (Betancourt & Girolami, 2015).
86
+ - **Non-centered parameterization**: `theta_j = mu + sigma * eta_j` where `eta_j ~ Normal(0, 1)`. Use when there are few observations per group, the group-level variance is small, or you encounter divergent transitions with centered parameterization (Betancourt & Girolami, 2015; Stan User's Guide, Section 1.13).
87
+
88
+ > **When in doubt, use non-centered parameterization.** It is more robust across a wider range of data configurations and is the Stan Development Team's default recommendation.
89
+
90
+ ## Prior Selection Principles
91
+
92
+ ### General Philosophy
93
+
94
+ Use **weakly informative priors** that encode known constraints without dominating the likelihood. The goal is to rule out impossible or implausible parameter values while remaining agnostic about the precise value (Gelman et al., 2008; Gelman et al., 2013, Ch. 2).
95
+
96
+ > **Domain-critical principle**: Cognitive parameters have natural constraints that generic "flat" or "diffuse" priors violate. Reaction times cannot be negative. Probabilities must lie in [0,1]. Learning rates are bounded. Firing rates are non-negative. Encoding these constraints in the prior is not "being subjective" -- it is encoding physical and psychological reality (Lee & Wagenmakers, 2014, Ch. 4).
97
+
98
+ ### Prior Families for Common Cognitive Parameter Types
99
+
100
+ | Parameter Type | Recommended Prior | Rationale | Source |
101
+ |---------------|-------------------|-----------|--------|
102
+ | Location (unbounded) | Normal(0, sd) or Student-t(3, 0, sd) | Weakly informative; heavier tails with Student-t for robustness | Gelman et al., 2008 |
103
+ | Scale / variance | Half-Normal(0, sd) or Half-Cauchy(0, sd) | Positive-only; Half-Cauchy allows heavier tails for group-level SDs | Gelman, 2006; Polson & Scott, 2012 |
104
+ | Probability (0 to 1) | Beta(a, b) | Natural conjugate for binomial; Beta(1,1) = Uniform; Beta(2,2) = weakly informative centered at 0.5 | Kruschke, 2015, Ch. 6 |
105
+ | Rate (0 to 1) | Beta(1.1, 1.1) or logit-Normal | Gently regularizes away from boundaries | Gelman et al., 2013, Ch. 2 |
106
+ | Positive continuous | Gamma(shape, rate) or Lognormal(mu, sigma) | For RT, non-decision time, threshold parameters | Lee & Wagenmakers, 2014, Ch. 4 |
107
+ | Correlation matrix | LKJ(eta) | eta=1: uniform over matrices; **eta=2: weakly informative** (Stan default recommendation) | Lewandowski et al., 2009; Stan User's Guide |
108
+ | Simplex (sums to 1) | Dirichlet(alpha) | alpha=1: uniform on simplex; alpha>1: concentrates toward center | Gelman et al., 2013, Ch. 2 |
109
+
110
+ For detailed cognitive-domain-specific prior tables, see `references/prior-selection-guide.md`.
111
+
112
+ ### Prior Predictive Checking
113
+
114
+ **Always** run a prior predictive check before fitting to data (Schad et al., 2021; Gabry et al., 2019):
115
+
116
+ 1. Sample parameters from your priors (no data)
117
+ 2. Simulate data from the model using those parameters
118
+ 3. Check: Does the simulated data look plausible for the domain?
119
+ - If the prior predicts impossible RTs (e.g., negative, or > 60 seconds), the prior is too diffuse
120
+ - If the prior predicts accuracy always near 50% or always near 100%, reconsider
121
+ 4. Iterate on priors until prior predictive distributions cover plausible data ranges without including absurd values
122
+
123
+ ## Common Cognitive Models in Bayesian Framework
124
+
125
+ ### Drift-Diffusion Model (DDM / HDDM)
126
+
127
+ - **Key parameters**: drift rate (v), boundary separation (a), non-decision time (t), starting point bias (z)
128
+ - **Bayesian implementation**: HDDM package (Wiecki et al., 2013) uses informative priors from empirical meta-analysis (Matzke & Wagenmakers, 2009)
129
+ - **Typical priors**: See `references/prior-selection-guide.md` for parameter-specific recommendations
130
+ - **Critical note**: Within-trial noise (s) is a scaling parameter fixed by convention at **0.1** (Ratcliff, 1978) or **1.0** (Navarro & Fuss, 2009). All other parameter ranges depend on this choice.
131
+ - Also see the `drift-diffusion-model` skill for detailed DDM guidance
132
+
133
+ ### Signal Detection Theory (SDT)
134
+
135
+ - **Key parameters**: sensitivity (d'), criterion (c)
136
+ - **Priors for d'**: Normal(0, 2) is weakly informative; typical empirical values range **0 to 4** (Macmillan & Creelman, 2005)
137
+ - **Priors for c**: Normal(0, 1.5) centered at no bias; typical range **-2 to 2** (Macmillan & Creelman, 2005)
138
+ - **Hierarchical structure**: Individual d' and c drawn from group distributions (Rouder & Lu, 2005)
139
+ - Also see the `signal-detection-analysis` skill
140
+
141
+ ### Multinomial Processing Trees (MPT)
142
+
143
+ - **Key parameters**: Processing probabilities (all in [0,1])
144
+ - **Priors**: Beta(1,1) for non-informative or Beta(a,b) with shape informed by prior studies (Klauer, 2010)
145
+ - **Hierarchical extension**: Latent-trait MPT with probit-transformed parameters drawn from multivariate normal (Klauer, 2010)
146
+
147
+ ### Item Response Theory (IRT)
148
+
149
+ - **Key parameters**: Ability (theta), difficulty (b), discrimination (a)
150
+ - **Priors**: theta ~ Normal(0,1) by convention; b ~ Normal(0, 2); a ~ Lognormal(0, 0.5) to enforce positivity (de Boeck & Wilson, 2004)
151
+ - **Cognitive application**: Modeling learning, cognitive ability, or item difficulty in memory/attention tasks
152
+
153
+ ### Reinforcement Learning (RL)
154
+
155
+ - **Key parameters**: Learning rate (alpha in [0,1]), inverse temperature (beta > 0), decay, perseveration
156
+ - **Priors for alpha**: Beta(1.1, 1.1) weakly informative on [0,1] (Daw, 2011; Gershman, 2016)
157
+ - **Priors for beta (inverse temperature)**: Gamma(2, 1) or Lognormal(0, 1) constraining to positive values; typical range **0.5 to 20** (Daw, 2011)
158
+ - **Critical note**: Learning rate and inverse temperature are often poorly identifiable in standard Q-learning; consider reparameterization or strong priors (Daw, 2011; Wilson & Collins, 2019)
159
+
160
+ ## MCMC Diagnostics
161
+
162
+ Every Bayesian analysis requires thorough convergence diagnostics. **Never report posterior summaries without first verifying convergence.** See `references/diagnostics-checklist.md` for the full step-by-step protocol.
163
+
164
+ ### Minimum Convergence Criteria
165
+
166
+ | Diagnostic | Threshold | Interpretation | Source |
167
+ |-----------|-----------|----------------|--------|
168
+ | R-hat (split R-hat) | **< 1.01** | Between-chain vs. within-chain variance; values > 1.01 indicate non-convergence | Vehtari et al., 2021 |
169
+ | Bulk-ESS | **> 400** (100 per chain with 4 chains) | Effective independent draws for posterior mean/median estimation | Vehtari et al., 2021 |
170
+ | Tail-ESS | **> 400** | Effective draws for tail quantiles (credible intervals) | Vehtari et al., 2021 |
171
+ | Divergent transitions | **0** | Any divergences indicate the sampler failed to explore the posterior faithfully | Betancourt, 2017 |
172
+ | E-BFMI | **> 0.3** | Energy Bayesian Fraction of Missing Information; low values indicate poor exploration | Betancourt, 2017 |
173
+ | Tree depth saturation | Rare (<1% of transitions) | Hitting maximum tree depth suggests difficult geometry | Stan User's Guide |
174
+
175
+ > **Critical domain knowledge**: The older threshold of R-hat < 1.1 is **outdated**. Vehtari et al. (2021) demonstrated that the traditional R-hat can miss convergence failures. Use the rank-normalized split R-hat with a threshold of **1.01** and always report both bulk-ESS and tail-ESS.
176
+
177
+ ### When Diagnostics Fail
178
+
179
+ See `references/diagnostics-checklist.md` for remediation steps. The most common fixes in cognitive modeling:
180
+
181
+ 1. **Divergent transitions** --> Switch to non-centered parameterization; increase `adapt_delta` to 0.95-0.99
182
+ 2. **Low ESS** --> Run longer chains; check for multimodality; reparameterize
183
+ 3. **High R-hat** --> Run more iterations; check for label switching in mixture models
184
+ 4. **E-BFMI warning** --> Reparameterize; consider reducing model complexity
185
+
186
+ ## Model Comparison
187
+
188
+ ### Information Criteria (Preferred for Most Applications)
189
+
190
+ | Method | When to Use | Implementation | Source |
191
+ |--------|------------|----------------|--------|
192
+ | **PSIS-LOO-CV** | **Default choice** for comparing predictive accuracy; more robust than WAIC with weak priors or influential observations | `loo` package (R), `az.loo` (Python/ArviZ) | Vehtari et al., 2017 |
193
+ | **WAIC** | Asymptotically equivalent to LOO; acceptable when PSIS diagnostics are clean (all Pareto k < 0.7) | `loo` package (R), `az.waic` (Python/ArviZ) | Watanabe, 2010; Vehtari et al., 2017 |
194
+ | **Bayes factors** | When testing a precise null hypothesis (e.g., parameter = 0); sensitive to prior specification | Bridge sampling, Savage-Dickey density ratio | Kass & Raftery, 1995; Lee & Wagenmakers, 2014, Ch. 7 |
195
+
196
+ > **Critical domain knowledge**: Prefer LOO-CV over WAIC for cognitive models. Vehtari et al. (2017) showed that PSIS-LOO is more robust in the finite-sample case, especially with weak priors or influential observations common in cognitive data. Always check the Pareto k diagnostic: values > **0.7** indicate unreliable LOO estimates for those observations.
197
+
198
+ ### Interpreting Bayes Factors
199
+
200
+ | Bayes Factor (BF10) | Evidence Category | Source |
201
+ |---------------------|-------------------|--------|
202
+ | 1 - 3 | Anecdotal / not worth more than a bare mention | Jeffreys, 1961; Lee & Wagenmakers, 2014 |
203
+ | 3 - 10 | Moderate evidence | Jeffreys, 1961; Lee & Wagenmakers, 2014 |
204
+ | 10 - 30 | Strong evidence | Jeffreys, 1961; Lee & Wagenmakers, 2014 |
205
+ | 30 - 100 | Very strong evidence | Jeffreys, 1961; Lee & Wagenmakers, 2014 |
206
+ | > 100 | Extreme / decisive evidence | Jeffreys, 1961; Lee & Wagenmakers, 2014 |
207
+
208
+ > **Caution**: Bayes factors are highly sensitive to prior specification. A diffuse prior on the alternative hypothesis inflates evidence for the null (the Jeffreys-Lindley paradox). Always conduct a prior sensitivity analysis when reporting Bayes factors (Schad et al., 2021).
209
+
210
+ ### Posterior Predictive Checks
211
+
212
+ After model comparison, the selected model must demonstrate it can reproduce key features of the observed data:
213
+
214
+ 1. **Simulate data** from the posterior predictive distribution (draw parameters from posterior, then generate synthetic data)
215
+ 2. **Compare summary statistics**: mean RT, RT quantiles (0.1, 0.3, 0.5, 0.7, 0.9), accuracy, conditional accuracy functions
216
+ 3. **Visual checks**: overlay posterior predictive density on observed data; Q-Q plots; residual distributions
217
+ 4. **Quantitative checks**: Posterior predictive p-values for test statistics of interest; values near 0 or 1 indicate misfit (Gelman et al., 2013, Ch. 6)
218
+
219
+ > **Domain-specific checks**: For RT models, always check the fit to the **full RT distribution** (not just the mean). Cognitive models derive their power from fitting distributional shape -- a model that matches mean RT but misses the right tail is inadequate (Ratcliff & McKoon, 2008).
220
+
221
+ ## Common Pitfalls
222
+
223
+ ### 1. Non-Identifiability
224
+
225
+ **Problem**: Two or more parameters trade off so that many parameter combinations yield equivalent likelihoods. Common in RL models (learning rate vs. inverse temperature) and DDM (boundary vs. drift rate with few conditions).
226
+
227
+ **Detection**: Pairwise posterior scatter plots show strong correlations or ridges; marginal posteriors are much wider than expected.
228
+
229
+ **Fix**: Add conditions that differentially constrain parameters; use informative priors; reparameterize (e.g., the ratio v/a in DDM; Wilson & Collins, 2019).
230
+
231
+ ### 2. Prior Sensitivity
232
+
233
+ **Problem**: Posterior conclusions change substantially when priors are varied within a reasonable range.
234
+
235
+ **Detection**: Re-fit with 2-3 alternative prior specifications and compare posteriors (Schad et al., 2021).
236
+
237
+ **Fix**: Collect more data; use more informative priors justified by previous literature; report sensitivity analysis in the paper.
238
+
239
+ ### 3. Label Switching
240
+
241
+ **Problem**: In mixture models, MCMC chains swap component labels, creating multimodal marginal posteriors even when the model is well-identified.
242
+
243
+ **Detection**: Trace plots show "switching" between modes; R-hat is high even with long chains.
244
+
245
+ **Fix**: Impose ordering constraints (e.g., mu_1 < mu_2); use label-invariant summaries; post-hoc relabeling (Stephens, 2000).
246
+
247
+ ### 4. Improper Posterior Geometry
248
+
249
+ **Problem**: Funnel-shaped posterior in hierarchical models where the group SD approaches zero, creating an increasingly narrow funnel that the sampler cannot traverse.
250
+
251
+ **Detection**: Divergent transitions concentrated near low group-SD values; non-centered parameterization is the standard fix (Betancourt & Girolami, 2015).
252
+
253
+ **Fix**: Non-centered parameterization (see Step 3 in Model Structure Decision Tree above).
254
+
255
+ ### 5. Insufficient Trials Per Participant
256
+
257
+ **Problem**: With too few trials, individual-level parameters are poorly constrained even in hierarchical models.
258
+
259
+ **Guideline**: For DDM, minimum **40-60 trials per condition per participant** for stable hierarchical estimation (Wiecki et al., 2013; Ratcliff & Childers, 2015). For simpler models (e.g., binomial SDT), **20-30 trials** may suffice with hierarchical priors (Lee & Wagenmakers, 2014).
260
+
261
+ **Fix**: If data are already collected, rely more heavily on hierarchical shrinkage and report wide credible intervals honestly.
262
+
263
+ ## Reporting Checklist
264
+
265
+ When reporting Bayesian cognitive models in a manuscript:
266
+
267
+ 1. **Model specification**: Full generative model with likelihood and all priors (consider a graphical model plate diagram)
268
+ 2. **Prior justification**: Why each prior was chosen; cite sources for domain-informed priors
269
+ 3. **Prior predictive check**: Confirm priors generate plausible data
270
+ 4. **Software and sampler settings**: Package, version, number of chains (minimum **4**; Vehtari et al., 2021), warmup iterations, sampling iterations, adapt_delta
271
+ 5. **Convergence diagnostics**: R-hat (< 1.01), bulk-ESS (> 400), tail-ESS (> 400), divergent transitions (0)
272
+ 6. **Posterior summaries**: Means/medians, credible intervals (89% or 95% HDI; Kruschke, 2015, Ch. 12), and full posterior distributions where space allows
273
+ 7. **Posterior predictive checks**: Visual and/or quantitative evidence that the model reproduces key data features
274
+ 8. **Model comparison** (if applicable): LOO-CV/WAIC with standard errors; Bayes factors with prior sensitivity
275
+ 9. **Sensitivity analysis**: At least one alternative prior specification with comparison of results
276
+ 10. **Code and data availability**: Share Stan/PyMC code and (where possible) data for reproducibility
277
+
278
+ ## Key References
279
+
280
+ - Betancourt, M. (2017). A conceptual introduction to Hamiltonian Monte Carlo. *arXiv:1701.02434*.
281
+ - Betancourt, M., & Girolami, M. (2015). Hamiltonian Monte Carlo for hierarchical models. In *Current Trends in Bayesian Methodology with Applications*. Chapman and Hall/CRC.
282
+ - Daw, N. D. (2011). Trial-by-trial data analysis using computational models. In *Decision Making, Affect, and Learning*. Oxford University Press.
283
+ - Gabry, J., Simpson, D., Vehtari, A., Betancourt, M., & Gelman, A. (2019). Visualization in Bayesian workflow. *Journal of the Royal Statistical Society: Series A*, 182(2), 389-402.
284
+ - Gelman, A. (2006). Prior distributions for variance parameters in hierarchical models. *Bayesian Analysis*, 1(3), 515-534.
285
+ - Gelman, A., Jakulin, A., Pittau, M. G., & Su, Y. S. (2008). A weakly informative default prior distribution for logistic and other regression models. *Annals of Applied Statistics*, 2(4), 1360-1383.
286
+ - Gelman, A., Carlin, J. B., Stern, H. S., Dunson, D. B., Vehtari, A., & Rubin, D. B. (2013). *Bayesian Data Analysis* (3rd ed.). Chapman and Hall/CRC.
287
+ - Gershman, S. J. (2016). Empirical priors for reinforcement learning models. *Journal of Mathematical Psychology*, 71, 1-6.
288
+ - Kruschke, J. K. (2015). *Doing Bayesian Data Analysis* (2nd ed.). Academic Press.
289
+ - Lee, M. D., & Wagenmakers, E. J. (2014). *Bayesian Cognitive Modeling: A Practical Course*. Cambridge University Press.
290
+ - Schad, D. J., Betancourt, M., & Vasishth, S. (2021). Toward a principled Bayesian workflow in cognitive science. *Psychological Methods*, 26(1), 103-126.
291
+ - Vehtari, A., Gelman, A., & Gabry, J. (2017). Practical Bayesian model evaluation using leave-one-out cross-validation and WAIC. *Statistics and Computing*, 27, 1413-1432.
292
+ - Vehtari, A., Gelman, A., Simpson, D., Carpenter, B., & Burkner, P. C. (2021). Rank-normalization, folding, and localization: An improved R-hat for assessing convergence of MCMC. *Bayesian Analysis*, 16(2), 667-718.
293
+ - Wiecki, T. V., Sofer, I., & Frank, M. J. (2013). HDDM: Hierarchical Bayesian estimation of the drift-diffusion model in Python. *Frontiers in Neuroinformatics*, 7, 14.
294
+ - Wilson, R. C., & Collins, A. G. (2019). Ten simple rules for the computational modeling of behavioral data. *eLife*, 8, e49547.
@@ -0,0 +1,351 @@
1
+ # MCMC Diagnostics and Model Checking Checklist
2
+
3
+ This reference provides a step-by-step diagnostic protocol for Bayesian cognitive models fitted with MCMC (Stan/PyMC). Every threshold is cited. Follow this checklist in order before reporting any posterior results.
4
+
5
+ ---
6
+
7
+ ## Phase 1: Pre-Fitting Checks
8
+
9
+ ### 1.1 Prior Predictive Check
10
+
11
+ Before fitting the model to data, verify that the priors produce plausible simulated data.
12
+
13
+ - [ ] Sample 500-1000 parameter sets from the prior distributions
14
+ - [ ] Simulate datasets from the generative model using each parameter set
15
+ - [ ] Verify simulated data falls within the plausible range for the domain
16
+ - [ ] Document the prior predictive check results
17
+
18
+ See `prior-selection-guide.md` for the full prior predictive checking procedure and domain-specific plausibility criteria.
19
+
20
+ ### 1.2 Computational Setup
21
+
22
+ - [ ] Run a minimum of **4 chains** (Vehtari et al., 2021)
23
+ - [ ] Set warmup/burn-in to at least **1000 iterations** per chain (Stan default; adjust upward for complex models)
24
+ - [ ] Set sampling iterations to at least **1000 per chain** (total post-warmup draws >= 4000)
25
+ - [ ] For Stan: set `adapt_delta` to at least **0.8** (default); increase to **0.95-0.99** if divergent transitions occur (Stan Reference Manual)
26
+ - [ ] For Stan: set `max_treedepth` to **10** (default); increase to **12-15** if tree depth saturation warnings appear
27
+ - [ ] Record software version, random seed, and all sampler settings for reproducibility
28
+
29
+ ---
30
+
31
+ ## Phase 2: Convergence Diagnostics
32
+
33
+ Run these checks on every parameter in the model, including derived quantities and hyperparameters. A single failing parameter means the model has not converged.
34
+
35
+ ### 2.1 R-hat (Split R-hat, Rank-Normalized)
36
+
37
+ **Threshold: R-hat < 1.01 for all parameters** (Vehtari et al., 2021)
38
+
39
+ | R-hat Value | Interpretation | Action |
40
+ |-------------|---------------|--------|
41
+ | < 1.01 | Chains have converged | Proceed |
42
+ | 1.01 - 1.05 | Possible convergence issue | Investigate; run longer chains; check trace plots |
43
+ | 1.05 - 1.1 | Likely convergence failure | Do not report results; diagnose the problem |
44
+ | > 1.1 | Definite convergence failure | Do not report results; model needs reparameterization or longer run |
45
+
46
+ **What R-hat measures**: The ratio of between-chain variance to within-chain variance after splitting each chain in half. The improved rank-normalized version (Vehtari et al., 2021) also detects problems in the tails of the distribution that traditional R-hat misses.
47
+
48
+ **Common causes of high R-hat**:
49
+ - Insufficient warmup/sampling iterations
50
+ - Multimodality in the posterior (multiple modes that chains get stuck in)
51
+ - Label switching in mixture models
52
+ - Near-non-identifiability creating ridges in the posterior
53
+ - Poor initial values causing chains to explore different regions
54
+
55
+ **Fixes**:
56
+ 1. Run longer chains (double iterations)
57
+ 2. Check for multimodality via trace plots
58
+ 3. For mixture models, impose ordering constraints to prevent label switching (e.g., mu_1 < mu_2) (Stephens, 2000)
59
+ 4. Reparameterize: switch centered to non-centered (or vice versa)
60
+ 5. Use more informative priors to reduce posterior ambiguity
61
+
62
+ ### 2.2 Effective Sample Size (ESS)
63
+
64
+ **Threshold: Bulk-ESS > 400 AND Tail-ESS > 400** (Vehtari et al., 2021)
65
+
66
+ The 400 threshold assumes 4 chains (approximately 100 effective samples per chain).
67
+
68
+ | ESS Type | What It Measures | Minimum | Source |
69
+ |----------|-----------------|---------|--------|
70
+ | **Bulk-ESS** | Effective samples for estimating the posterior mean/median (center of distribution) | **> 400** | Vehtari et al., 2021 |
71
+ | **Tail-ESS** | Effective samples for estimating tail quantiles (credible interval endpoints) | **> 400** | Vehtari et al., 2021 |
72
+
73
+ **Why two ESS measures?** A chain can mix well in the bulk of the distribution but poorly in the tails, or vice versa. Reporting only one ESS can mask problems with credible interval estimation. Tail-ESS is the minimum of the ESS for the 5th and 95th percentile quantiles (Vehtari et al., 2021).
74
+
75
+ **ESS vs. total draws ratio**: If ESS/total_draws < 0.1, there is substantial autocorrelation. This is not necessarily a problem if absolute ESS exceeds 400, but very low ratios (< 0.01) suggest the sampler is struggling.
76
+
77
+ **Common causes of low ESS**:
78
+ - High autocorrelation from poor parameterization (centered hierarchical when non-centered is needed)
79
+ - Near-non-identifiability creating slow exploration
80
+ - Multimodality causing chains to remain in modes for extended periods
81
+ - Step size too large or too small (diagnosed via tree depth)
82
+
83
+ **Fixes**:
84
+ 1. Reparameterize (non-centered parameterization for hierarchical models)
85
+ 2. Run more iterations
86
+ 3. Thin chains as a last resort (increases ESS per stored sample but wastes computation)
87
+ 4. For Stan: check that `adapt_delta` is not too high (> 0.99 slows down sampling without benefit for well-specified models)
88
+
89
+ ### 2.3 Divergent Transitions
90
+
91
+ **Threshold: 0 divergent transitions** (Betancourt, 2017)
92
+
93
+ - [ ] Check for divergent transitions in sampler output
94
+ - [ ] If any divergences occurred, do NOT trust the posterior
95
+
96
+ **What divergent transitions mean**: The Hamiltonian Monte Carlo sampler encountered regions of the posterior with very high curvature that it could not faithfully traverse. This means the posterior samples may not represent the true posterior distribution (Betancourt, 2017).
97
+
98
+ | Number of Divergences | Interpretation | Action |
99
+ |-----------------------|---------------|--------|
100
+ | 0 | No detected geometry problems | Proceed |
101
+ | 1-10 | Mild geometry issue; posterior may be biased in problematic region | Investigate; try remediation |
102
+ | 10-100 | Serious geometry problem | Do not trust results; must fix |
103
+ | > 100 | Severe model/parameterization problem | Rethink model specification |
104
+
105
+ **Common causes**:
106
+ - **Funnel geometry** in centered hierarchical models (the most common cause in cognitive modeling)
107
+ - Highly correlated parameters creating narrow valleys
108
+ - Priors that conflict with the likelihood, creating sharp posterior ridges
109
+ - Boundaries or constraints creating discontinuities
110
+
111
+ **Fixes** (in order of preference):
112
+ 1. **Non-centered parameterization**: Transform `theta_j ~ Normal(mu, sigma)` to `theta_j = mu + sigma * eta_j` where `eta_j ~ Normal(0, 1)` (Betancourt & Girolami, 2015)
113
+ 2. **Increase adapt_delta**: Set to 0.95, then 0.99 if needed. This reduces the step size, allowing the sampler to navigate difficult geometry at the cost of slower sampling (Stan Reference Manual)
114
+ 3. **Reparameterize correlated parameters**: Use Cholesky decompositions for multivariate priors; consider QR decomposition for regression predictors
115
+ 4. **Tighten priors**: More informative priors can smooth posterior geometry
116
+ 5. **Simplify the model**: If divergences persist after all fixes, the model may be too complex for the data
117
+
118
+ **Where divergences occur**: In Stan, you can extract which iterations diverged and plot the parameter values at those iterations. If divergences cluster in a specific region of parameter space (e.g., near sigma = 0 in a hierarchical model), this confirms the funnel geometry diagnosis.
119
+
120
+ ### 2.4 Energy Diagnostics (E-BFMI)
121
+
122
+ **Threshold: E-BFMI > 0.3** (Betancourt, 2017)
123
+
124
+ The Energy Bayesian Fraction of Missing Information measures how well the HMC momentum can explore the posterior.
125
+
126
+ | E-BFMI Value | Interpretation | Action |
127
+ |--------------|---------------|--------|
128
+ | > 0.3 | Adequate exploration | Proceed |
129
+ | 0.2 - 0.3 | Marginal; may miss some posterior mass | Investigate; consider reparameterization |
130
+ | < 0.2 | Poor exploration; posterior may be biased | Reparameterize; increase adapt_delta |
131
+
132
+ **Common causes of low E-BFMI**:
133
+ - Heavy-tailed posterior that HMC cannot efficiently explore
134
+ - Posterior with very different scales across parameters
135
+ - Funnel geometry (often co-occurs with divergent transitions)
136
+
137
+ **Fix**: Reparameterize to make the posterior geometry more uniform; standardize parameter scales.
138
+
139
+ ### 2.5 Tree Depth Saturation
140
+
141
+ **Threshold: < 1% of transitions hitting max_treedepth** (Stan Reference Manual)
142
+
143
+ When the NUTS sampler hits the maximum tree depth, it terminates the trajectory early, potentially reducing sampling efficiency.
144
+
145
+ - [ ] Check fraction of transitions that hit max_treedepth
146
+ - [ ] If > 1% saturate, increase max_treedepth by 2-3 (e.g., from 10 to 12 or 13)
147
+
148
+ **Note**: Tree depth saturation does not bias the posterior (unlike divergences), but it reduces ESS per unit time. The only cost of increasing max_treedepth is computational time (each additional depth level doubles the maximum number of leapfrog steps).
149
+
150
+ ---
151
+
152
+ ## Phase 3: Visual Diagnostics
153
+
154
+ Even when numerical diagnostics pass, visual inspection can reveal subtle problems.
155
+
156
+ ### 3.1 Trace Plots
157
+
158
+ - [ ] All chains should be well-mixed (indistinguishable "fuzzy caterpillar" appearance)
159
+ - [ ] No chain should be stuck in a different region from others
160
+ - [ ] No long-term trends (drift) in any chain
161
+ - [ ] No periodic patterns (indicates strong autocorrelation)
162
+
163
+ **What to look for**:
164
+ - **Good mixing**: Chains overlap completely and look like noise
165
+ - **Poor mixing**: Chains show slow wandering, long excursions, or different levels
166
+ - **Label switching**: Chains periodically swap between two or more values (common in mixture models)
167
+ - **Stationarity violation**: Chain mean or variance changes over time
168
+
169
+ ### 3.2 Rank Plots (Recommended)
170
+
171
+ - [ ] Generate rank histogram plots (available in ArviZ and bayesplot)
172
+ - [ ] Uniform rank histograms indicate good mixing across chains
173
+ - [ ] Non-uniform patterns indicate convergence problems
174
+
175
+ Rank plots are more informative than traditional trace plots for detecting subtle mixing problems (Vehtari et al., 2021).
176
+
177
+ ### 3.3 Pairwise Posterior Scatter Plots
178
+
179
+ - [ ] Check for strong posterior correlations between parameters
180
+ - [ ] Look for banana-shaped or ridge-shaped posteriors (indicate non-identifiability)
181
+ - [ ] Verify that no parameter pair shows a perfect linear trade-off
182
+
183
+ **Typical problematic correlations in cognitive models**:
184
+ - DDM: drift rate (v) and boundary separation (a) often negatively correlated when few conditions constrain them
185
+ - RL: learning rate (alpha) and inverse temperature (beta) are classically collinear (Daw, 2011)
186
+ - SDT: d' and c can correlate when hit/false alarm rates approach boundaries
187
+
188
+ ---
189
+
190
+ ## Phase 4: Posterior Predictive Checks
191
+
192
+ After confirming convergence, verify that the model can reproduce the observed data.
193
+
194
+ ### 4.1 Basic Posterior Predictive Protocol
195
+
196
+ 1. **Draw S = 500-1000 samples** from the posterior distribution
197
+ 2. **For each posterior sample, simulate a complete dataset** with the same structure as the observed data
198
+ 3. **Compute summary statistics** on each simulated dataset (same statistics you would report for the real data)
199
+ 4. **Compare simulated vs. observed statistics** using overlaid distributions or difference plots
200
+
201
+ ### 4.2 Domain-Specific Posterior Predictive Checks
202
+
203
+ #### For Reaction Time Models (DDM, LBA, etc.)
204
+
205
+ - [ ] **Mean RT by condition**: Simulated mean RT should bracket observed mean RT
206
+ - [ ] **RT quantiles (0.1, 0.3, 0.5, 0.7, 0.9) by condition**: The full distributional shape must be captured, not just the mean (Ratcliff & McKoon, 2008)
207
+ - [ ] **Accuracy by condition**: Simulated accuracy should bracket observed accuracy
208
+ - [ ] **Conditional Accuracy Functions (CAFs)**: Accuracy as a function of RT quantile bin; captures speed-accuracy tradeoff dynamics
209
+ - [ ] **RT distribution shape**: Overlay posterior predictive density on observed RT histogram; check right tail fit
210
+ - [ ] **Error RT distribution**: Often neglected; error RTs should be faster or slower than correct RTs depending on the model (Ratcliff & McKoon, 2008)
211
+
212
+ #### For Learning Models (RL, etc.)
213
+
214
+ - [ ] **Learning curves**: Simulated performance over trial blocks should match observed learning trajectory
215
+ - [ ] **Choice proportions by block**: Should bracket observed choice frequencies
216
+ - [ ] **Win-stay / lose-shift rates**: Captures local choice dynamics that aggregate statistics miss (Wilson & Collins, 2019)
217
+ - [ ] **Individual differences**: Simulated between-participant variability should match observed variability
218
+
219
+ #### For Signal Detection Models
220
+
221
+ - [ ] **Hit rate and false alarm rate**: Should bracket observed rates
222
+ - [ ] **ROC curve shape** (if multiple criteria/confidence levels available): Simulated ROC should match observed ROC
223
+ - [ ] **z-ROC linearity**: If assuming equal variance, z-ROC should be linear with slope near 1; deviations suggest unequal variance model (Macmillan & Creelman, 2005)
224
+
225
+ #### For Multinomial Processing Tree Models
226
+
227
+ - [ ] **Category response frequencies**: Simulated response frequencies should bracket observed frequencies for each response category
228
+ - [ ] **Pearson chi-square or G-squared**: Posterior predictive p-value for model fit (Klauer, 2010)
229
+
230
+ ### 4.3 Quantitative Posterior Predictive Assessment
231
+
232
+ **Posterior predictive p-value**: For a test statistic T(y), compute:
233
+
234
+ ```
235
+ p_B = Pr(T(y_rep) >= T(y_obs) | y_obs)
236
+ ```
237
+
238
+ where y_rep is data simulated from the posterior predictive distribution (Gelman et al., 2013, Ch. 6).
239
+
240
+ | p_B Value | Interpretation |
241
+ |-----------|---------------|
242
+ | 0.05 - 0.95 | No evidence of misfit for this statistic |
243
+ | < 0.05 or > 0.95 | Model systematically under- or over-predicts this feature |
244
+ | < 0.01 or > 0.99 | Strong evidence of misfit; model is missing an important data feature |
245
+
246
+ **Caution**: Posterior predictive p-values are conservative (they tend toward 0.5) because the same data are used for fitting and checking. A p-value near 0.5 does not guarantee good fit; it only means the check did not detect misfit (Gelman et al., 2013, Ch. 6).
247
+
248
+ **Choose meaningful test statistics**: Select statistics that capture features your model claims to explain. For DDMs, check RT quantiles, not just the mean. For RL models, check block-by-block learning, not just overall accuracy.
249
+
250
+ ---
251
+
252
+ ## Phase 5: Sensitivity Analysis
253
+
254
+ ### 5.1 Prior Sensitivity
255
+
256
+ - [ ] Re-fit the model with **at least 2 alternative prior specifications**:
257
+ - One with wider (more diffuse) priors
258
+ - One with narrower (more informative) priors
259
+ - [ ] Compare posterior means, credible intervals, and qualitative conclusions
260
+ - [ ] If conclusions change substantially, report this and collect more data or justify your preferred prior (Schad et al., 2021)
261
+
262
+ ### 5.2 What to Vary
263
+
264
+ | What to Vary | How | Concern If Results Change |
265
+ |-------------|-----|--------------------------|
266
+ | Prior SD on group means | Double and halve | Data may not be informative enough for this parameter |
267
+ | Prior on group-level SD | Try Half-Normal(0,0.5) vs Half-Normal(0,2) | Between-participant variance is poorly identified |
268
+ | Prior family | Try Normal vs. Student-t(3) for location parameters | Sensitivity to tail behavior |
269
+ | LKJ eta parameter | Try eta=1 vs eta=2 vs eta=4 | Correlation estimates driven by prior |
270
+ | Boundary-avoiding priors | Try Gamma vs. Lognormal for positive parameters | Choice of family matters for boundary behavior |
271
+
272
+ ### 5.3 Reporting Sensitivity Results
273
+
274
+ In your manuscript, include a brief sensitivity analysis section:
275
+
276
+ - State which priors were varied and to what alternatives
277
+ - Report whether the main conclusions (direction and magnitude of key effects) are robust
278
+ - If conclusions are sensitive, acknowledge this as a limitation and specify what additional data or constraints could resolve the ambiguity
279
+
280
+ ---
281
+
282
+ ## Phase 6: Summary Diagnostic Table Template
283
+
284
+ For your manuscript or supplementary materials, report a table like:
285
+
286
+ | Parameter | R-hat | Bulk-ESS | Tail-ESS | Prior | Posterior Mean [95% CI] |
287
+ |-----------|-------|----------|----------|-------|------------------------|
288
+ | mu_v | 1.00 | 2847 | 2104 | Normal(0, 2) | 1.52 [0.98, 2.11] |
289
+ | sigma_v | 1.00 | 1523 | 1205 | Half-Normal(0, 1) | 0.61 [0.38, 0.92] |
290
+ | mu_a | 1.00 | 3102 | 2456 | Half-Normal(0, 1) | 1.14 [0.95, 1.35] |
291
+ | ... | ... | ... | ... | ... | ... |
292
+
293
+ Additional information to report:
294
+ - Number of divergent transitions: 0
295
+ - E-BFMI: all chains > 0.3
296
+ - Software: Stan 2.x / PyMC 5.x (specify version)
297
+ - Chains: 4, Warmup: 1000, Sampling: 2000, adapt_delta: 0.95
298
+
299
+ ---
300
+
301
+ ## Quick Reference: Diagnostic Decision Flowchart
302
+
303
+ ```
304
+ 1. Any divergent transitions?
305
+ YES --> Fix parameterization (non-centered) or increase adapt_delta
306
+ NO --> Continue
307
+
308
+ 2. R-hat > 1.01 for any parameter?
309
+ YES --> Run longer; check for multimodality; reparameterize
310
+ NO --> Continue
311
+
312
+ 3. Bulk-ESS or Tail-ESS < 400 for any parameter?
313
+ YES --> Run longer; reparameterize; check autocorrelation
314
+ NO --> Continue
315
+
316
+ 4. E-BFMI < 0.3?
317
+ YES --> Reparameterize; standardize parameter scales
318
+ NO --> Continue
319
+
320
+ 5. Tree depth saturation > 1%?
321
+ YES --> Increase max_treedepth
322
+ NO --> Continue
323
+
324
+ 6. Visual checks pass (trace plots, rank plots, pair plots)?
325
+ YES --> Proceed to posterior predictive checks
326
+ NO --> Investigate identified issues
327
+
328
+ 7. Posterior predictive checks pass?
329
+ YES --> Proceed to sensitivity analysis and reporting
330
+ NO --> Revise model; consider missing mechanisms or misspecified priors
331
+
332
+ 8. Sensitivity analysis: conclusions robust to alternative priors?
333
+ YES --> Report results with confidence
334
+ NO --> Report sensitivity; acknowledge limitations; consider more data
335
+ ```
336
+
337
+ ---
338
+
339
+ ## References
340
+
341
+ - Betancourt, M. (2017). A conceptual introduction to Hamiltonian Monte Carlo. *arXiv:1701.02434*.
342
+ - Betancourt, M., & Girolami, M. (2015). Hamiltonian Monte Carlo for hierarchical models. In *Current Trends in Bayesian Methodology with Applications*. Chapman and Hall/CRC.
343
+ - Daw, N. D. (2011). Trial-by-trial data analysis using computational models. In *Decision Making, Affect, and Learning*. Oxford University Press.
344
+ - Gelman, A., et al. (2013). *Bayesian Data Analysis* (3rd ed.). Chapman and Hall/CRC.
345
+ - Klauer, K. C. (2010). Hierarchical multinomial processing tree models: A latent-trait approach. *Psychometrika*, 75(1), 70-98.
346
+ - Macmillan, N. A., & Creelman, C. D. (2005). *Detection Theory: A User's Guide* (2nd ed.). Lawrence Erlbaum Associates.
347
+ - Ratcliff, R., & McKoon, G. (2008). The diffusion decision model: Theory and data for two-choice decision tasks. *Neural Computation*, 20(4), 873-922.
348
+ - Schad, D. J., Betancourt, M., & Vasishth, S. (2021). Toward a principled Bayesian workflow in cognitive science. *Psychological Methods*, 26(1), 103-126.
349
+ - Stephens, M. (2000). Dealing with label switching in mixture models. *Journal of the Royal Statistical Society: Series B*, 62(4), 795-809.
350
+ - Vehtari, A., Gelman, A., Simpson, D., Carpenter, B., & Burkner, P. C. (2021). Rank-normalization, folding, and localization: An improved R-hat for assessing convergence of MCMC. *Bayesian Analysis*, 16(2), 667-718.
351
+ - Wilson, R. C., & Collins, A. G. (2019). Ten simple rules for the computational modeling of behavioral data. *eLife*, 8, e49547.