@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.
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/package.json +35 -0
- package/skills/01_Meta-Skills/contribute-skill/SKILL.md +277 -0
- package/skills/01_Meta-Skills/contribute-skills-via-pr/SKILL.md +163 -0
- package/skills/01_Meta-Skills/paper-to-skill/SKILL.md +435 -0
- package/skills/01_Meta-Skills/paper-to-skill/references/extraction-guide.md +286 -0
- package/skills/01_Meta-Skills/paper-to-skill/references/skill-template.md +250 -0
- package/skills/01_Meta-Skills/repo-to-skill/SKILL.md +289 -0
- package/skills/01_Meta-Skills/share-case/SKILL.md +253 -0
- package/skills/01_Meta-Skills/share-usage/README.md +63 -0
- package/skills/01_Meta-Skills/share-usage/SKILL.md +395 -0
- package/skills/01_Meta-Skills/verify-skill/SKILL.md +331 -0
- package/skills/02_Cross-Domain_Foundation/cogsci-power-analysis/SKILL.md +194 -0
- package/skills/02_Cross-Domain_Foundation/cogsci-power-analysis/references/effect-sizes.md +352 -0
- package/skills/02_Cross-Domain_Foundation/cogsci-power-analysis/references/sample-size-guide.md +407 -0
- package/skills/02_Cross-Domain_Foundation/cogsci-statistics/SKILL.md +361 -0
- package/skills/02_Cross-Domain_Foundation/cogsci-statistics/references/common-analyses.md +517 -0
- package/skills/02_Cross-Domain_Foundation/cogsci-visualization/SKILL.md +292 -0
- package/skills/02_Cross-Domain_Foundation/cogsci-visualization/references/plot-recipes.md +709 -0
- package/skills/02_Cross-Domain_Foundation/research-literacy/SKILL.md +286 -0
- package/skills/02_Cross-Domain_Foundation/research-literacy/references/common-assumptions.md +320 -0
- package/skills/02_Cross-Domain_Foundation/research-literacy/references/planning-template.md +143 -0
- package/skills/03_Cognitive_Psychology/alternative-uses-task-designer/SKILL.md +197 -0
- package/skills/03_Cognitive_Psychology/alternative-uses-task-designer/references/instruction-templates.md +60 -0
- package/skills/03_Cognitive_Psychology/cognitive-paradigm-design/SKILL.md +246 -0
- package/skills/03_Cognitive_Psychology/cognitive-paradigm-design/references/classic-paradigms.md +435 -0
- package/skills/03_Cognitive_Psychology/cognitive-paradigm-design/references/design-principles.md +256 -0
- package/skills/03_Cognitive_Psychology/creativity-self-efficacy-mediation/SKILL.md +270 -0
- package/skills/03_Cognitive_Psychology/creativity-self-efficacy-mediation/references/lavaan-templates.md +172 -0
- package/skills/03_Cognitive_Psychology/divergent-thinking-scoring/SKILL.md +238 -0
- package/skills/03_Cognitive_Psychology/divergent-thinking-scoring/references/scoring-rubric.md +143 -0
- package/skills/03_Cognitive_Psychology/drift-diffusion-model/SKILL.md +203 -0
- package/skills/03_Cognitive_Psychology/drift-diffusion-model/references/fitting-guide.md +571 -0
- package/skills/03_Cognitive_Psychology/drift-diffusion-model/references/model-variants.md +427 -0
- package/skills/03_Cognitive_Psychology/evidence-accumulation-selector/SKILL.md +310 -0
- package/skills/03_Cognitive_Psychology/evidence-accumulation-selector/references/ez-diffusion-formulas.md +137 -0
- package/skills/03_Cognitive_Psychology/signal-detection-analysis/SKILL.md +300 -0
- package/skills/03_Cognitive_Psychology/signal-detection-analysis/references/application-guide.md +278 -0
- package/skills/03_Cognitive_Psychology/signal-detection-analysis/references/sdt-formulas.md +318 -0
- package/skills/03_Cognitive_Psychology/visual-search-array-generator/SKILL.md +283 -0
- package/skills/03_Cognitive_Psychology/visual-search-array-generator/references/array-generation-parameters.yaml +111 -0
- package/skills/04_Psycholinguistics/reading-time-analysis/SKILL.md +301 -0
- package/skills/04_Psycholinguistics/reading-time-analysis/references/measure-computation-guide.md +195 -0
- package/skills/04_Psycholinguistics/self-paced-reading-designer/SKILL.md +257 -0
- package/skills/04_Psycholinguistics/self-paced-reading-designer/references/analysis-guide.md +356 -0
- package/skills/04_Psycholinguistics/self-paced-reading-designer/references/region-segmentation.md +266 -0
- package/skills/04_Psycholinguistics/sentence-stimulus-norming/SKILL.md +346 -0
- package/skills/04_Psycholinguistics/sentence-stimulus-norming/references/lexical-databases-guide.md +184 -0
- package/skills/05_EEG_ERP/eeg-paradigm-designer/SKILL.md +226 -0
- package/skills/05_EEG_ERP/eeg-paradigm-designer/references/component-paradigm-map.md +276 -0
- package/skills/05_EEG_ERP/eeg-paradigm-designer/references/timing-parameters.md +244 -0
- package/skills/05_EEG_ERP/eeg-preprocessing-pipeline-guide/SKILL.md +367 -0
- package/skills/05_EEG_ERP/eeg-preprocessing-pipeline-guide/references/parameter-lookup-tables.md +138 -0
- package/skills/05_EEG_ERP/erp-analysis/SKILL.md +185 -0
- package/skills/05_EEG_ERP/erp-analysis/references/erp-components.md +447 -0
- package/skills/05_EEG_ERP/erp-analysis/references/preprocessing-pipeline.md +277 -0
- package/skills/05_EEG_ERP/erp-analysis/references/statistical-approaches.md +351 -0
- package/skills/05_EEG_ERP/mne-python-guide/SKILL.md +174 -0
- package/skills/05_EEG_ERP/mne-python-guide/references/decoding.md +178 -0
- package/skills/05_EEG_ERP/mne-python-guide/references/io_formats.md +160 -0
- package/skills/05_EEG_ERP/mne-python-guide/references/preprocessing.md +259 -0
- package/skills/05_EEG_ERP/mne-python-guide/references/simulation.md +173 -0
- package/skills/05_EEG_ERP/mne-python-guide/references/source_localization.md +234 -0
- package/skills/05_EEG_ERP/mne-python-guide/references/statistics.md +196 -0
- package/skills/05_EEG_ERP/mne-python-guide/references/time_frequency.md +165 -0
- package/skills/05_EEG_ERP/mne-python-guide/references/visualization.md +175 -0
- package/skills/06_fMRI_Neuroimaging/brain-connectivity-modeler/SKILL.md +317 -0
- package/skills/06_fMRI_Neuroimaging/brain-connectivity-modeler/references/method-implementation-guide.md +116 -0
- package/skills/06_fMRI_Neuroimaging/fmri-glm-analysis-guide/SKILL.md +296 -0
- package/skills/06_fMRI_Neuroimaging/fmri-glm-analysis-guide/references/design-matrix-guide.md +214 -0
- package/skills/06_fMRI_Neuroimaging/fmri-glm-analysis-guide/references/statistical-inference.md +288 -0
- package/skills/06_fMRI_Neuroimaging/fmri-preprocessing-pipeline-guide/SKILL.md +274 -0
- package/skills/06_fMRI_Neuroimaging/fmri-preprocessing-pipeline-guide/references/quality-control.md +336 -0
- package/skills/06_fMRI_Neuroimaging/fmri-preprocessing-pipeline-guide/references/step-by-step-pipeline.md +380 -0
- package/skills/06_fMRI_Neuroimaging/fmri-task-design-guide/SKILL.md +264 -0
- package/skills/06_fMRI_Neuroimaging/fmri-task-design-guide/references/design-optimization-examples.md +114 -0
- package/skills/06_fMRI_Neuroimaging/neural-decoding-analysis/SKILL.md +273 -0
- package/skills/06_fMRI_Neuroimaging/neural-decoding-analysis/references/decoding-methods.md +170 -0
- package/skills/06_fMRI_Neuroimaging/neural-decoding-analysis/references/rsa-guide.md +266 -0
- package/skills/06_fMRI_Neuroimaging/pycortex-guide/SKILL.md +123 -0
- package/skills/06_fMRI_Neuroimaging/pycortex-guide/references/database-subjects.md +179 -0
- package/skills/06_fMRI_Neuroimaging/pycortex-guide/references/dataset-types.md +208 -0
- package/skills/06_fMRI_Neuroimaging/pycortex-guide/references/freesurfer-fmriprep.md +162 -0
- package/skills/06_fMRI_Neuroimaging/pycortex-guide/references/mapping-transforms.md +181 -0
- package/skills/06_fMRI_Neuroimaging/pycortex-guide/references/mni-utils.md +207 -0
- package/skills/06_fMRI_Neuroimaging/pycortex-guide/references/surface-analysis.md +219 -0
- package/skills/06_fMRI_Neuroimaging/pycortex-guide/references/visualization.md +251 -0
- package/skills/07_Computational_Modeling/act-r-model-builder/SKILL.md +297 -0
- package/skills/07_Computational_Modeling/act-r-model-builder/references/model-patterns.md +197 -0
- package/skills/07_Computational_Modeling/act-r-model-builder/references/parameter-table.yaml +204 -0
- package/skills/07_Computational_Modeling/bayesian-cognitive-model-builder/SKILL.md +294 -0
- package/skills/07_Computational_Modeling/bayesian-cognitive-model-builder/references/diagnostics-checklist.md +351 -0
- package/skills/07_Computational_Modeling/bayesian-cognitive-model-builder/references/prior-selection-guide.md +241 -0
- package/skills/07_Computational_Modeling/parameter-recovery-checker/SKILL.md +269 -0
- package/skills/07_Computational_Modeling/parameter-recovery-checker/references/recovery-diagnostics.md +207 -0
- package/skills/08_Computational_Neuroscience/brain-connectivity-modeler/SKILL.md +317 -0
- package/skills/08_Computational_Neuroscience/brain-connectivity-modeler/references/method-implementation-guide.md +116 -0
- package/skills/08_Computational_Neuroscience/neural-decoding-analysis/SKILL.md +273 -0
- package/skills/08_Computational_Neuroscience/neural-decoding-analysis/references/decoding-methods.md +170 -0
- package/skills/08_Computational_Neuroscience/neural-decoding-analysis/references/rsa-guide.md +266 -0
- package/skills/08_Computational_Neuroscience/neural-population-analysis-guide/SKILL.md +305 -0
- package/skills/08_Computational_Neuroscience/neural-population-analysis-guide/references/data-requirements.md +60 -0
- package/skills/08_Computational_Neuroscience/neural-population-analysis-guide/references/method-comparison.md +151 -0
- package/skills/08_Computational_Neuroscience/spiking-network-model-builder/SKILL.md +376 -0
- package/skills/08_Computational_Neuroscience/spiking-network-model-builder/references/hh-parameters.md +117 -0
- package/skills/08_Computational_Neuroscience/spiking-network-model-builder/references/network-regimes.md +130 -0
- package/skills/09_Cellular_Molecular_Neuroscience/calcium-imaging-analysis-guide/SKILL.md +258 -0
- package/skills/09_Cellular_Molecular_Neuroscience/calcium-imaging-analysis-guide/references/indicator-parameters.md +242 -0
- package/skills/09_Cellular_Molecular_Neuroscience/calcium-imaging-analysis-guide/references/pipeline-details.md +211 -0
- package/skills/09_Cellular_Molecular_Neuroscience/optogenetics-protocol-designer/SKILL.md +261 -0
- package/skills/09_Cellular_Molecular_Neuroscience/optogenetics-protocol-designer/references/opsin-catalog.md +124 -0
- package/skills/09_Cellular_Molecular_Neuroscience/optogenetics-protocol-designer/references/stimulation-parameters.md +304 -0
- package/skills/10_Clinical_Neuropsychology/lesion-symptom-mapping-guide/SKILL.md +367 -0
- package/skills/10_Clinical_Neuropsychology/lesion-symptom-mapping-guide/references/disconnection-guide.md +152 -0
- package/skills/10_Clinical_Neuropsychology/lesion-symptom-mapping-guide/references/vlsm-pipeline.md +182 -0
- package/skills/10_Clinical_Neuropsychology/neuropsych-battery-selector/SKILL.md +250 -0
- package/skills/10_Clinical_Neuropsychology/neuropsych-battery-selector/references/deficit-profiles.md +302 -0
- package/skills/10_Clinical_Neuropsychology/neuropsych-battery-selector/references/test-catalog.md +304 -0
- package/skills/11_Developmental_Cognition/infant-looking-time-designer/SKILL.md +345 -0
- package/skills/11_Developmental_Cognition/infant-looking-time-designer/references/age-parameters.yaml +186 -0
- package/skills/12_Social_Cognition/tom-task-selector/SKILL.md +379 -0
- package/skills/12_Social_Cognition/tom-task-selector/references/task-database.md +317 -0
- package/skills/13_Visualization/nature-figure/README.md +442 -0
- package/skills/13_Visualization/nature-figure/SKILL.md +60 -0
- package/skills/13_Visualization/nature-figure/assets/chart-atlas/atlas-01-bar-charts.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/chart-atlas/atlas-02-line-trends.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/chart-atlas/atlas-03-heatmaps.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/chart-atlas/atlas-04-scatter-bubble.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/chart-atlas/atlas-05-radar-polar.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/chart-atlas/atlas-06-distributions.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/chart-atlas/atlas-07-forest-interval.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/chart-atlas/atlas-08-area-stacked.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/chart-atlas/atlas-09-image-plates.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/chart-atlas/atlas-10-network-matrix.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/assets/Dispersion_motivation.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/assets/Dispersion_observation.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/assets/Dispersion_observation_distillation.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/assets/ImmunoStruct_contrastive.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/assets/ImmunoStruct_results_CEDAR.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/assets/ImmunoStruct_results_IEDB.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/assets/ImmunoStruct_schematic.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/assets/RNAGenScape_schematic.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_CellSpliceNet/figures/ablation.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_CellSpliceNet/figures/comparison.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_CellSpliceNet/plot_ablation.py +86 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_CellSpliceNet/plot_comparison.py +109 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Cflows/diffusion_swiss_roll.py +97 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Cflows/figures/diffusion_swiss_roll.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Cflows/figures/fig2_comparison_GeneRegulatory.pdf +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Cflows/figures/fig2_comparison_GeneRegulatory.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Cflows/figures/fig2_comparison_Trajectory.pdf +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Cflows/figures/fig2_comparison_Trajectory.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Cflows/figures/figX_comparison_Ablation.pdf +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Cflows/figures/figX_comparison_Ablation.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Cflows/plot_comparison_Ablation.py +64 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Cflows/plot_comparison_GeneRegulatory.py +74 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Cflows/plot_comparison_Trajectory.py +74 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Dispersion/figures/idea.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Dispersion/figures/illustration.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Dispersion/plot_idea.py +76 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Dispersion/plot_illustration.py +404 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_FPGM/figures/freq_prior.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_FPGM/plot_freq_prior.py +146 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_ImmunoStruct/figures/bars_ablation_Cancer.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_ImmunoStruct/figures/bars_ablation_IEDB.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_ImmunoStruct/figures/bars_comparison_Cancer.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_ImmunoStruct/figures/bars_comparison_IEDB.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_ImmunoStruct/plot_bars.py +216 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_ImmunoStruct/raw_data.py +125 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_RNAGenScape/figures/manifold.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_RNAGenScape/figures/manifold_holes.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_RNAGenScape/figures/results_comparison_optimization.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_RNAGenScape/figures/results_comparison_speed.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_RNAGenScape/figures/results_sweep.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_RNAGenScape/plot_comparison.py +228 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_RNAGenScape/plot_hole_manifold.py +82 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_RNAGenScape/plot_manifold.py +61 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_RNAGenScape/plot_sweep.py +77 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_VIGIL/figures/comparison_posttraining.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_VIGIL/figures/comparison_radar.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_VIGIL/plot_comparison_radar.py +173 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_VIGIL/plot_posttraining.py +82 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_brainteaser/figures/brute_force.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_brainteaser/figures/correctness_by_category.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_brainteaser/figures/correctness_by_subcategory.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_brainteaser/figures/rewriting.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_brainteaser/figures/selfcorrection_math.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_brainteaser/plot_brute_force.py +248 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_brainteaser/plot_correctness_by_category.py +132 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_brainteaser/plot_correctness_by_subcategory.py +131 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_brainteaser/plot_rewriting.py +105 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_brainteaser/plot_selfcorrection_math.py +99 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_ophthal_review/figures/composition_heatmap.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_ophthal_review/figures/trend_by_month.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_ophthal_review/plot_composition.py +81 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_ophthal_review/plot_trend.py +125 -0
- package/skills/13_Visualization/nature-figure/assets/gallery/fig1-material-mechanism-rich.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/gallery/fig2-spatial-imaging-rich.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/gallery/fig3-in-vivo-efficacy-rich.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/gallery/fig4-single-cell-systems-rich.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/gallery/fig5-validation-perturbation-rich.png +0 -0
- package/skills/13_Visualization/nature-figure/evals/evals.json +37 -0
- package/skills/13_Visualization/nature-figure/manifest.yaml +57 -0
- package/skills/13_Visualization/nature-figure/references/api.md +428 -0
- package/skills/13_Visualization/nature-figure/references/backend-selection.md +100 -0
- package/skills/13_Visualization/nature-figure/references/chart-types.md +281 -0
- package/skills/13_Visualization/nature-figure/references/common-patterns.md +350 -0
- package/skills/13_Visualization/nature-figure/references/demos.md +65 -0
- package/skills/13_Visualization/nature-figure/references/design-theory.md +436 -0
- package/skills/13_Visualization/nature-figure/references/figure-contract.md +93 -0
- package/skills/13_Visualization/nature-figure/references/nature-2026-observations.md +112 -0
- package/skills/13_Visualization/nature-figure/references/qa-contract.md +119 -0
- package/skills/13_Visualization/nature-figure/references/r-template-index.md +66 -0
- package/skills/13_Visualization/nature-figure/references/r-workflow.md +161 -0
- package/skills/13_Visualization/nature-figure/references/tutorials.md +251 -0
- package/skills/13_Visualization/nature-figure/static/core/contract.md +29 -0
- package/skills/13_Visualization/nature-figure/static/core/stance.md +37 -0
- package/skills/13_Visualization/nature-figure/static/fragments/backend/python.md +37 -0
- package/skills/13_Visualization/nature-figure/static/fragments/backend/r.md +44 -0
- package/skills/14_Writing/markdown-report-writing/SKILL.md +306 -0
- package/skills/14_Writing/markdown-report-writing/references/compatibility-matrix.md +72 -0
- package/skills/14_Writing/markdown-report-writing/references/templates.md +299 -0
- package/skills/15_Others/neuroimaging-power-guide/SKILL.md +324 -0
- package/skills/15_Others/neuroimaging-power-guide/references/effect-size-lookup-tables.md +102 -0
- package/skills/15_Others/neuroimaging-sample-size-calculator/SKILL.md +330 -0
- package/skills/15_Others/neuroimaging-sample-size-calculator/references/worked-examples.md +220 -0
|
@@ -0,0 +1,517 @@
|
|
|
1
|
+
# Common Statistical Analyses in Cognitive Science
|
|
2
|
+
|
|
3
|
+
This file provides concrete analysis recipes for typical cognitive science designs. Each recipe specifies: when to use it, the model specification, code patterns (R and/or Python), what to report, and common pitfalls.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Recipe 1: Between-Subjects Factorial Design
|
|
8
|
+
|
|
9
|
+
### When to Use
|
|
10
|
+
- Two or more groups (e.g., patient vs. control, training vs. no-training)
|
|
11
|
+
- Dependent variable is continuous (RT, accuracy rate, questionnaire score)
|
|
12
|
+
- Each participant contributes one observation per cell (or an aggregated mean)
|
|
13
|
+
|
|
14
|
+
### Model Specification
|
|
15
|
+
- Factorial ANOVA (Type III sums of squares for unbalanced designs; Langsrud, 2003)
|
|
16
|
+
- Follow up with planned contrasts or post-hoc comparisons
|
|
17
|
+
|
|
18
|
+
### R Code Pattern
|
|
19
|
+
|
|
20
|
+
```r
|
|
21
|
+
library(afex)
|
|
22
|
+
library(emmeans)
|
|
23
|
+
|
|
24
|
+
# Type III ANOVA via afex (handles unbalanced designs correctly)
|
|
25
|
+
model <- aov_ez(id = "subject", dv = "RT_mean",
|
|
26
|
+
between = c("group", "condition"), data = d)
|
|
27
|
+
summary(model) # provides partial eta-squared automatically
|
|
28
|
+
|
|
29
|
+
# Planned contrasts
|
|
30
|
+
emm <- emmeans(model, ~ group | condition)
|
|
31
|
+
contrast(emm, method = "pairwise", adjust = "holm")
|
|
32
|
+
|
|
33
|
+
# Effect sizes for pairwise comparisons
|
|
34
|
+
eff_size(emm, sigma = sigma(model$lm), edf = df.residual(model$lm))
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### What to Report
|
|
38
|
+
- F-statistic, df (numerator, denominator), exact p-value
|
|
39
|
+
- Partial eta-squared with **90% CI** (not 95%; see Steiger, 2004)
|
|
40
|
+
- Post-hoc: estimated marginal means, mean difference, CI, Cohen's d
|
|
41
|
+
- Sample size per cell
|
|
42
|
+
|
|
43
|
+
### Common Pitfalls
|
|
44
|
+
- Using Type I SS with unbalanced designs (inflates effects entered first in the model; Langsrud, 2003)
|
|
45
|
+
- Forgetting to check homogeneity of variance (Levene's test; use Welch ANOVA if violated)
|
|
46
|
+
- Reporting eta-squared instead of partial eta-squared for factorial designs (Richardson, 2011)
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Recipe 2: Within-Subjects Design with Continuous Predictor (LMM)
|
|
51
|
+
|
|
52
|
+
### When to Use
|
|
53
|
+
- Repeated measures over subjects (and potentially items)
|
|
54
|
+
- At least one continuous predictor (e.g., word frequency, stimulus duration, trial number)
|
|
55
|
+
- Trial-level analysis preferred (not condition means)
|
|
56
|
+
|
|
57
|
+
### Model Specification (Barr et al., 2013)
|
|
58
|
+
|
|
59
|
+
Fit the maximal random effects structure justified by the design:
|
|
60
|
+
|
|
61
|
+
```r
|
|
62
|
+
library(lme4)
|
|
63
|
+
library(lmerTest) # for p-values via Satterthwaite approximation
|
|
64
|
+
|
|
65
|
+
# Example: effect of word frequency (continuous) and condition (categorical)
|
|
66
|
+
# on RT in a lexical decision task
|
|
67
|
+
model <- lmer(log_RT ~ frequency_c * condition +
|
|
68
|
+
(1 + frequency_c * condition | subject) +
|
|
69
|
+
(1 + condition | item),
|
|
70
|
+
data = d,
|
|
71
|
+
control = lmerControl(optimizer = "bobyqa",
|
|
72
|
+
optCtrl = list(maxfun = 20000)))
|
|
73
|
+
|
|
74
|
+
summary(model)
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**Key decisions**:
|
|
78
|
+
- Center continuous predictors to reduce collinearity (Schielzeth, 2010)
|
|
79
|
+
- Use **Satterthwaite** or **Kenward-Roger** df approximation for p-values (Luke, 2017). Satterthwaite is the lmerTest default and is adequate for most cognitive science designs.
|
|
80
|
+
- If maximal model fails to converge, follow the simplification hierarchy in `../SKILL.md`
|
|
81
|
+
|
|
82
|
+
### Python Code Pattern
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
import statsmodels.formula.api as smf
|
|
86
|
+
|
|
87
|
+
# Note: statsmodels MixedLM has limited random effects support
|
|
88
|
+
# For complex crossed random effects, use R (lme4) or pymer4
|
|
89
|
+
model = smf.mixedlm("log_RT ~ frequency_c * condition",
|
|
90
|
+
data=d, groups=d["subject"],
|
|
91
|
+
re_formula="~frequency_c * condition")
|
|
92
|
+
result = model.fit()
|
|
93
|
+
print(result.summary())
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### What to Report
|
|
97
|
+
- Fixed effects: estimate (beta), SE, df, t-value, exact p-value
|
|
98
|
+
- Random effects: variance and SD for each random term
|
|
99
|
+
- Model specification (full formula including random effects)
|
|
100
|
+
- Optimizer used and convergence status
|
|
101
|
+
- Effect size: standardized beta or semi-partial R-squared (Rights & Sterba, 2019)
|
|
102
|
+
|
|
103
|
+
### Common Pitfalls
|
|
104
|
+
- Not centering continuous predictors (leads to uninterpretable intercepts and inflated collinearity)
|
|
105
|
+
- Using `anova()` on lmer objects without specifying `type = 3` (default is Type I)
|
|
106
|
+
- Ignoring singular fit warnings (indicates overparameterized random effects; simplify)
|
|
107
|
+
- Using Wald p-values from `summary()` without lmerTest loaded (Wald z-tests are anti-conservative for small samples)
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## Recipe 3: Reaction Time Analysis
|
|
112
|
+
|
|
113
|
+
### When to Use
|
|
114
|
+
- Any experiment measuring response latency
|
|
115
|
+
- Need to handle the characteristic right-skewed, positive-only distribution of RT
|
|
116
|
+
|
|
117
|
+
### Step 1: Data Cleaning
|
|
118
|
+
|
|
119
|
+
```r
|
|
120
|
+
# RT outlier exclusion (Ratcliff, 1993; Whelan, 2008)
|
|
121
|
+
d <- d %>%
|
|
122
|
+
filter(accuracy == 1) %>% # Only correct trials
|
|
123
|
+
filter(RT >= 200) %>% # Remove anticipatory (< 200 ms; Ratcliff, 1993)
|
|
124
|
+
group_by(subject, condition) %>%
|
|
125
|
+
filter(RT <= mean(RT) + 3 * sd(RT), # Remove > 3 SD (Van Selst & Jolicoeur, 1994)
|
|
126
|
+
RT >= mean(RT) - 3 * sd(RT)) %>%
|
|
127
|
+
ungroup()
|
|
128
|
+
|
|
129
|
+
# Report: "X% of correct trials were excluded as RT outliers"
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Step 2: Model Fitting (Recommended: Gamma GLMM)
|
|
133
|
+
|
|
134
|
+
```r
|
|
135
|
+
library(lme4)
|
|
136
|
+
|
|
137
|
+
# Gamma GLMM with identity link (Lo & Andrews, 2015)
|
|
138
|
+
# Results are on the original ms scale
|
|
139
|
+
model <- glmer(RT ~ condition * group +
|
|
140
|
+
(1 + condition | subject) + (1 | item),
|
|
141
|
+
family = Gamma(link = "identity"),
|
|
142
|
+
data = d,
|
|
143
|
+
control = glmerControl(optimizer = "bobyqa",
|
|
144
|
+
optCtrl = list(maxfun = 50000)))
|
|
145
|
+
summary(model)
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
**Alternative: Log-transform + LMM** (simpler, widely accepted):
|
|
149
|
+
|
|
150
|
+
```r
|
|
151
|
+
d$log_RT <- log(d$RT)
|
|
152
|
+
model <- lmer(log_RT ~ condition * group +
|
|
153
|
+
(1 + condition | subject) + (1 | item),
|
|
154
|
+
data = d)
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Python Code Pattern
|
|
158
|
+
|
|
159
|
+
```python
|
|
160
|
+
# Using pymer4 for R-like mixed models in Python
|
|
161
|
+
from pymer4.models import Lmer
|
|
162
|
+
|
|
163
|
+
model = Lmer("log_RT ~ condition * group + (1 + condition | subject) + (1 | item)",
|
|
164
|
+
data=d)
|
|
165
|
+
model.fit()
|
|
166
|
+
print(model.summary())
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### What to Report
|
|
170
|
+
- Outlier exclusion criteria and percentage excluded
|
|
171
|
+
- Model family and link function (if GLMM)
|
|
172
|
+
- Transform applied (if any)
|
|
173
|
+
- Fixed effects on appropriate scale
|
|
174
|
+
- Whether results are consistent across modeling approaches (robustness check)
|
|
175
|
+
|
|
176
|
+
### Common Pitfalls
|
|
177
|
+
- Analyzing mean RT without checking for speed-accuracy tradeoffs (check accuracy across conditions)
|
|
178
|
+
- Not excluding error trials before RT analysis (errors have different RT distributions; Ratcliff, 1993)
|
|
179
|
+
- Using raw RT with ANOVA (violates normality; Ratcliff, 1993)
|
|
180
|
+
- Forgetting that log-transformed effects are multiplicative, not additive (Lo & Andrews, 2015)
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## Recipe 4: Accuracy / Binary Response Analysis
|
|
185
|
+
|
|
186
|
+
### When to Use
|
|
187
|
+
- Dependent variable is binary (correct/incorrect, yes/no, detected/missed)
|
|
188
|
+
- Trial-level analysis (not proportion correct averaged over subjects)
|
|
189
|
+
|
|
190
|
+
### Model Specification
|
|
191
|
+
|
|
192
|
+
```r
|
|
193
|
+
library(lme4)
|
|
194
|
+
|
|
195
|
+
# Logistic mixed-effects model (Jaeger, 2008)
|
|
196
|
+
model <- glmer(accuracy ~ condition * difficulty +
|
|
197
|
+
(1 + condition * difficulty | subject) +
|
|
198
|
+
(1 + condition | item),
|
|
199
|
+
family = binomial(link = "logit"),
|
|
200
|
+
data = d,
|
|
201
|
+
control = glmerControl(optimizer = "bobyqa",
|
|
202
|
+
optCtrl = list(maxfun = 50000)))
|
|
203
|
+
|
|
204
|
+
summary(model)
|
|
205
|
+
|
|
206
|
+
# Odds ratios (exponentiate coefficients)
|
|
207
|
+
exp(fixef(model))
|
|
208
|
+
exp(confint(model, method = "Wald"))
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Python Code Pattern
|
|
212
|
+
|
|
213
|
+
```python
|
|
214
|
+
import statsmodels.formula.api as smf
|
|
215
|
+
|
|
216
|
+
# GEE approach (accounts for within-subject clustering)
|
|
217
|
+
model = smf.gee("accuracy ~ condition * difficulty",
|
|
218
|
+
groups="subject", family=sm.families.Binomial(),
|
|
219
|
+
data=d)
|
|
220
|
+
result = model.fit()
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### What to Report
|
|
224
|
+
- Log-odds (beta) with SE, z-value, p-value
|
|
225
|
+
- Odds ratios with 95% CI (exponentiated coefficients)
|
|
226
|
+
- Model specification and random effects structure
|
|
227
|
+
- If complete separation occurs, note it and consider Firth's penalized likelihood (Heinze & Schemper, 2002)
|
|
228
|
+
|
|
229
|
+
### Common Pitfalls
|
|
230
|
+
- Running ANOVA on proportion correct (violates normality, bounded at 0 and 1; Jaeger, 2008; Dixon, 2008)
|
|
231
|
+
- Using arcsine transform instead of logistic regression (arcsine is outdated; Warton & Hui, 2011)
|
|
232
|
+
- Ignoring complete or quasi-complete separation in logistic models (inflates SE to infinity)
|
|
233
|
+
- Not checking for ceiling/floor effects before analysis (if > **95%** accuracy, logistic models may be unstable)
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## Recipe 5: EEG Cluster-Based Permutation Test
|
|
238
|
+
|
|
239
|
+
### When to Use
|
|
240
|
+
- Comparing ERP waveforms or time-frequency representations across conditions
|
|
241
|
+
- No strong a priori hypothesis about specific time windows or channels
|
|
242
|
+
- Want to control family-wise error across the full spatiotemporal data matrix
|
|
243
|
+
|
|
244
|
+
### Method (Maris & Oostenveld, 2007)
|
|
245
|
+
|
|
246
|
+
1. Compute test statistic (t or F) at each time-channel pair
|
|
247
|
+
2. Threshold at **p < 0.05** (uncorrected) to identify candidate clusters (Maris & Oostenveld, 2007, default)
|
|
248
|
+
3. Sum test statistics within each cluster to get cluster mass
|
|
249
|
+
4. Build null distribution by permuting condition labels **1000-5000** times (Maris & Oostenveld, 2007 recommend minimum 1000; 5000 for publication-quality results)
|
|
250
|
+
5. Compare observed cluster mass to null distribution
|
|
251
|
+
6. Reject cluster if it exceeds the **95th percentile** of null distribution (alpha = 0.05)
|
|
252
|
+
|
|
253
|
+
### Python Code Pattern (MNE-Python)
|
|
254
|
+
|
|
255
|
+
```python
|
|
256
|
+
import mne
|
|
257
|
+
from mne.stats import spatio_temporal_cluster_test
|
|
258
|
+
|
|
259
|
+
# For within-subjects comparison of two conditions
|
|
260
|
+
X = [condition_A_epochs, condition_B_epochs] # shape: (n_subjects, n_times, n_channels)
|
|
261
|
+
|
|
262
|
+
# Adjacency matrix for spatial clustering
|
|
263
|
+
adjacency, ch_names = mne.channels.find_ch_adjacency(epochs.info, ch_type='eeg')
|
|
264
|
+
|
|
265
|
+
# Cluster-based permutation test
|
|
266
|
+
T_obs, clusters, cluster_p_values, H0 = spatio_temporal_cluster_test(
|
|
267
|
+
X,
|
|
268
|
+
n_permutations=5000, # Maris & Oostenveld, 2007; minimum 1000
|
|
269
|
+
threshold=None, # None = use default t-threshold
|
|
270
|
+
tail=0, # Two-tailed
|
|
271
|
+
adjacency=adjacency,
|
|
272
|
+
n_jobs=-1
|
|
273
|
+
)
|
|
274
|
+
|
|
275
|
+
# Identify significant clusters
|
|
276
|
+
significant_clusters = [c for c, p in zip(clusters, cluster_p_values) if p < 0.05]
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### R Code Pattern (permuco)
|
|
280
|
+
|
|
281
|
+
```r
|
|
282
|
+
library(permuco)
|
|
283
|
+
|
|
284
|
+
# Cluster-mass permutation test
|
|
285
|
+
result <- clusterlm(signal ~ condition + Error(subject / condition),
|
|
286
|
+
data = eeg_data,
|
|
287
|
+
np = 5000, # Number of permutations
|
|
288
|
+
multcomp = "clustermass",
|
|
289
|
+
threshold = qt(0.975, df = n_subjects - 1))
|
|
290
|
+
summary(result)
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
### What to Report
|
|
294
|
+
- Cluster-forming threshold
|
|
295
|
+
- Number of permutations
|
|
296
|
+
- For each significant cluster: time range, channels involved, cluster mass, cluster p-value
|
|
297
|
+
- Effect size within the cluster time window (Cohen's d)
|
|
298
|
+
|
|
299
|
+
### Common Pitfalls
|
|
300
|
+
- Interpreting cluster boundaries as precise spatiotemporal localization (clusters indicate EXISTENCE of an effect, not its exact boundaries; Maris & Oostenveld, 2007)
|
|
301
|
+
- Using too few permutations (< **1000**) -- p-values become imprecise (Ernst, 2004)
|
|
302
|
+
- Applying cluster tests to between-subjects designs without accounting for group structure
|
|
303
|
+
- Reporting "no significant clusters" as evidence of no effect (absence of evidence is not evidence of absence; use Bayesian alternatives for null support)
|
|
304
|
+
|
|
305
|
+
---
|
|
306
|
+
|
|
307
|
+
## Recipe 6: fMRI Whole-Brain Analysis
|
|
308
|
+
|
|
309
|
+
### When to Use
|
|
310
|
+
- Task-based fMRI with contrasts between conditions
|
|
311
|
+
- No strong a priori ROI (exploratory)
|
|
312
|
+
|
|
313
|
+
### Correction Approaches
|
|
314
|
+
|
|
315
|
+
| Method | When | Threshold | Source |
|
|
316
|
+
|--------|------|-----------|--------|
|
|
317
|
+
| Cluster-level FWE | Default for most task fMRI | Cluster-forming: **p < 0.001** (uncorrected); cluster-level: **p < 0.05** (FWE) | Eklund et al., 2016 |
|
|
318
|
+
| Voxel-level FWE | Conservative; when precise localization needed | **p < 0.05** (FWE) per voxel | Worsley et al., 1996 |
|
|
319
|
+
| Voxel-level FDR | When many true positives expected | **q < 0.05** | Genovese et al., 2002 |
|
|
320
|
+
| TFCE | Threshold-free alternative | Permutation-based, **p < 0.05** (FWER) | Smith & Nichols, 2009 |
|
|
321
|
+
|
|
322
|
+
### Code Pattern (nilearn + SPM-style)
|
|
323
|
+
|
|
324
|
+
```python
|
|
325
|
+
from nilearn.glm.second_level import SecondLevelModel
|
|
326
|
+
from nilearn.glm import threshold_stats_img
|
|
327
|
+
|
|
328
|
+
# Fit group-level model
|
|
329
|
+
second_level = SecondLevelModel()
|
|
330
|
+
second_level.fit(contrast_images, design_matrix=design)
|
|
331
|
+
|
|
332
|
+
z_map = second_level.compute_contrast(output_type='z_score')
|
|
333
|
+
|
|
334
|
+
# Cluster-level FWE correction
|
|
335
|
+
# cluster-forming threshold: z = 3.1 (~p < 0.001; Eklund et al., 2016)
|
|
336
|
+
thresholded_map, threshold = threshold_stats_img(
|
|
337
|
+
z_map,
|
|
338
|
+
alpha=0.05, # Cluster-level alpha
|
|
339
|
+
height_control='fpr', # False positive rate for cluster forming
|
|
340
|
+
cluster_threshold=10, # Minimum cluster size in voxels
|
|
341
|
+
two_sided=True
|
|
342
|
+
)
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
### What to Report
|
|
346
|
+
- Software, version, and analysis pipeline
|
|
347
|
+
- Cluster-forming threshold (voxel-level p-value)
|
|
348
|
+
- Cluster-level correction method (FWE, FDR, TFCE)
|
|
349
|
+
- For each significant cluster: peak coordinates (MNI), cluster size (voxels and mm3), peak Z/T statistic, anatomical label
|
|
350
|
+
- Smoothing kernel FWHM (typically **6-8 mm** for single-subject, **8 mm** for group; Mikl et al., 2008)
|
|
351
|
+
|
|
352
|
+
### Common Pitfalls
|
|
353
|
+
- Using cluster-forming threshold of **p < 0.01** (inflates false positives to ~70%; Eklund et al., 2016)
|
|
354
|
+
- Not reporting unthresholded statistical maps (share on NeuroVault for transparency; Gorgolewski et al., 2015)
|
|
355
|
+
- Performing ROI analysis after seeing whole-brain results (double-dipping; Kriegeskorte et al., 2009)
|
|
356
|
+
- Using non-parametric methods with too few subjects (permutation tests require minimum **20** subjects for stable results; Winkler et al., 2014)
|
|
357
|
+
|
|
358
|
+
---
|
|
359
|
+
|
|
360
|
+
## Recipe 7: Correlation Analysis with Proper Inference
|
|
361
|
+
|
|
362
|
+
### When to Use
|
|
363
|
+
- Testing association between two continuous variables (e.g., behavioral measure and neural measure)
|
|
364
|
+
- Individual differences analysis
|
|
365
|
+
|
|
366
|
+
### Recommended Approach: Bootstrap CI
|
|
367
|
+
|
|
368
|
+
```r
|
|
369
|
+
library(boot)
|
|
370
|
+
|
|
371
|
+
# Bootstrap correlation with 10,000 resamples (Efron & Tibshirani, 1993)
|
|
372
|
+
boot_cor <- function(data, indices) {
|
|
373
|
+
cor(data[indices, 1], data[indices, 2])
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
results <- boot(data = d[, c("measure1", "measure2")],
|
|
377
|
+
statistic = boot_cor,
|
|
378
|
+
R = 10000)
|
|
379
|
+
|
|
380
|
+
# 95% BCa CI (bias-corrected and accelerated; best bootstrap CI method)
|
|
381
|
+
boot.ci(results, type = "bca")
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
### Python Code Pattern
|
|
385
|
+
|
|
386
|
+
```python
|
|
387
|
+
import numpy as np
|
|
388
|
+
from scipy import stats
|
|
389
|
+
|
|
390
|
+
# Pearson correlation with bootstrap CI
|
|
391
|
+
r, p = stats.pearsonr(d['measure1'], d['measure2'])
|
|
392
|
+
|
|
393
|
+
# Bootstrap 95% CI (10,000 resamples; Efron & Tibshirani, 1993)
|
|
394
|
+
n_boot = 10000
|
|
395
|
+
boot_rs = np.array([
|
|
396
|
+
np.corrcoef(
|
|
397
|
+
np.random.choice(d['measure1'], size=len(d), replace=True),
|
|
398
|
+
np.random.choice(d['measure2'], size=len(d), replace=True)
|
|
399
|
+
)[0, 1] # Note: this is a naive bootstrap; use paired resampling below
|
|
400
|
+
for _ in range(n_boot)
|
|
401
|
+
])
|
|
402
|
+
|
|
403
|
+
# Correct paired bootstrap (resample cases, not variables independently)
|
|
404
|
+
boot_rs = np.array([
|
|
405
|
+
np.corrcoef(d.iloc[idx]['measure1'], d.iloc[idx]['measure2'])[0, 1]
|
|
406
|
+
for idx in [np.random.choice(len(d), size=len(d), replace=True)
|
|
407
|
+
for _ in range(n_boot)]
|
|
408
|
+
])
|
|
409
|
+
|
|
410
|
+
ci_lower, ci_upper = np.percentile(boot_rs, [2.5, 97.5])
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
### What to Report
|
|
414
|
+
- r value, exact p-value, 95% CI (bootstrap BCa preferred)
|
|
415
|
+
- Sample size
|
|
416
|
+
- Scatterplot with regression line and CI band
|
|
417
|
+
- Consider Spearman's rho if normality is violated or outliers are present
|
|
418
|
+
|
|
419
|
+
### Common Pitfalls
|
|
420
|
+
- Reporting only r and p without CI (a "significant" r = 0.30 at N = 50 has CI [0.02, 0.53]; Cumming, 2014)
|
|
421
|
+
- Not checking for influential observations (use Cook's distance; threshold > **4/N**; Cook, 1977)
|
|
422
|
+
- Correlating averaged neural measures with averaged behavioral measures without accounting for reliability (Vul et al., 2009)
|
|
423
|
+
- Computing brain-behavior correlations with N < **100** (likely underpowered; Marek et al., 2022)
|
|
424
|
+
|
|
425
|
+
---
|
|
426
|
+
|
|
427
|
+
## Recipe 8: Mediation Analysis
|
|
428
|
+
|
|
429
|
+
### When to Use
|
|
430
|
+
- Testing whether variable M mediates the effect of X on Y
|
|
431
|
+
- Common in cognitive science: does attention (M) mediate the effect of reward (X) on memory (Y)?
|
|
432
|
+
|
|
433
|
+
### Recommended Approach: Bootstrap Mediation (Preacher & Hayes, 2008)
|
|
434
|
+
|
|
435
|
+
Sobel's test assumes normality of the indirect effect, which is rarely met. Use bootstrap instead.
|
|
436
|
+
|
|
437
|
+
### R Code Pattern
|
|
438
|
+
|
|
439
|
+
```r
|
|
440
|
+
library(mediation)
|
|
441
|
+
|
|
442
|
+
# Step 1: Mediator model
|
|
443
|
+
med_model <- lm(M ~ X + covariates, data = d)
|
|
444
|
+
|
|
445
|
+
# Step 2: Outcome model
|
|
446
|
+
out_model <- lm(Y ~ X + M + covariates, data = d)
|
|
447
|
+
|
|
448
|
+
# Step 3: Bootstrap mediation (Preacher & Hayes, 2008)
|
|
449
|
+
med_result <- mediate(med_model, out_model,
|
|
450
|
+
treat = "X", mediator = "M",
|
|
451
|
+
boot = TRUE,
|
|
452
|
+
sims = 5000) # 5000 bootstrap samples (Preacher & Hayes, 2008)
|
|
453
|
+
summary(med_result)
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
### Python Code Pattern
|
|
457
|
+
|
|
458
|
+
```python
|
|
459
|
+
# Using pingouin for simple mediation
|
|
460
|
+
import pingouin as pg
|
|
461
|
+
|
|
462
|
+
result = pg.mediation_analysis(data=d, x='X', m='M', y='Y',
|
|
463
|
+
n_boot=5000, # Preacher & Hayes, 2008
|
|
464
|
+
seed=42)
|
|
465
|
+
print(result)
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
### What to Report
|
|
469
|
+
- Path coefficients: a (X -> M), b (M -> Y), c (total X -> Y), c' (direct X -> Y)
|
|
470
|
+
- Indirect effect (a * b) with bootstrap 95% CI
|
|
471
|
+
- If CI for indirect effect excludes zero, mediation is supported
|
|
472
|
+
- Proportion mediated (indirect / total effect; but interpret with caution for small effects)
|
|
473
|
+
- Number of bootstrap samples
|
|
474
|
+
|
|
475
|
+
### Common Pitfalls
|
|
476
|
+
- Using Sobel's test instead of bootstrap (violates normality assumption; MacKinnon et al., 2004)
|
|
477
|
+
- Claiming causal mediation from cross-sectional data (mediation implies temporal ordering; Bullock et al., 2010)
|
|
478
|
+
- Not reporting the direct effect (c') alongside the indirect effect
|
|
479
|
+
- Ignoring that mediation with small samples (N < **100**) has very low power (Fritz & MacKinnon, 2007)
|
|
480
|
+
|
|
481
|
+
---
|
|
482
|
+
|
|
483
|
+
## References
|
|
484
|
+
|
|
485
|
+
- Barr, D. J., et al. (2013). Random effects structure for confirmatory hypothesis testing. *Journal of Memory and Language*, 68(3), 255-278.
|
|
486
|
+
- Bullock, J. G., Green, D. P., & Ha, S. E. (2010). Yes, but what's the mechanism? *Journal of Personality and Social Psychology*, 98(4), 550-558.
|
|
487
|
+
- Cook, R. D. (1977). Detection of influential observation in linear regression. *Technometrics*, 19(1), 15-18.
|
|
488
|
+
- Cumming, G. (2014). The new statistics. *Psychological Science*, 25(1), 7-29.
|
|
489
|
+
- Dixon, P. (2008). Models of accuracy in repeated-measures designs. *Journal of Memory and Language*, 59(4), 447-456.
|
|
490
|
+
- Efron, B., & Tibshirani, R. J. (1993). *An Introduction to the Bootstrap*. Chapman and Hall.
|
|
491
|
+
- Eklund, A., et al. (2016). Cluster failure. *PNAS*, 113(28), 7900-7905.
|
|
492
|
+
- Ernst, M. D. (2004). Permutation methods: A basis for exact inference. *Statistical Science*, 19(4), 676-685.
|
|
493
|
+
- Fritz, M. S., & MacKinnon, D. P. (2007). Required sample size to detect the mediated effect. *Psychological Science*, 18(3), 233-239.
|
|
494
|
+
- Genovese, C. R., et al. (2002). Thresholding of statistical maps in functional neuroimaging using the false discovery rate. *NeuroImage*, 15(4), 870-878.
|
|
495
|
+
- Gorgolewski, K. J., et al. (2015). NeuroVault.org: A web-based repository for collecting and sharing unthresholded statistical maps. *Frontiers in Neuroinformatics*, 9, 8.
|
|
496
|
+
- Heinze, G., & Schemper, M. (2002). A solution to the problem of separation in logistic regression. *Statistics in Medicine*, 21(16), 2409-2419.
|
|
497
|
+
- Jaeger, T. F. (2008). Categorical data analysis. *Journal of Memory and Language*, 59(4), 434-446.
|
|
498
|
+
- Kriegeskorte, N., et al. (2009). Circular analysis in systems neuroscience. *Nature Neuroscience*, 12(5), 535-540.
|
|
499
|
+
- Langsrud, O. (2003). ANOVA for unbalanced data: Use Type II instead of Type III sums of squares. *Statistics and Computing*, 13(2), 163-167.
|
|
500
|
+
- Lo, S., & Andrews, S. (2015). To transform or not to transform. *Frontiers in Psychology*, 6, 1171.
|
|
501
|
+
- Luke, S. G. (2017). Evaluating significance in linear mixed-effects models in R. *Behavior Research Methods*, 49(4), 1494-1502.
|
|
502
|
+
- MacKinnon, D. P., et al. (2004). Confidence limits for the indirect effect. *Multivariate Behavioral Research*, 39(1), 99-128.
|
|
503
|
+
- Marek, S., et al. (2022). Reproducible brain-wide association studies require thousands of individuals. *Nature*, 603, 654-660.
|
|
504
|
+
- Maris, E., & Oostenveld, R. (2007). Nonparametric statistical testing of EEG- and MEG-data. *Journal of Neuroscience Methods*, 164(1), 177-190.
|
|
505
|
+
- Mikl, M., et al. (2008). Effects of spatial smoothing on fMRI group inferences. *Magnetic Resonance Imaging*, 26(4), 490-503.
|
|
506
|
+
- Preacher, K. J., & Hayes, A. F. (2008). Asymptotic and resampling strategies for assessing and comparing indirect effects. *Behavior Research Methods*, 40(3), 879-891.
|
|
507
|
+
- Ratcliff, R. (1993). Methods for dealing with reaction time outliers. *Psychological Bulletin*, 114(3), 510-532.
|
|
508
|
+
- Richardson, J. T. E. (2011). Eta squared and partial eta squared. *Educational Research Review*, 6(2), 135-147.
|
|
509
|
+
- Rights, J. D., & Sterba, S. K. (2019). Quantifying explained variance in multilevel models. *Journal of Educational and Behavioral Statistics*, 44(2), 223-263.
|
|
510
|
+
- Schielzeth, H. (2010). Simple means to improve the interpretability of regression coefficients. *Methods in Ecology and Evolution*, 1(2), 103-113.
|
|
511
|
+
- Smith, S. M., & Nichols, T. E. (2009). Threshold-free cluster enhancement. *NeuroImage*, 44(1), 83-98.
|
|
512
|
+
- Steiger, J. H. (2004). Beyond the F test: Effect size confidence intervals. *Psychological Methods*, 9(2), 164-182.
|
|
513
|
+
- Van Selst, M., & Jolicoeur, P. (1994). A solution to the effect of sample size on outlier elimination. *QJEP*, 47A(3), 631-650.
|
|
514
|
+
- Warton, D. I., & Hui, F. K. C. (2011). The arcsine is asinine. *Ecology*, 92(1), 3-10.
|
|
515
|
+
- Whelan, R. (2008). Effective analysis of reaction time data. *The Psychological Record*, 58(3), 475-482.
|
|
516
|
+
- Winkler, A. M., et al. (2014). Permutation inference for the general linear model. *NeuroImage*, 92, 381-397.
|
|
517
|
+
- Worsley, K. J., et al. (1996). A unified statistical approach. *Human Brain Mapping*, 4(1), 58-73.
|