Skip to content

BUG: Gaussian loglikelihood in GLM #3356

Closed

Description

@lorentzenchr

https://github.com/statsmodels/statsmodels/blob/master/statsmodels/genmod/families/family.py#L564-L573

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:

  1. Gaussian().loglike(endog=1, mu=1) results in inf, but it should be a perfectly valid, well-defined log-likelihood. I think SSR is already on the log-scale and llf = -np.log(SSR) is just a logarithm applied too often.

  2. Gaussian().loglike(endog=np.array([1,1]), mu=np.array([0,0])) results in -1.7655121234846454, whereas Gaussian(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

  1. josef-pkt commented on Jan 4, 2017

    @josef-pkt
    Member

    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.

  2. josef-pkt commented on Jan 4, 2017

    @josef-pkt
    Member

    here is the issue for this #2351 (I haven't checked yet on the status of it.)

  3. josef-pkt commented on Jan 4, 2017

    @josef-pkt
    Member

    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.

  4. lorentzenchr commented on Jan 4, 2017

    @lorentzenchr
    ContributorAuthor

    Ok. Now it makes more sense to me 😏 Thanks for the PR link.

  5. josef-pkt commented on Jan 4, 2017

    @josef-pkt
    Member

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions