You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In #7525 it looks like scale estimated by profile-MLE is better in the gamma case than the default pearson_chi2 based scale estimate.
I think we can add "profile-mle" similar to chi2 and deviance scale estimator.
proposal:
We stick with one parameter LEF, and do not estimate full mle (no joint estimation of scale and mean parameters).
"profile-mle" stays as auxiliary estimation, mean parameters are estimated independently of scale.
This means we are imposing orthogonality in estimation and inference for mean parameters.
(this is different from discussion in #2353 based on quick skimming)
from scipy import optimize
om = optimize.minimize(lambda x: -results.model.loglike(results.params, scale=x), 10)
This will work for families that have a proper scale/dispersion parameter like gamma and gaussian.
MLE scale for Poisson and Binomial is fixed at 1.
Tweedie is more difficult because we don't have full loglike.
Quasi-loglike might be an option.
Adding quasi-loglike for Poisson and similar doesn't make much sense, given that we have robust cov_type (HC, excess dispersion) for inference, and there is no proper distribution for quasi-poisson.
My focus in #7525 was to get a better scale estimate to have a better predictive distribution, and not better inference for mean parameters.
Maybe: Do we want something like REML scale estimate, e.g. degrees of freedom correction?
I don't know how this would work for distributions like gamma.
Aside:
Another option would be to add some minimum distance estimator for the scale, to match a gof statistic for the predictive distribution directly. #7412 That might be less sensitive to heavy tails and outliers.
I'm running something similar in #7778 estimating Gamma model with mean and scale by full MLE.
Scale estimate of full MLE GammaHet model agrees with the profile estimate computed like above.
However, default ("X2") scale estimate in GLM gamma family is around 3 times the mle scale.
Activity
josef-pkt commentedon Jun 30, 2021
implementation:
looks like we have the needed pieces
estimate_scale(self, mu)uses mu and does not need paramsand we have loglike_mu function that can take
muas givenloglike_mu(self, mu, scale=1.)has same scale estimate as minimizing loglike with fixed params in gamma example
_fit_gradienthas scale estimate after optimization_fit_irlsis messier because it uses estimate_scale several times during optimization and not explicitly at the endjosef-pkt commentedon Oct 2, 2021
I'm running something similar in #7778 estimating Gamma model with mean and scale by full MLE.
Scale estimate of full MLE GammaHet model agrees with the profile estimate computed like above.
However, default ("X2") scale estimate in GLM gamma family is around 3 times the mle scale.
josef-pkt commentedon Oct 2, 2021
R library MASS has a function to get the mle estimate based GLM gamma
I can get the same results as they have in the doc example
mine:
problem is optimization needs a good starting value, or I get nans (negative dispersion)
reparameterizing seems to work better
method="trust-constr" doesn't need jacobian
newton methods, other trustxxx require jacobian.
josef-pkt commentedon Oct 2, 2021
This needs more work and reading than what I want to do for #7778. I just wanted a unit test case against GLM-gamma.
some links (that I didn't really read, partial skimming of a few parts)
https://stats.stackexchange.com/questions/58497/using-r-for-glm-with-gamma-distribution
https://www.groups.ma.tum.de/fileadmin/w00ccg/statistics/czado/lec8.pdf
http://civil.colorado.edu/~balajir/CVEN6833/lectures/GammaGLM-01.pdf
question related to get_distribution (separate issues).
MLE scale would provide a better fit and a better gof test for predictive distribution
(assuming gamma is correctly specified. Standard glm might be more robust to misspecification similar to WLS/GLSHet versus MLE)
https://stackoverflow.com/questions/60215085/calculating-scale-dispersion-of-gamma-glm-using-statsmodels
maybe also:
mgcv, gamma with scale heteroscedasticity model for penalized splinesGAMhttps://rdrr.io/cran/mgcv/man/gammals.html