Description
The function loglike of class Gaussian does not need a distinction of cases since it is expressed in terms of mu, i.e. lin_pred and the link function do not occur. Furthermore, I struggle with two issues:
-
Gaussian().loglike(endog=1, mu=1)results ininf, but it should be a perfectly valid, well-defined log-likelihood. I thinkSSRis already on the log-scale andllf = -np.log(SSR)is just a logarithm applied too often. -
Gaussian().loglike(endog=np.array([1,1]), mu=np.array([0,0]))results in-1.7655121234846454, whereasGaussian(link=L.log).loglike(endog=np.array([1,1]), mu=np.array([0,0]))results in-2.8378770664093453. I think both should give the same value.
I would recommend to completely delete the distinction of cases and only return the always valid
return np.sum(freq_weights * ((endog * mu - mu**2/2)/scale -
endog**2/(2 * scale) - .5*np.log(2 * np.pi * scale)))(Is there a reason for the somehow odd way of writing this formula? Why not ...-0.5*(endog-mu)**2/scale...?)
Activity
josef-pkt commentedon Jan 4, 2017
I need to check why this hasn't been fixed, or what the previous issue for this was/is.
The case with linear link uses the concentrated likelihood like OLS where the scale is replaced by its MLE.
The current definition works for what we are currently using it for, but is not appropriate for some extensions.
josef-pkt commentedon Jan 4, 2017
here is the issue for this #2351 (I haven't checked yet on the status of it.)
josef-pkt commentedon Jan 4, 2017
proposed fix is in #2353 which looks stalled, but I don't remember details right now.
The main issue for the general solution for scale handling is that we don't support yet QMLE as used in statistics with only over or underdispersion but no general heteroscedasticity.
i.e. we can use LR test or compare deviances if we "fix" or estimate the scale appropriately.
but LR test and comparing deviances do not have a standard distribution if there is general misspecified variance or correlation.
lorentzenchr commentedon Jan 4, 2017
Ok. Now it makes more sense to me 😏 Thanks for the PR link.
josef-pkt commentedon Jan 4, 2017
I'm closing this as duplicate of #2351
there are currently 32 open issues related to scale and GLM
https://github.com/statsmodels/statsmodels/search?q=glm+scale+label%3Acomp-genmod+&state=open&type=Issues&utf8=%E2%9C%93
I think what's needed are unit tests against, for example, R's quasi-poisson including dispersion based anova , to get a test case for the overdispersed QMLE.