lotze / COMPoissonReg

COMPoissonReg R package
GNU General Public License v2.0
8 stars 4 forks source link

glm.cmp: numerical problems with large magnitude covariates #14

Closed andrewraim closed 2 years ago

andrewraim commented 2 years ago

We noticed problems with large magnitude covariates when nu < 1. (For example, even when nu is about 0.5 )

  1. With L-BFGS-B, the optimizer fails after reporting infinite values.
  2. With Nelder-Mead or BFGS, we get results with NaN standard errors.

Is this caused by very large changes in the normalizing constant when relatively small changes are made to beta? Could this be improved by changing to the mean-parameterization of CMP?

TODO: Set up a minimal working example using generated data.

andrewraim commented 2 years ago

It looks like the problem in our particular case was even before computing the normalizing constant. When we compute $\lambda_i = \exp(x_i^\top \beta)$, and one of the elements of $x_i$ has a very large magnitude, relatively small changes to $\beta$ during optimization will move $\lambda_i$ to zero orInf and interfere with the rest of the likelihood calculation.

Some material was added to the vignette (to the end of Section 4) to discuss this issue with large magnitude covariates. There is also some discussion on large counts and moderate-value covariates, which also tends to cause numerical issues.