An open API service indexing awesome lists of open source software.

https://github.com/anas436/confidence-intervals-for-differences-between-population-parameters-with-python


https://github.com/anas436/confidence-intervals-for-differences-between-population-parameters-with-python

confidence-intervals inferential-statistical-analyses jupyterlab matplotlib-pyplot numpy pandas python3 seaborn

Last synced: about 1 year ago
JSON representation

Awesome Lists containing this project

README

          

# Confidence-Intervals-for-Differences-between-Population-Parameters-with-Python

This tutorial is going to demonstrate how to load data, clean/manipulate a dataset, and construct a confidence interval for the difference between two population proportions and means.

We will use the 2015-2016 wave of the NHANES data for our analysis.

*Note: We have provided a notebook that includes more analysis, with examples of confidence intervals for one population proportions and means, in addition to the analysis I will show you in this tutorial. I highly recommend checking it out!

__For our population proportions, we will analyze the difference of proportion between female and male smokers. The column that specifies smoker and non-smoker is `"SMQ020"` in our dataset.__

__For our population means, we will analyze the difference of mean of body mass index within our female and male populations. The column that includes the body mass index value is `"BMXBMI"`.__

Additionally, the gender is specified in the column `"RIAGENDR"`.

### Constructing Confidence Intervals

Now that we have the population proportions of male and female smokers, we can begin to calculate confidence intervals. From lecture, we know that the equation is as follows:

$$Best\ Estimate \pm Margin\ of\ Error$$

Where the *Best Estimate* is the **observed population proportion or mean** from the sample and the *Margin of Error* is the **t-multiplier**.

The equation to create a 95% confidence interval can also be shown as:

$$Population\ Proportion\ or\ Mean\ \pm (t-multiplier *\ Standard\ Error)$$

The Standard Error (SE) is calculated differenly for population proportion and mean:

$$Standard\ Error \ for\ Population\ Proportion = \sqrt{\frac{Population\ Proportion * (1 - Population\ Proportion)}{Number\ Of\ Observations}}$$

$$Standard\ Error \ for\ Mean = \frac{Standard\ Deviation}{\sqrt{Number\ Of\ Observations}}$$

Lastly, the standard error for difference of population proportions and means is:

$$Standard\ Error\ for\ Difference \ of\ Two\ Population\ Proportions\ Or\ Means = \sqrt{(SE_{\ 1})^2 + (SE_{\ 2})^2}$$