Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions posterior_database/bibliography/references.bib
Original file line number Diff line number Diff line change
Expand Up @@ -361,3 +361,14 @@ @article{pagani2022
publisher={Wiley},
doi={10.1111/sjos.12532}
}

@article{mcgilchrist1991regression,
author = {McGilchrist, C. A. and Aisbett, C. W.},
title = {Regression with Frailty in Survival Analysis},
journal = {Biometrics},
year = {1991},
volume = {47},
number = {2},
pages = {461--466},
doi = {10.2307/2532138}
}
22 changes: 22 additions & 0 deletions posterior_database/data/data-raw/kidney_data/kidney_data.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Builds the kidney_data list used by the frailty_cox_replication model
# from the kidney dataset of the R survival package.

k <- survival::kidney
k <- k[order(k$time), ]

# Covariates as in McGilchrist & Aisbett (1991): age in years, sex (1 = male, 2 = female),
# 0/1 indicators for disease types GN, AN and PKD (Other is the baseline).
X <- cbind(age = k$age,
sex = k$sex,
GN = as.integer(k$disease == "GN"),
AN = as.integer(k$disease == "AN"),
PKD = as.integer(k$disease == "PKD"))

kidney_data <- list(N = nrow(k),
M = length(unique(k$id)),
P = ncol(X),
t = k$time,
D = k$status,
pid = k$id,
X = X,
sigma = 1)
Binary file added posterior_database/data/data/kidney_data.json.zip
Binary file not shown.
17 changes: 17 additions & 0 deletions posterior_database/data/info/kidney_data.info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "kidney_data",
"title": "Kidney Survival Data",
"description": "Data on kidney catheter infections for 38 patients and their recurrence times. From the survival package in R",
"keywords": [
"survival",
"kidney",
"infection"
],
"urls": [
"https://search.r-project.org/CRAN/refmans/survival/html/kidney.html"
],
"references": ["mcgilchrist1991regression"],
"added_by": "Isac Kanon, Julius Searancke, Thauri Dattadeen",
"added_date": "2026-11-01",
"data_file": "data/data/kidney_data.json"
}
24 changes: 24 additions & 0 deletions posterior_database/models/info/frailty_cox_replication.info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "frailty_cox_replication",
"title": "Replication of Cox Frailty Partial Likelihood including Frailties",
"description": "Cox proportional hazards model with a shared log-normal frailty per patient and a flat prior on the regression coefficients. Replication of McGilchrist and Aisbett (1991).",
"keywords": [
"hazard regression",
"frailty",
"survival analysis",
"regression"
],
"urls": [
"https://doi.org/10.2307/2532138",
"https://search.r-project.org/CRAN/refmans/survival/html/kidney.html"
],
"references": ["mcgilchrist1991regression"],
"added_by": "Isac Kanon, Julius Searancke, Thauri Dattadeen",
"added_date": "2026-11-01",
"model_implementations": {
"stan": {
"model_code": "models/stan/frailty_cox_replication.stan",
"stan_version": ">=2.36.0"
}
}
}
37 changes: 37 additions & 0 deletions posterior_database/models/stan/frailty_cox_replication.stan
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Bayesian Cox model with shared Gaussian frailty (McGilchrist & Aisbett, 1991)
// Requires data sorted by ascending time t.
data {
int<lower=1> M, N, P; // # of patients, total obs, # of covariates
vector[N] t; // gap times, sorted ascending
array[N] int<lower=0, upper=1> D; // 1 = uncensored, 0 = censored
array[N] int<lower=1, upper=M> pid; // patient_id for each interval
matrix[N, P] X; // covariates- age,sex,disease type
real<lower=0> sigma; // fixed log-frailty sd
}
parameters {
vector[P] beta; // regression coeffs
sum_to_zero_vector[M] u; // log-frailties restriction [1'u = 0]
}
transformed parameters {
vector[N] eta = X * beta + u[pid]; // linear substitution
}
model {
// Priors
u ~ normal(0, sigma); // log-frailties ~ normal(0, sigma^2)

// Cox's partial likelihood: numerator sums the patient's intervals still at risk
for (k in 1:N)
if (D[k] == 1) {
real num = negative_infinity();
for (j in k:N)
if (pid[j] == pid[k])
num = log_sum_exp(num, eta[j]);
target += num - log_sum_exp(eta[k:N]);
}
}
generated quantities {
vector[M] Z = exp(u); // Frailties
real sigma2 = dot_self(u) / (M - 1); // sigma^2 = u'u/(M-1)
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "kidney_data-frailty_cox_replication",
"keywords": ["hazard regression", "frailty", "survival analysis", "survival", "kidney", "infection"],
"urls": ["https://doi.org/10.2307/2532138", "https://search.r-project.org/CRAN/refmans/survival/html/kidney.html"],
"model_name": "frailty_cox_replication",
"data_name": "kidney_data",
"reference_posterior_name": null,
"references": ["mcgilchrist1991regression"],
"dimensions": {
"beta": 5,
"u": 37
},
"added_by": "Isac Kanon, Julius Searancke, Thauri Dattadeen",
"added_date": "2026-11-01"
}