bbolker / bbmle

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

Support confidence and prediction intervals in predict method? #16

Open tomwenseleers opened 6 years ago

tomwenseleers commented 6 years ago

For a specific application I would like to be able to calculate confidence and prediction intervals. Would it be hard to incorporate these in the predict method of bbmle?

bbolker commented 6 years ago

hmm. At present AFAICT the predict method (?"predict,mle2-method") doesn't support any kind of intervals (confidence or prediction)? Maybe I'm missing something? Confidence intervals would probably have to be done by delta method or bootstrapping (or much more fancily, by constrained optimization/likelihood profiling). Prediction intervals are kind of hard for non-Gaussian responses; we usually assume multivariate Normal sampling errors of the parameters, and this variation has to be compounded with the variation in the response. For Gaussian responses the combination is Gaussian (we can sum the variance in the prediction and the residual variance, then compute CIs from a Gaussian with predicted mean and var= (predict var + resid var)), but it's harder for non-Gaussian responses ...

tomwenseleers commented 6 years ago

Ha sorry I see now that confidence intervals were also still on the TO DO list... :-) I was indeed thinking that the delta method could be used for that... For prediction intervals - could parametric bootstrapping not be used for that, analogously to how the ciTools provides prediction intervals for GLMs? : https://cran.r-project.org/web/packages/ciTools/vignettes/ciTools-glm-vignette.html

bbolker commented 6 years ago

Yes, something like that would be the way to do it.

I'm in a bit of a quandary over bbmle: it works well enough in its current form, but there are several nice extensions: the current suggestion, and providing analytical gradients (maybe even allowing for a TMB back-end) -- but I'd also like to think about refactoring the code before I started making major/structural improvements.

Know anyone who wants to help :-) ?