Skip to content

ENH: Multinomial confidence interval (cont. 2953) - #3161

Merged
josef-pkt merged 3 commits into
statsmodels:masterfrom
josef-pkt:multinomial_ci2
Aug 16, 2016
Merged

josef-pkt merged 3 commits into
statsmodels:masterfrom
josef-pkt:multinomial_ci2

Conversation

@josef-pkt

Copy link
Copy Markdown
Member

this continues PR #2953

remove exception for zero counts
allow counts to be zero or have decimals
speedup by avoiding calculating same value several times

wehlutyk and others added 2 commits June 27, 2016 10:16
This includes tests. There are a number of todos added here and there,
and in the documentation, corresponding to what comes next (Goodman
method and advice on what to use when).

DOCS: explain where the multinomial CI tests come from

TST: add missing test from Sison & Glaz paper

Also define precision for the tests in the results file, and do some
code style fixes.

DOCS: cleanup before a real pass on method advice

EHN: implement goodman method for multinomial CIs

This includes tests.

REF: refactor to fix function name

FIX: integer division don't behave the same under py2 and py3

DOC: reduce 'TODO' ambitions a little

The Hou-Chiang-Tai method would be interesting to implement, but would
take a lot more time.

DOC: fill docstring for multinomial_proportions_confint

FIX: assert_raises_regex is not available in numpy < 1.9

FIX: allow null values in `counts`

DOC: Formatting, and include multinomial_confint docstring in docs

DOC: formatting and phrasing

BUG: str.format() does not exist in python < 2.7

DOC: formatting

DOC: a few more details and coming closer to conventions

STY: variable names and performance

* Don't use `l`, which can be mixed up with `1`
* Use exp sum log instead of product division
* Use `np.minimum` and `np.maximum`

EHN: update method name matching and checks on `counts`

In particular, counts can't have 0-valued entries, as the behavior is
undefined in that case.

DOC: clarify details of the sison-glaz method
@josef-pkt

Copy link
Copy Markdown
Member Author

The case with zero count fails in all older versions on TravisCI.
I guess some zero restriction in scipy.stats distributions for older scipy, <=0.14 fails

we are not testing with scipy version between 0.14 and 0.17 on TravisCI. (0.17, 0.18 are the current latest versions that we get from conda)

(because of the two year release delay, we are testing with ancient scipy 0.11 to 0.14 )

@josef-pkt

Copy link
Copy Markdown
Member Author

with scipy 0.16.1 poisson doesn't allow zero mean

>>> stats.poisson._cdf(0, 0)
1.0
>>> stats.poisson.cdf(0, 0)
nan

In scipy 0.17.0 I get

stats.poisson.cdf(0, 0)
Out[40]:
1.0

We cannot use _cdf in this case because it doesn't handle counts < 0 correctly.
last commit is a hack to check if that works for all TravisCI versions
(I might switch to _cdf(np.minimum(x, 0))

@coveralls

coveralls commented Aug 15, 2016 •

Copy link
Copy Markdown

Coverage Status

Changes Unknown when pulling f3dfc0a on josef-pkt:multinomial_ci2 into * on statsmodels:master*.

@josef-pkt

Copy link
Copy Markdown
Member Author

all green, I leave the workaround the way it is because this way it is a no-op for scipy >= 0.17.

aside: I thought the function might be vectorized, but the proportion p is scalar.

I still need to remove a left-in debug print, otherwise I think this looks good.

@coveralls

coveralls commented Aug 15, 2016 •

Copy link
Copy Markdown

Coverage Status

Changes Unknown when pulling d1a258c on josef-pkt:multinomial_ci2 into * on statsmodels:master*.

@josef-pkt

Copy link
Copy Markdown
Member Author

I'm merging this, closes #2953 (original PR) but I leave the original issue #2895 open
some additional things like Monte Carlo probabilities are in PR #2932
(and lots of related open issues with discussion/monologues and references)

@josef-pkt
josef-pkt merged commit 5fa4f8e into statsmodels:master Aug 16, 2016
@josef-pkt josef-pkt mentioned this pull request Aug 16, 2016
4 of 28 tasks
@josef-pkt
josef-pkt deleted the multinomial_ci2 branch August 17, 2016 15:16
josef-pkt added a commit to josef-pkt/statsmodels that referenced this pull request Aug 19, 2016
@TomAugspurger TomAugspurger mentioned this pull request Feb 2, 2017
2 tasks done
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.

3 participants