Skip to content

DOC: Improve documentation about glm #2959 - #3353

Closed
lorentzenchr wants to merge 2 commits into
statsmodels:masterfrom
lorentzenchr:master
Closed

lorentzenchr wants to merge 2 commits into
statsmodels:masterfrom
lorentzenchr:master

Conversation

@lorentzenchr

Copy link
Copy Markdown
Contributor

I added a short section "Technical Documentation" to the glm documentation and the distribution function to the docstring of the family class NegativeBinomial.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 88.026% when pulling 621f37e on lorentzenchr:master into 42d2f57 on statsmodels:master.

@josef-pkt

Copy link
Copy Markdown
Member

@lorentzenchr Thanks for working on this.

Looks good overall, but the latex is difficult to read and I will need to check again when I see a rendered version.

One clarification question: What are the weights w? From which reference did you take the formulas?
We will get several types of weights and currently only have frequency weights.
see below (*)

Things that would be good to add

  • translation greek -> statsmodels: Some of the usual greek letters have english names in the code, e.g. dispersion parameter phi is attribute scale, we kept mu for mean, and I think but I'm not sure that theta is the linear prediction linpred. i.e. mu = g^{-1} (theta) or g(mu) = theta theta = x * beta

  • add offset and exposure

(*) IIUC, R uses weights as variance weights for Binomial when the endog y is rescaled to a proportion.
We currently allow Binomial only to be specified as a count distribution, i.e. endog is Bernoulli {0,1} dummy/indicator array or counts for (good, bad) or [success, failure]

@lorentzenchr

Copy link
Copy Markdown
Contributor Author

@josef-pkt Thank you for your fast reply.

  1. Translation of greeks: I would recommend to let the greeks live 😄 as they are standard. Although their meaning is mentioned in the text, one could add a short list with their code correspondents (μ is mu, φ is scale, η=x'β is lin_pred, θ is not used in code, ...)

  2. Offsets are part of the linear predictor. Therefore I did not mention them.

  3. Exposure is linked to weights, see next point.

  4. The definition I gave includes weights w, see e.g. Regression
    Models, Methods and Applications
    from Fahrmeir, Kneib, Lang, Marx. The famous monograph of McCullagh and Nelder about GLMs has even a scale function a(φ) instead of just φ, but it later specifies it to precisely the definition I gave. I think a clear definition of the model might also clarify the need for weights. I'm not sure where I should comment: weights: repeat versus mean/variance in LEF family #2840, SUMM: weights - which kinds #2848 or followup GLM weights, Stata and Poisson #2849?

@josef-pkt

Copy link
Copy Markdown
Member

about 4. weights:
another issue #2889 for explicit dispersion models.

The point I wanted to make is that I prefer not to use the word "weights" without qualifier anymore, except in a generic way or when the definition doesn't matter as in the estimating equations where they all enter in the same way for GLM/LEF.

( #2849 is mostly an implementation issue for auxiliary results, and not so much a general discussion.)
#2848 is the most generic issue, which should apply across all models
#2840 is specific to GLM/LEF because of the aggregation/endog scaling issue.

AFAIU, var_weights will cover #2840 (endog is a sub-sample mean) and #2889 (dispersion is a function of constant and other variables)
I need to see if I can find a reference with your definition (which I think is var_weights)

about 1. Greek
I agree, we leave the Greek letters in the formulas, but add additionally (tautology for emphasis) the translation to the user accessible attributes.
Related, I prefer if rendered Greek has the pronunciation at least once if there are several \phi (phi), mainly because I often forget what the name of the greek letters is beyond the very commonly used.

@lorentzenchr

Copy link
Copy Markdown
Contributor Author

Continuation in PR #3364

@TomAugspurger TomAugspurger mentioned this pull request Feb 2, 2017
2 tasks done
@bashtage bashtage added the rejected Used for PRs with changes that are not acceptable label Jul 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rejected Used for PRs with changes that are not acceptable

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants