jaredhuling / fastglm

Fast glm fitting via RcppEigen
https://jaredhuling.org/fastglm/
56 stars 14 forks source link

vcov.fastglm - Variance covariance matrix of fitted parameters #10

Open legaultmarc opened 3 years ago

legaultmarc commented 3 years ago

Hello,

I was wondering if you had any pointer on how you would estimate the variance-covariance matrix of the fitted parameters (like vcov.glm).

I would be willing to contribute a PR, but would need a little bit of help getting started.

Thank you for this awesome project!

jaredhuling commented 3 years ago

In general, with glms, the estimated variance-covariance matrix comes from $(X'WX)^{-1}$ from the last iteration of IRLS. Since the fastglm package offers different methods for solving the weighted least squares problem at each step (each method is a different decomposition such a Cholesky, QR, etc), each one would require slightly different code for returning the appropriate matrix inverse. The WLS solving happens in src/glm.h from lines 295 to 424. Some partial clues towards how this can be done are in lines 426-473. The matrix decomposition documentation for Eigen will also be helpful decomposition catelog and lin alg tutorial