Back to Skills

survival-models

verified

Bayesian survival analysis models including exponential, Weibull, log-normal, and piecewise exponential hazard models with censoring support.

View on GitHub

Marketplace

bayesian-modeling-agent

choxos/BayesianAgent

Plugin

bayesian-modeling

statistics

Repository

choxos/BayesianAgent

plugins/bayesian-modeling/skills/survival-models/SKILL.md

Last Verified

January 21, 2026

Install Skill

Select agents to install to:

Scope:
npx add-skill https://github.com/choxos/BayesianAgent/blob/main/plugins/bayesian-modeling/skills/survival-models/SKILL.md -a claude-code --skill survival-models

Installation paths:

Claude
.claude/skills/survival-models/
Powered by add-skill CLI

Instructions

# Survival Models

## Data Structure

```stan
data {
  int<lower=0> N;
  vector<lower=0>[N] time;      // Observed/censored time
  array[N] int<lower=0,upper=1> event;  // 1=event, 0=censored
  matrix[N, K] X;               // Covariates
}
```

## Exponential Model

### Stan
```stan
parameters {
  real alpha;           // Log baseline hazard
  vector[K] beta;
}
model {
  alpha ~ normal(0, 2);
  beta ~ normal(0, 1);

  for (n in 1:N) {
    real lambda = exp(alpha + X[n] * beta);
    if (event[n] == 1)
      target += exponential_lpdf(time[n] | lambda);
    else
      target += exponential_lccdf(time[n] | lambda);  // Survival
  }
}
```

### JAGS (with censoring)
```
model {
  for (i in 1:N) {
    is.censored[i] ~ dinterval(t[i], t.cen[i])
    t[i] ~ dexp(lambda[i])
    log(lambda[i]) <- alpha + inprod(X[i,], beta[])
  }
  alpha ~ dnorm(0, 0.25)
  for (k in 1:K) { beta[k] ~ dnorm(0, 1) }
}
```

## Weibull Model

### Stan (AFT Parameterization)
```stan
parameters {
  real alpha;                    // Intercept (log scale)
  vector[K] beta;
  real<lower=0> shape;           // Weibull shape
}
model {
  alpha ~ normal(0, 5);
  beta ~ normal(0, 2);
  shape ~ exponential(1);

  for (n in 1:N) {
    real mu = alpha + X[n] * beta;
    if (event[n] == 1)
      target += weibull_lpdf(time[n] | shape, exp(mu));
    else
      target += weibull_lccdf(time[n] | shape, exp(mu));
  }
}
```

### JAGS
```
model {
  for (i in 1:N) {
    is.censored[i] ~ dinterval(t[i], t.cen[i])
    t[i] ~ dweib(shape, lambda[i])
    log(lambda[i]) <- alpha + inprod(X[i,], beta[])
  }
  shape ~ dgamma(1, 0.001)
  alpha ~ dnorm(0, 0.01)
  for (k in 1:K) { beta[k] ~ dnorm(0, 0.01) }
}
```

## Log-Normal Model

### Stan
```stan
parameters {
  real alpha;
  vector[K] beta;
  real<lower=0> sigma;
}
model {
  for (n in 1:N) {
    real mu = alpha + X[n] * beta;
    if (event[n] == 1)
      target += lognormal_lpdf(time[n] | mu, sigma);
    else
      target += lognormal_lccdf(time[n] | mu, sigma);
  }
}
```

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
3612 chars