(Basic Statistics for Citizen Data Scientist)
One-sample Proportion Testing
From the theorem, we know that when sufficiently large samples of size n are taken, the distribution of sample proportions is approximately normal, distributed around the true population proportion mean π, with standard deviation (i.e. the standard error)
We can use this fact to do hypothesis testing as was done for the normal distribution. In addition when a two-tailed test is performed a confidence interval can be calculated where
If necessary, we can use the sample mean p as an estimate for the population mean when calculating the standard error. This introduces additional error, which is acceptable for large values of n.
Example 1: A company believes that 50% of their customers are women. A sample of 600 customers is chosen and 325 of them are women. Is this significantly different from their belief?
H0: π = 0.5; i.e. any difference in the number of men and women is due to chance
H1: π ≠ 0.5
Method 1: Using the binomial distribution, we reject the null hypothesis since:
BINOMDIST(325, 600, .5, TRUE) = 0.981376 > 0.975 = 1 – α/2 (2-tailed)
Method 2: By Theorem 1 we can also use the normal distribution
The observed mean is 325/600 = 0.541667. Based on the null hypothesis, we can assume that the mean p = .5 and the standard error
NORMDIST(.541667, .5, .020412, TRUE) = 0.979387 > 0.975 = 1 – α/2 (2-tailed)
And so we reach the same conclusion, namely to reject the null hypothesis.
Example 2: A survey of 1,100 voters showed that 53% are in favor of the new tax reform. Can we conclude that the majority of voters (from the population) are in favor?
H0: π < 0.5
Since people are not surveyed twice, we essentially have a hypergeometric distribution instead of a binomial distribution; i.e. we are selecting without replacement. But for large n the hypergeometric distribution is approximately binomial (i.e. it is not so likely that you will select the same person twice).
Since p = .53 and n = 1100, np > 5 and n (1 – p) > 5, and so we can approximate the distribution as a normal distribution. We will also use the sample p as an estimate of π in calculating the standard error.
NORMDIST(.53, .5, 0.01505, TRUE) = .976889 > .95, and so we can reject the null hypothesis and conclude with 95% confidence that the population will vote in favor of the tax reform.
We determine the 95% confidence interval as follows:
zcrit = NORMSINV(1 – α/2) = NORMSINV(0.975) = 1.96
and so the 95% confidence interval is
Thus we conclude with 95% confidence that between 50.1% and 55.9% of the population will be in favor. If however we are looking for a 99% confidence interval then
zcrit = NORMSINV(1 – α/2) = NORMSINV(0.995) = 2.58
And so the 99% confidence interval is
This means that with 99% confidence, between 49.1% and 56.9% of the population will be in favor. Since 50.0% is in this interval this time we cannot conclude (with 99% confidence) that the population will vote in favor of the tax reform.
Example 3: In conducting a survey of potential voters, how big does the sample need to be so that with 95% confidence the actual result (i.e. the population mean) will be within 2.5% of the sample mean? (i.e. how big a sample is necessary to have a 2.5% margin of error?)
This time we are looking for the value of n such that
zcrit · s.e. = 2.5%
As we saw in the previous example for 95% confidence zcrit = 1.96. The question is for any value of n when is s.e. the maximum? For any n, s.e. = is maximum when p(1–p) is maximum. It is easy to see that this occurs when p = .5. Thus the maximum s.e. = = . It now follows that
Solving for n yields n = 1536.584. Thus a sample of size 1,537 is sufficient. Using a similar calculation, to achieve 99% confidence requires a sample of size of 2,654.
Statistics for Beginners in Excel – Confidence Intervals for Sampling Distributions
Statistics for Beginners in Excel – One-sample hypothesis testing
Disclaimer: The information and code presented within this recipe/tutorial is only for educational and coaching purposes for beginners and developers. Anyone can practice and apply the recipe/tutorial presented here, but the reader is taking full responsibility for his/her actions. The author (content curator) of this recipe (code / program) has made every effort to ensure the accuracy of the information was correct at time of publication. The author (content curator) does not assume and hereby disclaims any liability to any party for any loss, damage, or disruption caused by errors or omissions, whether such errors or omissions result from accident, negligence, or any other cause. The information presented here could also be found in public knowledge domains.
Learn by Coding: v-Tutorials on Applied Machine Learning and Data Science for Beginners
Latest end-to-end Learn by Coding Projects (Jupyter Notebooks) in Python and R:
All Notebooks in One Bundle: Data Science Recipes and Examples in Python & R.
End-to-End Python Machine Learning Recipes & Examples.
End-to-End R Machine Learning Recipes & Examples.
Applied Statistics with R for Beginners and Business Professionals
Data Science and Machine Learning Projects in Python: Tabular Data Analytics
Data Science and Machine Learning Projects in R: Tabular Data Analytics
Python Machine Learning & Data Science Recipes: Learn by Coding
R Machine Learning & Data Science Recipes: Learn by Coding
Comparing Different Machine Learning Algorithms in Python for Classification (FREE)
There are 2000+ End-to-End Python & R Notebooks are available to build Professional Portfolio as a Data Scientist and/or Machine Learning Specialist. All Notebooks are only $29.95. We would like to request you to have a look at the website for FREE the end-to-end notebooks, and then decide whether you would like to purchase or not.