bbolker / bbmle

maximum likelihood estimation package
GNU General Public License v3.0
25 stars 13 forks source link

provide analytical gradients for formula-based methods #2

Open bbolker opened 7 years ago

mbg-unsw commented 3 months ago

Hi Ben, thank you for bbmle.

I know it's a while since the last change to this project, but could you give a summary of what would be needed to make this work?

We are implementing a MLE fit function for some custom densities using the model formula interface to mle2() and wondered how hard it would be to include analytical gradients.

bbolker commented 3 months ago

Hmm. I had a student working on a version of this for a while here, but the project is at best 2/3 done. (Since we started on that version RTMB has come out, I would probably build that part of the project on RTMB rather than TMB ...

It's not too hard in principle - you can use built-in deriv, or the derivs package, to derive gradients of the parameters of the conditional distribution with respect to the top-level model parameters, and the gradients of the log-likelihood with respect to the parameters of the conditional distribution with respect to its parameters, then use the chain rule to combine them; something similar is done in the fitode package. The plumbing, and maintaining a reasonable level of backward compatibility, is the hard part ...

mbg-unsw commented 3 months ago

Thanks Ben. When I have a couple of hours I will try to read the code and figure out what still needs doing to meet our requirements.