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
{{ message }}
Repository navigation
BUG: GLM scale is not updated when computing null model #9025
GLMResults.null computes null model estimate, but only returns fittedvalues
GLMResults.llnull computes with null fittedvalues, but uses scale from full model
llnull does not seem to be unit tested (except Poisson)
main unit tests are for null_deviance
It looks like null_deviance does not take scale into account at all (scale is fixed at 1.)
There are some unit tests for pseudo-rsquared/prsquared, but I don't see which models are covered by it.
(I never really looked at this for families that have scale != 1)
I have added llnull myself in #1714
I don't see any comments about the implementation, and I was focusing mainly on Poisson, Binomial, scale=1 cases
It looks like Stata glm does not have llnull and related.
I don't find any direct literature for llnull in GLM gamma or similar.
References for pseudo-rsquared in GLM seem to NOT adjust the scale/dispersion coefficient for the null model.
This looks related to the frequent comment in the GLM literature to keep scale/dispersion fixed or at the full model when comparing models with different/nested exog.
Based on stackoverflow/stackexchange question it looks like statistical packages don't have pseudo-R2 for GLM gamma and similar, or no pseudo-R2 at all. (and most questions are for logistic/logit).
Most pseudo-R2 seem to be deviance based, not based on loglike definition. (but I guess scale in deviance remains a similar open question)
It's still open what we should do in GLM.
Having both would be messy because llnull is a cached attribute and we cannot add keyword option.
Aside: gamma pearson scale can be far from the mle scale #7525
(We still don't have multi-link model framework to add a have full GammaModel that would have clean MLE properties)
update
llnull is not in summary
only Pseudo R-squ. (CS) is in summary
no test statistic for comparison to null model is in summary, e.g. no p-value for joint hypothesis that all slope coefficients are zero.
Most likely llnull in GLM is used by very few users.
We have some methods/cached attributes with _scaled post-fix, e.g. llf_scaled. Similarly we could add ll_null options.
While looking at some references/websites for analysis of deviance, I also saw the distinction deviance versus deviance_scaled.
deviance_scaled seems to correspond to loglike difference while deviance multiplies by scale/dispersion coefficient. Standard recommendation seems to be to use scale of largest model (e.g. https://stat.ethz.ch/R-manual/R-patched/library/stats/html/anova.glm.html
"The dispersion estimate will be taken from the largest model, using the value returned by summary.glm."
update2
for poisson QMLE with excess-dispersion
"It is crucial to use the full-model dispersion parameter for both scaled deviances, as the regressor-dependent fit is to be measured, and not that depending on the dispersion parameter"
in
Heinzl, Harald, and Martina Mittlböck. “Pseudo R-Squared Measures for Poisson Regression Models with over- or Underdispersion.” Computational Statistics & Data Analysis, Special Issue in Honour of Stan Azen: a Birthday Celebration, 44, no. 1 (October 28, 2003): 253–71. https://doi.org/10.1016/S0167-9473(03)00062-8.
have a discussion
R2_LRT uses scale (implicitly assumes MLE for mean and scale) likelihood-ratio definition
R2_KL scale cancels in definition if scale is multiplicative (gaussian, gamma), based on Kullback-Leibler divergence and looks similar to deviance (with dispersion coefficient removed from loglike)
They have KL formulas in a table for all our families except Tweedie, so we could add it to the family classes.
Need to check whether or how much it differs from the deviance definition.
Does not include GLM specific pR2 like those based on deviance
no mention of scale
Does not explicitly mention that McFadden pR2 only applies to discrete endog.
Activity
josef-pkt commentedon Oct 10, 2023
I have added llnull myself in #1714
I don't see any comments about the implementation, and I was focusing mainly on Poisson, Binomial, scale=1 cases
It looks like Stata glm does not have llnull and related.
I don't find any direct literature for llnull in GLM gamma or similar.
References for pseudo-rsquared in GLM seem to NOT adjust the scale/dispersion coefficient for the null model.
This looks related to the frequent comment in the GLM literature to keep scale/dispersion fixed or at the full model when comparing models with different/nested exog.
Based on stackoverflow/stackexchange question it looks like statistical packages don't have pseudo-R2 for GLM gamma and similar, or no pseudo-R2 at all. (and most questions are for logistic/logit).
Most pseudo-R2 seem to be deviance based, not based on loglike definition. (but I guess scale in deviance remains a similar open question)
It's still open what we should do in GLM.
Having both would be messy because llnull is a cached attribute and we cannot add keyword option.
Aside: gamma pearson scale can be far from the mle scale #7525
(We still don't have multi-link model framework to add a have full GammaModel that would have clean MLE properties)
update
llnull is not in
summaryonly
Pseudo R-squ. (CS)is insummaryno test statistic for comparison to null model is in
summary, e.g. no p-value for joint hypothesis that all slope coefficients are zero.Most likely llnull in GLM is used by very few users.
We have some methods/cached attributes with
_scaledpost-fix, e.g. llf_scaled. Similarly we could add ll_null options.While looking at some references/websites for analysis of deviance, I also saw the distinction deviance versus deviance_scaled.
deviance_scaled seems to correspond to loglike difference while deviance multiplies by scale/dispersion coefficient. Standard recommendation seems to be to use scale of largest model (e.g. https://stat.ethz.ch/R-manual/R-patched/library/stats/html/anova.glm.html
"The dispersion estimate will be taken from the largest model, using the value returned by summary.glm."
update2
for poisson QMLE with excess-dispersion
"It is crucial to use the full-model dispersion parameter for both scaled deviances, as the regressor-dependent fit is to be measured, and not that depending on the dispersion parameter"
in
Heinzl, Harald, and Martina Mittlböck. “Pseudo R-Squared Measures for Poisson Regression Models with over- or Underdispersion.” Computational Statistics & Data Analysis, Special Issue in Honour of Stan Azen: a Birthday Celebration, 44, no. 1 (October 28, 2003): 253–71. https://doi.org/10.1016/S0167-9473(03)00062-8.
josef-pkt commentedon Oct 11, 2023
more on scale in R2
Colin Cameron, A., and Frank A. G. Windmeijer. “An R-Squared Measure of Goodness of Fit for Some Common Nonlinear Regression Models.” Journal of Econometrics 77, no. 2 (April 1, 1997): 329–42. https://doi.org/10.1016/S0304-4076(96)01818-0.
have a discussion
R2_LRT uses scale (implicitly assumes MLE for mean and scale) likelihood-ratio definition
R2_KL scale cancels in definition if scale is multiplicative (gaussian, gamma), based on Kullback-Leibler divergence and looks similar to deviance (with dispersion coefficient removed from loglike)
They have KL formulas in a table for all our families except Tweedie, so we could add it to the family classes.
Need to check whether or how much it differs from the deviance definition.
josef-pkt commentedon Oct 18, 2023
GLM prsquared was added in #7682 (links to original PR and issue)
UCLA list of pseudo R2 with example Logit
https://stats.oarc.ucla.edu/other/mult-pkg/faq/general/faq-what-are-pseudo-r-squareds/
Does not include GLM specific pR2 like those based on deviance
no mention of scale
Does not explicitly mention that McFadden pR2 only applies to discrete endog.