Stabilising survival model integrand for use in integrate_1d

Here’s a reprex and some revised Stan code. Also I think we’re getting off topic here and I should probably post this information somewhere else.

library(rstan)
library(cmdstanr)

prefit_psi_step <- stan_model(
  "submodel-two-psi-step.stan"
)

cmd_prefit_psi_step <- cmdstan_model(
  "submodel-two-psi-step.stan"
)

psi_step_data <- list(n_patients = 16L, baseline_measurement = c(-0.935695521120025, 
-2.12761603089136, -0.876325387003469, 0.931350429946891, 0.422731897638725, 
-1.30375210258178, 1.85158267797611, -0.289448169455647, 0.325903831278964, 
-1.2757407765375, 1.58794213975781, 1.59307842403321, -0.0584097720952887, 
1.80357260097634, -2.30428952138529, 0.655115279462301), log_crude_event_rate = 3.17644992456411, 
    event_time = c(3.88219330975027, 17.5607555174655, 8.14097264393642, 
    0.874471581905152, 0.875182734259227, 1.39419961264823, 1.13884032148061, 
    43.2464501785995, 1.01706489078387, 19.9898187874785, 1.1633097689907, 
    0.769646147838224, 9.44064603011716, 1.49631432330604, 22.3176589776014, 
    1.04117377075568), long_beta = structure(c(0.931386697031433, 
    0.865137767714317, 0.973505472094455, 0.880036367203131, 
    0.935119573179882, 0.910063465843014, 1.34798084760589, 0.919172808940375, 
    1.01141192543184, 0.890762064216965, 1.05317362916398, 1.22448828904961, 
    0.843895992304378, 0.872039892731229, 0.854977513431319, 
    0.958580645647191, -0.511886090506962, 0.660548718396229, 
    1.21418574954005, 1.57400898285864, 1.48149041414514, 0.176628427838126, 
    1.46367493523126, 0.437751542691176, 1.21862018076306, 0.117778624770988, 
    0.988969750444339, 0.940177413736985, 0.142150803498799, 
    1.96856722070831, 0.366973246331529, 1.02998350811324), .Dim = c(16L, 
    2L)))

res <- sampling(
  prefit_psi_step,
  data = psi_step_data,
  chains = 1,
  warmup = 100,
  iter = 110,
  control = list(adapt_delta = 0.9)
)

res <- cmd_prefit_psi_step$sample(
  data = psi_step_data,
  chains = 1,
  iter_warmup = 100,
  iter_sampling = 110,
  adapt_delta = 0.9
)

submodel-two-psi-step.stan (2.7 KB)

2 Likes