You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not entirely sure why this optimization problem is so hard, but I'm suspecting because it's poorly constrained - that is, because it's not too hard to get impossible outcomes by setting the parameters (in)appropriately
in general, returning NA or 'squashing' parameters to legal values (e.g. prevalence = pmin(prevalence, pop_size)) doesn't work optimally, because once the parameters go out of bounds there is no gradient to guide them back to the legal space (one can add a penalty that it (say) a quadratic function of the distance from the edge of the 'legal' space, but that's harder). It's better to constrain the parameters to the legal space or transform to an unconstrained space
I changed from fitting B and Phi to log(B) and log(Phi) (this is different from assuming that something varies linearly on the odds vs the log-odds space - approximately equivalent to fitting with constraints B > 0 and Phi >0)
the Hessian computation is unstable, for reasons I don't completely understanding. mle2 uses numDeriv::hessian() internally rather than optimHess, which I thought would usually be slower but more reliable, but in this case optimHess works better. There isn't currently an mle2 option for changing methods internally (I could add one), but I've added a function for re-computing the Hessian with optimHess and substituting the corresponding covariance matrix in the fit ...
I'm no longer getting the error about Re(ev) - I could adjust mle2here to make it more robust if necessary ...
A few general remarks:
prevalence = pmin(prevalence, pop_size)) doesn't work optimally, because once the parameters go out of bounds there is no gradient to guide them back to the legal space (one can add a penalty that it (say) a quadratic function of the distance from the edge of the 'legal' space, but that's harder). It's better to constrain the parameters to the legal space or transform to an unconstrained spaceBandPhitolog(B)andlog(Phi)(this is different from assuming that something varies linearly on the odds vs the log-odds space - approximately equivalent to fitting with constraints B > 0 and Phi >0)mle2usesnumDeriv::hessian()internally rather thanoptimHess, which I thought would usually be slower but more reliable, but in this caseoptimHessworks better. There isn't currently anmle2option for changing methods internally (I could add one), but I've added a function for re-computing the Hessian withoptimHessand substituting the corresponding covariance matrix in the fit ...Re(ev)- I could adjustmle2here to make it more robust if necessary ...