AgentStack
SKILL verified MIT Self-run

Bugs Fundamentals

skill-choxos-biostatagent-bugs-fundamentals · by choxos

Foundational knowledge for writing BUGS/JAGS models including precision parameterization, declarative syntax, distributions, and R integration. Use when creating or reviewing BUGS/JAGS models.

No reviews yet
0 installs
12 views
0.0% view→install

Install

$ agentstack add skill-choxos-biostatagent-bugs-fundamentals

✓ scanned · ✓ verified — works with Claude Code, Cursor, and more.

Security review

✓ Passed

No 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.

Are you the author of Bugs Fundamentals? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

BUGS/JAGS Fundamentals

When to Use This Skill

  • Writing new WinBUGS or JAGS models
  • Understanding BUGS declarative syntax
  • Converting between BUGS and Stan
  • Integrating with R via R2jags or R2WinBUGS

Model Structure

BUGS uses a single declarative block where order doesn't matter:

model {
  # Likelihood (order doesn't matter)
  for (i in 1:N) {
    y[i] ~ dnorm(mu[i], tau)
    mu[i] = threshold
eq <- equals(y, 0)           # 1 if y == 0

Common Priors

# Vague normal (variance = 1000)
alpha ~ dnorm(0, 0.001)

# Half-Cauchy on SD (via uniform)
sigma ~ dunif(0, 100)
tau <- pow(sigma, -2)

# Vague gamma on precision
tau ~ dgamma(0.001, 0.001)

# Correlation matrix
Omega ~ dwish(I[,], K + 1)

R Integration

R2jags (Recommended)

library(R2jags)

jags.data <- list(N = 100, y = y, x = x)
jags.params <- c("alpha", "beta", "sigma")
jags.inits <- function() {
  list(alpha = 0, beta = 0, tau = 1)
}

fit <- jags(
  data = jags.data,
  inits = jags.inits,
  parameters.to.save = jags.params,
  model.file = "model.txt",
  n.chains = 4,
  n.iter = 10000,
  n.burnin = 5000
)

print(fit)
fit$BUGSoutput$summary

R2WinBUGS (Windows)

library(R2WinBUGS)

fit <- bugs(
  data = bugs.data,
  inits = bugs.inits,
  parameters.to.save = bugs.params,
  model.file = "model.txt",
  n.chains = 3,
  n.iter = 10000,
  bugs.directory = "C:/WinBUGS14/"
)

Key Differences from Stan

| Feature | BUGS/JAGS | Stan | |---------|-----------|------| | Normal | dnorm(mu, tau) precision | normal(mu, sigma) SD | | MVN | dmnorm(mu, Omega) precision | multi_normal(mu, Sigma) cov | | Syntax | Declarative (DAG) | Imperative (sequential) | | Blocks | Single model{} | 7 optional blocks | | Sampling | Gibbs + Metropolis | HMC/NUTS | | Discrete | Direct sampling | Marginalization required |

Common Errors

  1. Using SD instead of precision: dnorm(0, 1) means variance=1, NOT SD=1
  2. Wrong binomial order: dbin(p, n) not dbin(n, p)
  3. Missing initial values: Provide inits for complex models
  4. Invalid parent values: Check for NA/NaN in data

Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet — be the first.

Versions

  • v0.1.0 Imported from the upstream source.