survival-models
Bayesian survival analysis models including exponential, Weibull, log-normal, and piecewise exponential hazard models with censoring support.
What this skill does
# 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);
}
}
```
## Piecewise Exponential (Cox-like)
### Stan
```stan
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;
}
}
```
## Frailty Model (Random Effects)
### Stan
```stan
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
```stan
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));
}
```
## Interpretation
- **Weibull shape**: <1 decreasing hazard, =1 constant (exponential), >1 increasing
- **HR**: Hazard ratio (multiplicative effect on hazard)
- **AFT**: Accelerated failure time (multiplicative effect on survival time)
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.