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
- Host: GitHub
- URL: https://github.com/anas436/confidence-intervals-for-differences-between-population-parameters-with-python
- Owner: Anas436
- Created: 2022-10-29T16:54:57.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-10-29T17:01:39.000Z (over 3 years ago)
- Last Synced: 2025-02-01T15:31:00.074Z (about 1 year ago)
- Topics: confidence-intervals, inferential-statistical-analyses, jupyterlab, matplotlib-pyplot, numpy, pandas, python3, seaborn
- Language: Jupyter Notebook
- Homepage:
- Size: 282 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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}$$