Skip to content

ENH: all weights in GLM - #2879

Merged
josef-pkt merged 6 commits into
statsmodels:masterfrom
josef-pkt:glm_four_weights
Jun 19, 2016
Merged

josef-pkt merged 6 commits into
statsmodels:masterfrom
josef-pkt:glm_four_weights

Conversation

@josef-pkt

Copy link
Copy Markdown
Member

see
#2849 followup for GLM
#2848 SUMM issue for weights

The plan here is to implement 3 or 4 weight types in analogy to Stata
freq_weights, var_weights, prob_weights, and possibly iweights. (fweights, aweights and pweights in Stata)

robust cov_type HC and cluster should work correctly after this (not with same defaults as Stata)
other robust cov_types should be extended for var_weights and prob_weights (AFAICS, they would make sense in those cases, but in a later PR, it might not be easy for panel and HAC cov_types.)

freq_weights for GLM has been merged in #2835 (checked for cov_type nonrobust and HC)

status:
currently only unit tests, test cases from Stata are GLM-Poisson and WLS(regress)
Note: output from Stata contains some redundancies because several cases produce the same results. e.g. residuals don't include weights in Stata. I left them in to have separate test cases and for the record.

@josef-pkt

Copy link
Copy Markdown
Member Author

2 nonactive T_ests for aweight and pweight with HC1 (not implemented yet, not wired up)

@josef-pkt

Copy link
Copy Markdown
Member Author

all python 2 fail, integer division?
adding the future

@josef-pkt

Copy link
Copy Markdown
Member Author

cluster robust works but only without small sample correction. We need wnobs information in the sandwich code.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.05%) to 85.433% when pulling a983371 on josef-pkt:glm_four_weights into c89da5c on statsmodels:master.

@josef-pkt

Copy link
Copy Markdown
Member Author

rebased after #2877 merge (no weights in resid)

test resids except resid_working

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.06%) to 85.435% when pulling e52791f on josef-pkt:glm_four_weights into 970e99e on statsmodels:master.

@josef-pkt

Copy link
Copy Markdown
Member Author

I will merge this as is, without the promised weights.
This is a useful incremental PR with mainly unit tests. The rest will follow in new PRs

@josef-pkt

Copy link
Copy Markdown
Member Author

rebased and added warning

should be ready to merge, but doesn't deliver what was intended here
Now it's mainly unit tests plus warning

@coveralls

coveralls commented Jun 19, 2016 •

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.06%) to 85.524% when pulling 31d62ac on josef-pkt:glm_four_weights into 1a9d7e9 on statsmodels:master.


# experimental support for freq_weights
if hasattr(results.model, 'freq_weights'):
if hasattr(results.model, 'freq_weights') and not cov_type == 'clu':

@josef-pkt josef-pkt Jun 19, 2016 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first condition is now empty for GLM because it's currently always true for GLM. But it will be required for other models.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants