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
ENH: GLM.estimate_scale add option to choose scaletype #4693
The GLM.estimate_scale method currently uses only the scaletype attribute to select the scale method.
We should add an option so we can override this when we want to compute different scale types from a results instance.
This could be reused for pearson chi2 and deviance scale in results instance,
and to handle excess dispersion for cov_type or LR and score test, even if the underlying scaletype attribute specifies a default.
i.e. scale type is mostly a fit argument, in terms of inference, but a model attribute because we use it to concentrate out scale in loglike and related.
(That part is still the mess because scale is both a model parameter and an auxiliary parameter irrelevant for estimation of mean parameters.)
If I can comment, I think it might also be helpful for estimate_scale to handle OLS (identity normal GLM) because I think the denominator is slightly different in that case.
Activity
josef-pkt commentedon May 30, 2018
scale is a fit_option !
The attribute before calling fit doesn't matter. GLM.fit sets the scale to the value of the keyword argument which is None by default.
I tried to change the scaletype model attribute before calling fit and it didn't have any effect.
josef-pkt commentedon May 30, 2018
another annoying thing
scaletype='x2'should be
scale_type='chi2'josef-pkt commentedon May 30, 2018
fit_constrained does not propagate
scalei.e. model.scaletype is None after calling fit_constrained
thequackdaddy commentedon May 30, 2018
If I can comment, I think it might also be helpful for
estimate_scaleto handle OLS (identity normal GLM) because I think the denominator is slightly different in that case.thequackdaddy commentedon May 30, 2018
For example, scale is divided by
wnobs, notdf_resid.statsmodels/statsmodels/genmod/generalized_linear_model.py
Lines 1559 to 1573 in 17577b3
josef-pkt commentedon May 30, 2018
I thought we had already changed this.
maybe there was a merge conflict
https://github.com/statsmodels/statsmodels/pull/3856/files#diff-724e15f4019b2a24906f6b271d67e370R1538
added the special handling of linear gaussian, which I thought we had dropped in a previous round
josef-pkt commentedon May 30, 2018
Maybe I was thinking about something else
#3856 (comment)
I also opened #4665 when I was reading through parts of the code.
josef-pkt commentedon Jun 1, 2018
I just realized that we have (most likely
*) "stale" incorrect state if scale is set in the fit method.writing an answer https://stackoverflow.com/questions/50641585/understanding-statsmodels-linear-regression/50644360#50644360
I saw that GLM fit(scale=...) has now the same problem as RLM.fit(est_scale=...)
http://www.statsmodels.org/devel/pitfalls.html#repeated-calls-to-fit-with-different-parameters
(
*) I didn't check an example for GLM to show this.see also #3359
josef-pkt commentedon Oct 2, 2021
bump to add scale_type option to GLM.estimate_scale
I wanted to check how much scale estimates differ across scaletype and it requires manipulating the attribute.
also #7526 for adding MLE profile scale
_estimate_x2_scaleis available as separate method, but none fordevscale