Statistics for Beginners in Excel – One-sample hypothesis testing

(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)

image542

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

image543image544

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

image545

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 (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.

image5024

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

image550

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

image551

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 ns.e. = sqrt{frac{p(1-p)}{n}} is maximum when p(1–p) is maximum. It is easy to see that this occurs when p = .5. Thus the maximum s.e. = sqrt{frac{.5(1-.5)}{n}} = frac{.5}{sqrt{n}}. It now follows that

image558

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

Personal Career & Learning Guide for Data Analyst, Data Engineer and Data Scientist

Applied Machine Learning & Data Science Projects and Coding Recipes for Beginners

A list of FREE programming examples together with eTutorials & eBooks @ SETScholars

95% Discount on “Projects & Recipes, tutorials, ebooks”

Projects and Coding Recipes, eTutorials and eBooks: The best All-in-One resources for Data Analyst, Data Scientist, Machine Learning Engineer and Software Developer

Topics included: Classification, Clustering, Regression, Forecasting, Algorithms, Data Structures, Data Analytics & Data Science, Deep Learning, Machine Learning, Programming Languages and Software Tools & Packages.
(Discount is valid for limited time only)

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

Please do not waste your valuable time by watching videos, rather use end-to-end (Python and R) recipes from Professional Data Scientists to practice coding, and land the most demandable jobs in the fields of Predictive analytics & AI (Machine Learning and Data Science).

The objective is to guide the developers & analysts to “Learn how to Code” for Applied AI using end-to-end coding solutions, and unlock the world of opportunities!