Calculating Confidence Interval For A Proportion In One Sample
What would be a better way to calculate Confidence Interval (CI) for a proportion when the sample size is small and even the sample size is 1? I am currently calculating CI for a P
Solution 1:
Try statsmodels.stats.proportion.proportion_confint
http://www.statsmodels.org/devel/generated/statsmodels.stats.proportion.proportion_confint.html
According to their documentation, you use it like this:
ci_low, ci_upp = proportion_confint(count, nobs, alpha=0.05, method='normal')
Where the parameters are:
- count (int or array_array_like) – number of successes, can be pandas Series or DataFrame
- nobs (int) – total number of trials
- alpha (float in (0, 1)) – significance level, default 0.05
method (string in ['normal']) – method to use for confidence interval, currently available methods:
- normal : asymptotic normal approximation
- agresti_coull : Agresti-Coull interval
- beta : Clopper-Pearson interval based on Beta distribution
- wilson : Wilson Score interval
- jeffreys : Jeffreys Bayesian Interval
- binom_test : experimental, inversion of binom_test
Post a Comment for "Calculating Confidence Interval For A Proportion In One Sample"