Install
$ agentstack add skill-choxos-biostatagent-stan-fundamentals ✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ✓ Environment & secrets No
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
Verified badge
Passed review? Show it. Paste this badge into your README, it links to the public security report.
Reliability & compatibility
Declared compatibility
Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.
We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.
How agent discovery & health will work →About
Stan Fundamentals
When to Use This Skill
- Writing new Stan models from scratch
- Understanding Stan program structure
- Learning Stan syntax and conventions
- Translating models from other languages to Stan
- Optimizing existing Stan code
Program Structure
Stan models have up to 7 blocks in this exact order:
functions { } // User-defined functions
data { } // Input data declarations
transformed data { } // Data preprocessing
parameters { } // Model parameters
transformed parameters { } // Derived parameters
model { } // Log probability
generated quantities { } // Posterior predictions
All blocks are optional. Empty string is valid (but useless) Stan program.
Type System Quick Reference
Scalars
int n; // Integer
real x; // Real number
complex z; // Complex number
Vectors and Matrices
vector[N] v; // Column vector
row_vector[N] r; // Row vector
matrix[M, N] A; // Matrix
Arrays (Modern Syntax)
array[N] real x; // 1D array of reals
array[M, N] int y; // 2D array of integers
array[J] vector[K] theta; // Array of vectors
Constrained Types
real sigma; // Non-negative
real p; // Probability
simplex[K] theta; // Sums to 1
ordered[K] c; // Ascending
corr_matrix[K] Omega; // Correlation
cov_matrix[K] Sigma; // Covariance
cholesky_factor_corr[K] L_Omega; // Cholesky correlation
Key Distributions
Continuous (SD parameterization!)
y ~ normal(mu, sigma); // sigma is SD
y ~ student_t(nu, mu, sigma);
y ~ cauchy(mu, sigma);
y ~ exponential(lambda);
y ~ gamma(alpha, beta);
y ~ beta(a, b);
y ~ lognormal(mu, sigma);
Discrete
y ~ bernoulli(theta);
y ~ binomial(n, theta);
y ~ poisson(lambda);
y ~ neg_binomial_2(mu, phi);
y ~ categorical(theta);
Multivariate
y ~ multi_normal(mu, Sigma); // Sigma is COVARIANCE
y ~ multi_normal_cholesky(mu, L);
y ~ lkj_corr(eta);
Essential Patterns
Vectorization
// GOOD - Efficient
y ~ normal(mu, sigma);
// BAD - Slow
for (n in 1:N) y[n] ~ normal(mu[n], sigma);
Non-Centered Parameterization
parameters {
vector[J] theta_raw;
}
transformed parameters {
vector[J] theta = mu + tau * theta_raw;
}
model {
theta_raw ~ std_normal();
}
Target Syntax
// These are equivalent:
y ~ normal(mu, sigma);
target += normal_lpdf(y | mu, sigma);
Common Priors
// Location parameters
mu ~ normal(0, 10);
// Scale parameters
sigma ~ exponential(1);
sigma ~ cauchy(0, 2.5); // half-Cauchy when sigma has lower=0
// Probabilities
theta ~ beta(1, 1); // Uniform on (0,1)
// Regression coefficients
beta ~ normal(0, 2.5);
// Correlation matrices
Omega ~ lkj_corr(2); // eta=2 favors identity
R Integration (cmdstanr)
library(cmdstanr)
mod 400
- [ ] ESS_tail > 400
- [ ] Zero divergences
- [ ] Not hitting max_treedepth
- [ ] Prior predictive produces sensible values
- [ ] Posterior predictive matches data pattern
## Key Differences from BUGS
| Feature | Stan | BUGS/JAGS |
|---------|------|-----------|
| Normal | `normal(mu, sigma)` SD | `dnorm(mu, tau)` precision |
| MVN | `multi_normal(mu, Sigma)` cov | `dmnorm(mu, Omega)` precision |
| Execution | Sequential (order matters) | Declarative (order doesn't matter) |
| Sampling | HMC/NUTS | Gibbs/Metropolis |
## Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- **Author:** [choxos](https://github.com/choxos)
- **Source:** [choxos/BiostatAgent](https://github.com/choxos/BiostatAgent)
- **License:** MIT
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet, be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.