Hi @amas0 ,
I am here again with a mess. I am trying to use algebra_solver_newton
described in section 9.1 in stan functions reference to solve user defined CDF function for t. This is what I tried in functions block and model block, but it seems like there are lots of errors when calling to the newton algebraic solver in the model block.
functions{
vector CDF_func(vector t, vector theta, real[] x_r, // Data (real)
int[] x_i){
real NC = theta[1];
real mu = theta[2];
real nu = theta[2];
real alpha1 = theta[3];
real alpha2 = theta[4];
real gamma_ns = theta[5];
real alpha_ns = theta[6];
real q = theta[7]; // CPD
vector[1] CDF;
real alpha = alpha_ns * (1 + alpha1* pow(q,alpha2));
real gamma = gamma_ns * (1 + alpha1* pow(q,alpha2)); // alpha  beta  mu , beta  apoptosis rate of initiated cells, alpha  division rate of initiated cells
real B = (gamma + sqrt(gamma^2 + 4 * alpha * mu))/2;
CDF = 1  (1/(gamma + 2*B))*(exp(t)*(gamma^((nu*mu*NC)^2/(B*(gamma+B)^2)) + (B^((nu*mu*NC)^2/(B*(gamma+B)^2)))) + exp((((gamma2*B)/B) + 1)*(nu*mu*NC/(gamma+B))*t)*B^((nu*mu*NC)/(gamma*B+B^2)));
return CDF;
}
}
model{
.
.
.
for(i in 1:n){
real q = df[i,3];
if(df[i,2] == 0){ // for females
tmal[i] = algebra_solver_newton(CDF_func, {15}, {NC, nu_fns, alpha1f, alpha2f, gamma_fns, alpha_fns, q}, {0.0}, {0});
Vmal[i] = exp((s/m) * (1exp((m * tmal[i])))) * V_0;
}
}
.
.
.
}
Errors:
Illtyped arguments supplied to function 'algebra_solver_newton'. Available signatures:
((vector, vector, data array[] real, data array[] int) => vector, vector, vector, data array[] real, data array[] int) => vector
((vector, vector, data array[] real, data array[] int) => vector, vector, vector, data array[] real, data array[] int, data real, data real, data real) => vector

Instead supplied arguments of incompatible type: (vector, vector, array[] real, array[] int) => vector, array[] int, array[] real, array[] real, array[] int
Can someone kindly suggest how can I make it works for me? @bbbales2 can you help me here?
Thank you.