Thanks @bbbales2.
I tried specifying the tolerances to 1e-6 and changed maximum number of steps to 1000, 1e6, 1e7, 2e6 and other values. I still get the same error.
The data I used for this example is generated from the model and the code seems to estimate all parameters except beta. I actually need the code to run with some patient (actual) data. However, when i tried to run the stan code with actual data, I get the following error for some patient data but not for others.
Chain 1: Rejecting initial value:
Chain 1: Error evaluating the log probability at the initial value.
Chain 1: Exception: lognormal_lpdf: Location parameter[2] is nan, but must be finite! (in 'model4adc71ce664f_myModel_fit_upto_omega' at line 131)
Chain 1: Rejecting initial value:
Chain 1: Error evaluating the log probability at the initial value.
Chain 1: Exception: lognormal_lpdf: Location parameter[3] is nan, but must be finite! (in 'model4adc71ce664f_myModel_fit_upto_omega' at line 131)
And a warning after the end
Warning message:
In validityMethod(object) :
The following variables have undefined values: y_pred[1,1],The following variables have undefined values: y_pred[2,1],The following variables have undefined values: y_pred[3,1],The following variables have undefined values: y_pred[4,1],The following variables have undefined values: y_pred[5,1],The following variables have undefined values: y_pred[6,1],The following variables have undefined values: y_pred[7,1],The following variables have undefined values: y_pred[8,1],The following variables have undefined values: y_pred[9,1],The following variables have undefined values: y_pred[10,1],The following variables have undefined values: y_pred[11,1],The following variables have undefined values: y_pred[1,2],The following variables have undefined values: y_pred[2,2],The following variables have undefined values: y_pred[3,2],The following variables have undefined values: y_pred[4,2],The following variables have undefined values: y_pred[5,2],The following variables have undefined [... truncated]
Line 131 has the code
``R
y_hat ~ lognormal(log(y[,5]), std);
where _y_ is computed from ODE.
And _y_pred_ is prediction from ODE in the generated quantities block.
I was wondering if this means sampling for _y_hat_ is not computed as the location parameter, _log(y[ ,5])_ is nan due to the value of _y[, 5]_ being negative?
If this is the case, is there a way STANs ODE solver to compute Nonnegative solutions (like MATLAB)? If not, how do I modify the code so that the error is removed and sampling is computed correctly.
Thanks so much