Survival model for readout/interval data

Hi, I have readout/interval data for a survival model I want to build. If I were using MLE, I would take the difference of the CDF. So is this how I would generally proceed in Stan to get the difference of the CDF?

 data {

  int T; 
  int N_t[T];



  real<lower=0> a;
  real<lower=0> b;


for (i in 1:T){

  target += N_t[i] *log(weibull_cdf(t[i] , a, b) - weibull_cdf(t[i-1] , a, b));


I know I still need to make sure the indices are correct…I will sort that out later.

Thanks in advance.

If you want to test that Stan is doing the right thing, there are a few options.

You can print out the variables that you’re curious about. So you could do something like:

real tmp = weibull_cdf(t[i], a, b) - weibull_cdf(t[i-1], a, b);
print(tmp, t[i], t[i - 1], a, b);

And then see what prints out and evaluate it elsewhere.

You can use rstan’s expose_stan_functions (docs here) and write a function that computes the thing you want to compute.

You can define the thing you want to know about in the generated quantities block.

One of those will probably work for this!