Currently manyglm is struggling to handle majority of gamma distributed data that I have been attempting to model.
The RtoGlm function easily results in NA's for the z$var.estimator when the gamma family is used (below code from manyglm)....
z <- RtoGlm(modelParam, Y, X, O)
if (any(z$var.est == 0)) {
z$var.estimator = pmax(z$var.est, 1e-06)
z$residuals = (Y - z$fit)/sqrt(z$var.est)
Which stops the model estimation at the above step because any(z$var.est == 0) returns an NA. Not sure why RtoGlm is returning NA's here quite often for gamma data which glm has no issues fitting. Perhaps best to replace NA's with 0 and then run the model replacing the var.estimator appropriately for example below (using tidyverse replace_na).
z <- RtoGlm(modelParam, Y, X, O)
z$var.est[is.na(z$var.est)]<-0
if (any(replace_na(z$var.est,0) == 0)) {
z$var.estimator = pmax(z$var.est, 1e-06)
z$residuals = (Y - z$fit)/sqrt(z$var.est)
Happy to provide data and further discussion if need be. This issue makes it really hard for gamma function to be taken up and applied widely!
Currently manyglm is struggling to handle majority of gamma distributed data that I have been attempting to model.
The RtoGlm function easily results in NA's for the z$var.estimator when the gamma family is used (below code from manyglm)....
Which stops the model estimation at the above step because any(z$var.est == 0) returns an NA. Not sure why RtoGlm is returning NA's here quite often for gamma data which glm has no issues fitting. Perhaps best to replace NA's with 0 and then run the model replacing the var.estimator appropriately for example below (using tidyverse replace_na).
Happy to provide data and further discussion if need be. This issue makes it really hard for gamma function to be taken up and applied widely!
cheers
Ben ben.maslen95@gmail.com