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
The documentation about Generalized Linear Models is not very detailed. As is the case in the chapter about linear regression, one could specify the underlying stochastic model, e.g. Y ~ ExpFamily, and then specify the exponential family. The docu just states: "Generalized linear models currently supports estimation using the one-parameter exponential families".
In short: Some more formulas would be helpful, not only in the chapter about glms (cf. docu of scikit-learn).
PRs and improvements would be very welcome and appreciated.
It's a lot of work to write documentation, and even more so vignette length versions.
In the case of GLM essentially everything is standard, and any textbook and maybe Wikipedia provides the relevant formulas.
(I'm looking mostly at SAS and SPSS technical documentation or the source, when I want to see the actual formulas for different families. I don't find the generic GLM likelihood very informative and it is not directly used in any code, but every article or book starts with it.)
When I write documentation for parts where it is still missing, then I try to focus on things where references are not easily accessible or where implementation details are not standard across packages.
Actually, for the parameter estimation the only things that are relevant are the link function for mean and the variance function for weighting observations, and the implied constraints on the support/domain of the response.
I think I've seen a nice table for this in the documentation of some other package.
family/distribution are relevant if we want to have full MLE interpretation, e.g. loglike, ...
Can you discuss your argument that the only things that are relevent for parameter estimation are the link and variance function?
I get what you are saying insofar as the variance function is part of the calculation for W, but I've always been under the impression that that variance function is part of the family for all GLMs. Take page 95 of this text. I was always under the impression that the variance function was tied to the family, so necessary for parameter estimation as well? Maybe I'm confused again.
@thequackdaddy The way the estimator and the variance function are derived and are implemented is through the family.
However, like in OLS/WLS properties of the family/distribution other than expected response (mean function) and variance don't show up in the estimating equation.
And interpreted as Quasi-MLE, the mean parameter estimates are consistent if the mean function is specified, and the are efficiently (minimum asymptotic variance) estimated if the variance function is correctly specified. The rest doesn't really matter for estimating the mean parameters.
(We need sandwich robust covariance matrix for the mean parameters for inference if the variance or covariances are misspecified.)
This is all we need if we want to predict the mean/expected value of a new information given the explanatory variables.
However, it's not enough if we want to find the distribution for predicting a new value, e.g. use Poisson to evaluate the prediction distribution. In that case we need a fully and correctly specified family.
(aside: in several usecases we want to misuse or redefine a variance function, which is perfectly fine as QMLE, but there might not be an actual known distribution for it. And it's a bit like Tweedie right now, where we only use link and variance function in the estimation.)
It's not a very widespread view among people that focus on MLE, and I only started to go through the details in the GLM context maybe 3 years ago.
But it's a bit similar to the view that looks at OLS or linear model mainly through the normal distribution, which is completely irrelevant for mean prediction based on large samples (after making some other "technical" assumption like finite 4th moment which rules out very heavy tailed distributions and big outliers.)
nice exercise that I haven't tried, but I tried something similar:
use GLM with gaussian family and log link for a nonnegative response and override the variance function to be var = mean, i.e. Poisson.
I think the parameter and scale estimates should be exactly the same as over- or underdispersed GLM with family Poisson.
(There is currently no option to change the variance function, but it's possible to cheat by assigning to the attribute of the model.)
Activity
josef-pkt commentedon May 19, 2016
PRs and improvements would be very welcome and appreciated.
It's a lot of work to write documentation, and even more so vignette length versions.
In the case of GLM essentially everything is standard, and any textbook and maybe Wikipedia provides the relevant formulas.
(I'm looking mostly at SAS and SPSS technical documentation or the source, when I want to see the actual formulas for different families. I don't find the generic GLM likelihood very informative and it is not directly used in any code, but every article or book starts with it.)
When I write documentation for parts where it is still missing, then I try to focus on things where references are not easily accessible or where implementation details are not standard across packages.
Another area where I lost an overview (especially for my code and for older code) is what references were used for the implementation. And what are references that can be recommended to users, especially if the implementation references are too heavy.
https://github.com/josef-pkt/misc/wiki/References-for-Implementation
In many parts the references are in the docstrings or code comments but not everywhere.
josef-pkt commentedon May 20, 2016
Actually, for the parameter estimation the only things that are relevant are the link function for mean and the variance function for weighting observations, and the implied constraints on the support/domain of the response.
I think I've seen a nice table for this in the documentation of some other package.
family/distribution are relevant if we want to have full MLE interpretation, e.g. loglike, ...
thequackdaddy commentedon May 20, 2016
Josef,
Can you discuss your argument that the only things that are relevent for parameter estimation are the link and variance function?
I get what you are saying insofar as the variance function is part of the calculation for W, but I've always been under the impression that that variance function is part of the family for all GLMs. Take page 95 of this text. I was always under the impression that the variance function was tied to the family, so necessary for parameter estimation as well? Maybe I'm confused again.
josef-pkt commentedon May 20, 2016
@thequackdaddy The way the estimator and the variance function are derived and are implemented is through the family.
However, like in OLS/WLS properties of the family/distribution other than expected response (mean function) and variance don't show up in the estimating equation.
And interpreted as Quasi-MLE, the mean parameter estimates are consistent if the mean function is specified, and the are efficiently (minimum asymptotic variance) estimated if the variance function is correctly specified. The rest doesn't really matter for estimating the mean parameters.
(We need sandwich robust covariance matrix for the mean parameters for inference if the variance or covariances are misspecified.)
This is all we need if we want to predict the mean/expected value of a new information given the explanatory variables.
However, it's not enough if we want to find the distribution for predicting a new value, e.g. use Poisson to evaluate the prediction distribution. In that case we need a fully and correctly specified family.
(aside: in several usecases we want to misuse or redefine a variance function, which is perfectly fine as QMLE, but there might not be an actual known distribution for it. And it's a bit like Tweedie right now, where we only use link and variance function in the estimation.)
It's not a very widespread view among people that focus on MLE, and I only started to go through the details in the GLM context maybe 3 years ago.
But it's a bit similar to the view that looks at OLS or linear model mainly through the normal distribution, which is completely irrelevant for mean prediction based on large samples (after making some other "technical" assumption like finite 4th moment which rules out very heavy tailed distributions and big outliers.)
josef-pkt commentedon May 20, 2016
nice exercise that I haven't tried, but I tried something similar:
use GLM with gaussian family and log link for a nonnegative response and override the variance function to be var = mean, i.e. Poisson.
I think the parameter and scale estimates should be exactly the same as over- or underdispersed GLM with family Poisson.
(There is currently no option to change the variance function, but it's possible to cheat by assigning to the attribute of the model.)
DOC: Improve documentation about glm statsmodels#2959
lorentzenchr commentedon Jan 3, 2017
PR #3353
DOC: Improve documentation about glm statsmodels#2959 update1
DOC: Improve documentation about glm statsmodels#2959 update2 Tweedie
DOC: Improve documentation about glm statsmodels#2959 update3 expecta…
Merge pull request #3364 from lorentzenchr/glm_docu
DOC: Improve documentation about glm statsmodels#2959
2 remaining items
DOC: Improve documentation about glm statsmodels#2959 update3 expecta…
DOC: Improve documentation about glm statsmodels#2959
DOC: Improve documentation about glm statsmodels#2959 update1
DOC: Improve documentation about glm statsmodels#2959 update2 Tweedie
DOC: Improve documentation about glm statsmodels#2959 update3 expecta…
DOC: Improve documentation about glm statsmodels#2959 update1
DOC: Improve documentation about glm statsmodels#2959 update2 Tweedie
DOC: Improve documentation about glm statsmodels#2959 update3 expecta…
DOC: Improve documentation about glm statsmodels#2959
DOC: Improve documentation about glm statsmodels#2959 update1
DOC: Improve documentation about glm statsmodels#2959 update2 Tweedie
DOC: Improve documentation about glm statsmodels#2959 update3 expecta…
lorentzenchr commentedon Mar 28, 2020
Closed with PR #3364.