Hi everyone,
I am trying to write a rstan code for parameter calibration. In my calibration model, there is a hazard function h(t) which uses to derive the age t. This model comes from the paper MILC: A microsimulation model of the natural history of lung cancer | International Journal of Microsimulation.
This is how I tried to define the function
functions{
real h_integral(real t, real X, real mu, real nu, real alpha1, real alpha2, real gamma_ns, real alpha_ns, real q, real[] x_r, int[] x_i){
real alpha = alpha_ns * (1 + alpha1* pow(q,alpha2));
real gamma = gamma_ns * (1 + alpha1* pow(q,alpha2));
real B = (-gamma + sqrt(gamma^2 + 4 * alpha * mu))/2;
return (nu * mu * X * (exp((gamma+2*B)*t)-1))/(gamma+B*exp((gamma+2*B)*t)+1);
}
}
Can someone please guide me on a way of defining this function in order to return age t ?
(In R, I defined it as
hr[[i]] <- function(t) (nu * mu * X * (exp((gamma[i]+2*B[i])*t)-1))/(gamma[i]+B[i]*exp((gamma[i]+2*B[i])*t)+1) # Hazard rate
F.hr[[i]] <- function(t) 1-exp(-(integrate(hr[[i]], lower = 0, upper = t)$value)) # CDF function)
)
Thank you
@jonah @Bob_Carpenter Please have a look at this. Thank you all.