Survival models with prior_PD = TRUE still depend on the data
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 401
- Forks
- 136
- PR merge metrics
- No merged PRs in 30d
Description
Summary:
A stan_surv model with prior_PD = TRUE still has an implicit prior for prior_intercept that is shifted by a data dependent quantity (the log crude event rate). Even though the model is not conditioning on the data.
Description:
stan_surv has a prior_intercept that is shifted by the log crude event rate to help with numerical stability. See the description in the help file here: https://github.com/stan-dev/rstanarm/blob/ff0a22b90cd70828616f73c39fa54ebb68522040/R/stan_surv.R#L148.
The estimates returned to the user however, are back transformed so that they don't need to worry about that shift.
The thing that is slightly strange is that we still do this shift on the prior even when not conditioning on the data. So changing the data when prior_PD = TRUE and the seed is unchanged will still produce slightly different MCMC samples. See the reproducible steps below.
Reproducible Steps:
library(tidyverse)
library(rstanarm)
# ex data 1
empty_dat1 <- data.frame(
time = 1,
delta = c(1, 0, 1, 1, 0),
trt = factor(letters[1:5])
)
# ex data 2
empty_dat2 <- empty_dat1
empty_dat2$time <- 10
prior_checks1 <- stan_surv(Surv(time, delta) ~ trt, data = empty_dat1,
basehaz = "weibull-aft", prior_PD = TRUE,
prior = normal(0, .5), prior_aux = exponential(1),
prior_intercept = normal(1, 1, autoscale = FALSE),
chains = 4, iter = 2000, seed = 8354)
prior_checks2 <- stan_surv(Surv(time, delta) ~ trt, data = empty_dat2,
basehaz = "weibull-aft", prior_PD = TRUE,
prior = normal(0, .5), prior_aux = exponential(1),
prior_intercept = normal(1, 1, autoscale = FALSE),
chains = 4, iter = 2000, seed = 8354)
prior_checks1
prior_checks2
RStanARM Version:
2.21.2 (feature/survival branch)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the prior-intercept handling described in R/stan_surv.R around the referenced help text, then run the two stan_surv examples with prior_PD = TRUE and the unchanged seed. Trace why the log crude event rate still affects prior draws and verify that changing only time no longer changes the prior-predictive samples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100