Repository navigation
Conversation
|
Hello @josef-pkt! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2020-12-14 17:33:54 UTC |
|
I didn't run the code yet and some parts won't work |
|
This pull request introduces 1 alert when merging b02ad31 into 874c666 - view on LGTM.com new alerts:
|
|
a reference to justify including frequency plots, as I had used in my notebook (IIRC, I also allowed for subsample freq plots, e.g. male versus female) Holling, Heinz, Walailuck Böhning, Dankmar Böhning, and Anton K Formann. 2016. “The Covariate-Adjusted Frequency Plot.” Statistical Methods in Medical Research 25 (2): 902–16. https://doi.org/10.1177/0962280212473386. |
|
There might be something strange with the Poisson dispersion test, I get a lot of overrejection in a simple monte carlo. at nobs=1000, cameron trivedi "CT" tests are closer to size, but "Dean" seem to be doubled 2-sample case, |
|
Bug in pvalue for "Dean" tests, missing same as before (seed is not set), large sample results look reasonable, with 5000 MC replications |
|
zero inflation tests example 2 sample exog. With small poisson means, the zero-inflation test looks good, correctly sized and close to uniform even for nobs=100 It looks like test_poisson_zeroinflation and test_poisson_zeroinflation_brock give the same results for constant zero-inflation prob, i.e. exog_infl is just a constant. With nobs=5000, the test gets closer to asymptotic distribution for larger poisson mean e.g. exp([1, 2]) |
|
aside: MC takes time because in dispersion test we compute always all 7 tests, 4 of which require auxiliary regression default: using exog_infl introduces more variation into the score statistic and pvalues get closer to uniform |
|
Tang and Tang 2019 have poisson zi score test with large deviations from nominal size in their Monte Carlo simulations. It looks like I get the same results. The problem in the computation of the zi score test is that it divides by prob_zero which will be close to zero if the poisson mean is large. Jansakul and Hinde 2009 score_test using exog_infl works better than Brock but not as well as "He" when poisson mean is large. So I guess the moment test should be the default for Poisson zi test. A possible idea is to clip prob_zero in the score test to have a larger minimum, i.e. we use a weighted moment condition that corresponds to the score test but with adjusted weights. Tang and Tank also look at Wald and LR test using a ZI model, but in many cases the MLE cannot be estimated under the Null. In those failing cases "He" test statistic is negative, i.e. zero-deflated in sample. We got the convergence failures in similar cases when merging ZI models. aside: reuse generic ztest to handle I coded "He" moment test based on explicit formula in Tang/Tang equ.12 and appendix. |
|
countreg in R has zitest based on van den Broek
besides the zitest in countreg, I don't find anything for zi tests in R found another Broek test in vcdextra |
|
function name zi brock is wrong test_poisson_zeroinflation_brock return p-value for all 3 alternatives I guess the same could apply to dispersion tests. equivalence testing, superiority by a margin: Locally we could add a |
|
what should be in XXXDiagnostic.summary ? we could add something similar to but longer than the OLS summary bottom table e.g. for count models example Poisson
related influence and outlier statistics, should we add some of those to Diagnostic classes should just be a quick overview with methods to look more closely, |
|
PR #2096 had added family to Poisson I had started to use log link in this PR directly. We need a consistent design as we add this. Mainly we need the mean function transformation, inverse link in models that use "links" to constrain to appropriate parameter space. adding family is not general enough, e.g. for models like NegBin(P) and GPP we don't have the families but we still use exp mean, log-link |
|
genmod\tests\test_score_test.py includes unit test for GLM-Poisson and discrete Poisson for score_test function and dispersion tests GLM get_prediction does not have unit tests in genmod/tests |
b02ad31 to
af566f8
Compare
|
This pull request introduces 1 alert when merging af566f8 into c024369 - view on LGTM.com new alerts:
|
|
comparing Poisson score_test to statmod they report z-statistic numbers look like they agree well, I picked an example by chance (*) where this was true and they don't get strong non-rejection. my pvalue = 1 |
|
score_test precision problems exog_extra is linear trend collinear with included exog respoi is results of Poisson model score_test should be invariant in this case score test for glm is even getting a negative chi2 statistic -0.00788994 that is not noise around 0 only xr, and only exog_extra |
|
another collinear case, RESET test with only dummy variables
so, RESET test doesn't do anything if we only have categorical exog The example is not a good test case, one of the two categoricals has close to zero effect parameters < 1e-13 in absolute I need a nice unit test case before going into numerical precision and corner case problems numerically: statmod scoretest only allows for a single exog and can to explicit computation for the scalar test case for z-test. Information about already included exog comes from QR decomposition when estimating the GLM. So, that's potentially more stable than my generic linalg solution for arbitrary number of constraints, but R stats also does weird things in the QR for highly multicollinear data. |
|
example data from
res2 uses correctly specified Poisson leaving out a relevant variable not sure if we get something on params of included exog, i.e. is left out variable biasing our included parameters missing variable is misspecified mean function |
|
removing warnings when running test_glm.py TestGlmGaussianGradient numbers look converged but bfgs issues warning about not converged with precision problems when computing the Null, constant only model the DomainWarning was raised. I caught that warning in the code in |
|
selective unit test comparing GLM to Logit in test_glm.py tests are mainly for hessian, score, ... (*) (*) |
|
This pull request introduces 1 alert when merging 7c5ef32 into c2c9f56 - view on LGTM.com new alerts:
|
|
test_glm_weights copied the Poisson test from test_glm |
|
I did some whitespace and line break cleanup in test_glm_weights. I don't know if that's too noisy in this PR. TestInfluenceLogitCompare fails with large discrepancies and nans in appveyor. I thought I had run it locally. bug is in my mistake: I left log-link in there instead of using the attached link |
|
This pull request introduces 1 alert when merging 038a1f9 into c2c9f56 - view on LGTM.com new alerts:
|
|
aside: with canonical link, Logit and Poisson: |
|
needs a push so we get test results again. would be good to have this merged |
|
mising unit test coverage for im_ratio, tic, gbic |
|
difficult PR to review, only around 400 lines but affects many parts |
collecting diagnostic and specification tests in XXXDiagnostic classes
see #130 for design as
get_diagnosticclassesThe plan is to make this the main access point for diagnostics for users, similar to get_influence and other
get_xxxcurrently I'm collecting specification tests for Poisson, especially dispersion and zero-inflation score, LM, m/cm tests
Those need to be better organized, e.g. too many versions of exess dispersion tests
I'm still working on the design and collecting functions, and less on getting the details for the specification tests in a nice shape.
Some of the methods are not really Poisson specific and can be moved higher up in an inheritance class tree, e.g. to CountDiagnostic or even generic.
Another open question is what methods or attribute we need to add to the model and results classes themselves, so we can write more general diagnostic functions or reuse across post-estimation methods.
e.g. derivatives, more predict options, ...
new content
I wanted to check MLEInfluence for Poisson and Logit, however I needed some extras
score_factorandhessian_factorget_predictionfor Logit and Poisson. The same way should also work for NBP and GPP with log-linkscore_test, I checked the standalone function for Poisson, but should now also work for Logit, and we can add it as a Results method.get_influenceto Logit and Poisson to return MLEInfluencenot checked yet: Probit