Repository navigation
MAINT: GLM - #1734
MAINT: GLM#1734kshedden wants to merge 9 commits into
Conversation
|
Thanks Kerby, I will go over it soon, but I think I merge my fit_constrained branch first which should make merge conflicts easier (I only expect them in a few spots.) I'm only planning to do a few more smaller changes, but then I would like or need to go back to reviewing other PRs. Two extension questions, not for this or my PR: Do you know what we need for robust covariance matrix of the parameter estimates? In the other models I needed the score for each observation and the Hessian, after that it is largely generic code. influence: While reading the Stata manual for this I saw that they define the (diagonal of the) hat matrix as the hatmatrix of the WLS estimator for the linear predictor, where the weights are the family specific variance function. |
|
TravisCI failure is because of an extra array that is not removed before pickling the instance #1729 in generalized_linear_model.py on line 199, 200, we need to add the new array _offset_exposure |
|
I added _offset_exposure as you noted above but it still fails on test_shrink_pickle. The length of the thing that you are checking is ~10,300, and you want it to be <10,000. |
|
I don't have a lot of experience with robust covariance estimators. I think you are talking about what's on page 13 here: If so, then it appears that yes, you just need the Hessian, and the score for each subject. Maybe we can add a 'score_obs' method to the base likelihood model class, and then have a default 'score' method that just calls this for every row of the data set. We could then if needed override the default score method for efficiency. Then we could have a generic 'robust_covariance' method that would work for all models. |
|
Regarding diagnostics, I think you referred to this page earlier in a discussion about GEE. It shows how diagnostics are calculated in SAS for GLM (and GEE). Everything seems to be a function of the data and residuals (i.e. we don't seem to need the explicit score or Hessian). |
|
about the pickle/remov_data failure: We have to adjust the test and can increase the size limit to 20000 (I was mostly guessing on the size requirement, and made it pretty strict when I added this.) |
|
(I had forgotten that the SAS documentation was one of my favorite readings.) about diagnostic and hatmatrix: based on briefly looking at the formulas, I don't see how SAS and Stata match up. So I'm not trying to quickly replicate Stata if it's not clear it is the only or right choice. new issue specific for GLM diagnostics #1737 about robust cov: I think I know now roughly how to add this if it's just generic MLE assumptions, and can look into this again later, new issue #1738 related: having score_obs/scores/estimating equations explicitly in GLM will also make it easier to add other things like score tests, or alternative optimizers. |
|
general comment: If we do cleanups, then it would be useful to fix pep-8 issues in the changed lines, e.g. spaces after comma and around operators. |
There was a problem hiding this comment.
general taste issue:
In pure math, I find using y and x locally improves readability, y = endog # alias
here missing whitespace makes it difficult to read
There was a problem hiding this comment.
I can revert the y->endog changes in family. Just give me some guidance on
how to proceed with renamings.
On Mon, Jun 9, 2014 at 3:05 AM, Josef Perktold [email protected]
wrote:
In statsmodels/genmod/families/family.py:
return -2 * np.sum(one * np.log(mu+1e-200) + (1-one) * np.log(1-mu+1e-200)) else:
return 2_np.sum(self.n_(Y_np.log(Y/mu+1e-200)+(1-Y)_np.log((1-Y)/(1-mu)+1e-200)))return 2_np.sum(self.n_(endog_np.log(endog/mu+1e-200)+(1-endog)_np.log((1-endog)/(1-mu)+1e-200)))general taste issue:
In pure math, I find using y and x locally improves readability, y =
endog # alias
here missing whitespace makes it difficult to read—
Reply to this email directly or view it on GitHub
https://github.com/statsmodels/statsmodels/pull/1734/files#r13525584.
|
I saw a bunch of pep-8 issues and was tempted to change them, but didn't On Mon, Jun 9, 2014 at 2:59 AM, Josef Perktold [email protected]
|
|
about fixing pep-8: about the renamings: in general, based on my reviewing and bughunting experience: Readability for math or the actual calculations in a function can improve if we have short names. So, I'm often using the full names in short expressions, or when a name shows up only once. y or endog in families could go either way, but for example in discrete_models we don't alias endog, except for removing self (Poisson) but this is less nice |
|
I'm going to rebase and merge this. genmod needs a pep-8 cleanup, and we need to check formulas in the documentation to see whether using I will rebase and merge #1781 after this is in |
|
I was going to continue this PR based on some of your earlier comments. On Thu, Jun 26, 2014 at 3:43 AM, Josef Perktold [email protected]
|
|
I'm going to merge this today, after rebase @kshedden do you still have anything in this branch that you didn't push yet to github? |
|
Thanks for checking. No, there are no local changes. On Wed, Jul 9, 2014 at 10:19 AM, Josef Perktold [email protected]
|
…ased REF Glm maint rebased closes statsmodels#1734 (PR) closes statsmodels#1728
Addresses (or partially addresses) several issues with GLM: