hierarchical-models

hierarchical-models is a skill for Claude Code from choxos/BiostatAgent. It costs 28 tokens per session (725 once invoked), scanned A, original, MIT.

A collection of patterns for hierarchical, also called multilevel, Bayesian models. These models represent data grouped by things such as schools, hospitals, people, or studies, while allowing groups to share information.

In plain words
What is it for?
Use it to build grouped-data models, random effects, repeated-measurement models, and meta-analysis models with partial pooling.
Why use it?
It helps you choose between treating groups as fully separate, fully identical, or partly related. It also explains centered and non-centered parameterizations, which are different ways to write the same model for better sampling.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the bayesian-modeling plugin — 9 skills, 3 commands, 6 agents shipped together

Good fit Use it to build grouped-data models, random effects, repeated-measurement models, and meta-analysis models with partial pooling.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/choxos/biostatagent/hierarchical-models
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add choxos/BiostatAgent --skill hierarchical-models
Clone the repo
git clone --depth 1 https://github.com/choxos/BiostatAgent

Made for: Claude Code.

Or install bayesian-modeling, the plugin that ships this one along with the rest of its 9 skills, 3 commands, 6 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for hierarchical-models

README.md
[![agentmods](https://agentmods.dev/badge/skills/choxos/biostatagent/hierarchical-models/github.svg)](https://agentmods.dev/skills/choxos/biostatagent/hierarchical-models)
Your own site
<a href="https://agentmods.dev/skills/choxos/biostatagent/hierarchical-models"><img src="https://agentmods.dev/badge/skills/choxos/biostatagent/hierarchical-models/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for hierarchical-models

Your own site · 80×15
<a href="https://agentmods.dev/skills/choxos/biostatagent/hierarchical-models"><img src="https://agentmods.dev/badge/skills/choxos/biostatagent/hierarchical-models.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 28 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 725 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00028 $0.00725
Opus 5 $0.00014 $0.00362
Sonnet 5 $0.00006 $0.00145
Haiku 4.5 $0.00003 $0.00072

Measured 8d ago against content hash 70237fd9d1e9, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

hierarchical-models scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 8d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/bayesian-modeling/skills/hierarchical-models/SKILL.md · 123 lines

How it starts

The opening of the file, as written. The whole thing — 123 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Hierarchical Models

When to Use

  • Nested/grouped data (students in schools, patients in hospitals)
  • Repeated measurements on subjects
  • Meta-analysis with study-level variation
  • Partial pooling between complete pooling and no pooling

Core Concept: Partial Pooling

Group means shrink toward overall mean based on:
- Within-group sample size
- Within-group variance
- Between-group variance

Stan Implementation

Centered Parameterization (Default)

data {
  int<lower=0> N;           // Total observations
  int<lower=0> J;           // Number of groups
  array[N] int<lower=1,upper=J> group;
  vector[N] y;
}
parameters {
  real mu;                  // Population mean
  real<lower=0> tau;        // Between-group SD
  real<lower=0> sigma;      // Within-group SD
  vector[J] theta;          // Group means
}
model {
  // Hyperpriors
  mu ~ normal(0, 10);
  tau ~ cauchy(0, 2.5);
  sigma ~ exponential(1);

  // Group effects
  theta ~ normal(mu, tau);

  // Likelihood
  y ~ normal(theta[group], sigma);
}

Non-Centered Parameterization (Better for weak data/small tau)

parameters {
  real mu;
  real<lower=0> tau;
  real<lower=0> sigma;
  vector[J] theta_raw;      // Standard normal
}
transformed parameters {
  vector[J] theta = mu + tau * theta_raw;
}
model {
  theta_raw ~ std_normal();
  // ... rest same
}

When to use non-centered: Divergences, small tau, few observations per group.

JAGS Implementation

model {
  for (i in 1:N) {
    y[i] ~ dnorm(theta[group[i]], tau.y)
  }

  for (j in 1:J) {
    theta[j] ~ dnorm(mu, tau.theta)
  }

  # Hyperpriors
  mu ~ dnorm(0, 0.0001)
  tau.theta <- pow(sigma.theta, -2)
  sigma.theta ~ dunif(0, 100)
  tau.y <- pow(sigma.y, -2)
  sigma.y ~ dunif(0, 100)
}

Classic Example: Eight Schools

data {
  int<lower=0> J;
  array[J] real y;          // Observed effects
  array[J] real<lower=0> sigma;  // Known SEs
}
parameters {
  real mu;
  real<lower=0> tau;
  vector[J] theta_raw;
}
transformed parameters {
  vector[J] theta = mu + tau * theta_raw;
}
model {
  mu ~ normal(0, 5);
  tau ~ cauchy(0, 5);
  theta_raw ~ std_normal();
  y ~ normal(theta, sigma);
}

Read the full file on GitHub · 123 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 8d ago First seen · 123 lines · 28 tokens per session scan A 70237fd9d1e9

Subscribe to this mod's changes

hierarchical-models is a skill published in the GitHub repository choxos/BiostatAgent (11 stars, last pushed 3mo ago), licensed MIT. It adds 28 tokens to every session and 725 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

imaging-data-commons

Query and download public cancer imaging data from NCI Imaging Data Commons. Invoke for any question about IDC collections, cancer imaging datasets, DICOM data access, radiology (CT, MR, PET) or pathology AI training sets, metadata queries, visualization, or license checks — even when the user doesn't explicitly…

K-Dense-AI/scientific-agent-skills · 75 tokens

lab-hardware-cad

Design custom laboratory hardware as parametric build123d models and export fabrication-ready STEP, STL, and DXF files - microfluidic chips and molds, optomechanical mounts and breadboard adapters, cuvette and microplate holders, tube racks, animal-behavior rigs, and 3D-printed instrument fixtures. Use when a research…

K-Dense-AI/scientific-agent-skills · 106 tokens

pkpd-modeling

Pharmacokinetic and pharmacodynamic modelling and simulation - non-compartmental analysis, compartmental and population PK, PK/PD and exposure-response, TMDD, PBPK orientation, bioequivalence, allometric scaling and first-in-human dose, drug interaction prediction, and Bayesian therapeutic drug monitoring. Use when…

K-Dense-AI/scientific-agent-skills · 273 tokens

diffdock

DiffDock and DiffDock-L molecular docking. Use for protein-small-molecule pose prediction from PDB or sequence plus SMILES/SDF/MOL2, batch docking, virtual screening, and pose-confidence interpretation. Not for binding affinity prediction.

K-Dense-AI/scientific-agent-skills · 51 tokens

latex-posters

Create professional research posters in LaTeX using beamerposter, tikzposter, or baposter. Support for conference presentations, academic posters, and scientific communication. Includes layout design, color schemes, multi-column formats, figure integration, and poster-specific best practices for visual communication.

K-Dense-AI/scientific-agent-skills · 60 tokens

neuropixels-analysis

Analyze Neuropixels extracellular recordings end-to-end with SpikeInterface. Covers loading SpikeGLX/Open Ephys/NWB data, preprocessing, drift/motion correction, Kilosort4 (and CPU) spike sorting, quality metrics, and unit curation (threshold-based, model-based UnitRefine, and AI-assisted visual review). Use when…

K-Dense-AI/scientific-agent-skills · 98 tokens