Open Tess-LaCoil opened 2 months ago
@dfalster can you please have a look at the implementation of models in the intergration-update branch and check if you believe the maths.
So far I have done analytic solutions for von Bertalanffy based on $$Y(t) = Y{max} + (Y(0) - Y{max}) \exp(-\beta t)$$ and a log-transformation of the power law with $$\log(Y(t)) = \frac{\log(\beta_0)}{\beta_1} + \Bigg(\log(Y(0)) - \frac{\log(\beta_0)}{\beta_1}\Bigg) \exp(-\beta t)$$ where $\beta_0$ is the coeff parameter, $\beta_1$ the power.
For the last estimate of growth when there's no following measurement to compare I have it take the same time gap as the previous observation period and project forward, then use that difference.
von Bertalanffy model is fully updated. Now working on power law.
Numerical solution with step size 0.1
Analytic solution In wrangling the power law model I have come across what I think is an error in the maths. I'm going to ask a friend to double check my solution but the RK4 model reliably gives the correct sizes over time and parameters while the analytic solution does not and I have been unable to determine why.
The current models are on the integration-update branch, implemented as separate stan files in the inst/stan/ directory. @dfalster can you please look at the power_single_ind_analytic.stan file and see if you believe the maths? To run it, save a duplicate under the name power_single_ind.stan and then use the usual workflow.
After some additional wrangling and checking of the solution, what breaks the numerical methods for vB doesn't appear in the power law model because the coefficient on Y is not negative. It may be preferable to sidestep the problems in the analytic solution by just using the numerical method instead as it reliably gives good estimates.
Power law parameter estimates are robus to changes in the step size.
In order to avoid pathologies associated with particular numerical methods: