Bayesian survival analysis models including exponential, Weibull, log-normal, and piecewise exponential hazard models with censoring support.
/plugin marketplace add choxos/BiostatAgent/plugin install bayesian-modeling@biostat-agentThis skill inherits all available tools. When active, it can use any tool Claude has access to.
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
}
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
}
}
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) }
}
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));
}
}
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) }
}
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);
}
}
data {
int<lower=0> N;
int<lower=0> J; // Number of intervals
vector[J] cuts; // Cut points
matrix[N, J] d; // Time in each interval
array[N] int<lower=0,upper=1> event;
array[N] int<lower=1,upper=J> interval; // Event interval
matrix[N, K] X;
}
parameters {
vector[J] log_baseline; // Log baseline hazard per interval
vector[K] beta;
}
model {
log_baseline ~ normal(0, 2);
beta ~ normal(0, 1);
for (n in 1:N) {
real log_hazard = log_baseline[interval[n]] + X[n] * beta;
// Contribution from all intervals
for (j in 1:J)
target += -d[n,j] * exp(log_baseline[j] + X[n] * beta);
// Event contribution
if (event[n] == 1)
target += log_hazard;
}
}
data {
int<lower=0> N;
int<lower=0> G; // Number of groups
array[N] int<lower=1,upper=G> group;
// ... rest of survival data
}
parameters {
real alpha;
vector[K] beta;
real<lower=0> shape;
vector[G] frailty_raw; // Non-centered
real<lower=0> sigma_frailty;
}
transformed parameters {
vector[G] frailty = sigma_frailty * frailty_raw;
}
model {
sigma_frailty ~ exponential(1);
frailty_raw ~ std_normal();
for (n in 1:N) {
real mu = alpha + X[n] * beta + frailty[group[n]];
// ... Weibull likelihood with censoring
}
}
generated quantities {
// Hazard ratio for 1-unit increase in X[,1]
real HR = exp(beta[1]);
// Median survival at X=0
real median_survival = exp(alpha) * pow(log(2), 1/shape);
// Survival function at time t=1
array[N] real S_1;
for (n in 1:N)
S_1[n] = exp(-pow(1 / exp(alpha + X[n] * beta), shape));
}
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.