Friday, May 30, 2014

2-Sample Pooled Hypothesis Test of Proportion in 4 Steps in Excel 2010 and Excel 2013

This is one of the following four articles on Hypothesis Tests of Proportion in Excel

Hypothesis Tests of Proportion Overview (Hypothesis Testing On Binomial Data)

1-Sample Hypothesis Test of Proportion in 4 Steps in Excel 2010 and Excel 2013

2-Sample Pooled Hypothesis Test of Proportion in 4 Steps in Excel 2010 and Excel 2013

How To Build a Much More Useful Split-Tester in Excel Than Google's Website Optimizer

 

Two-Sample, Pooled

Hypothesis Test of

Proportion in 4 Steps in

Excel

This hypothesis test analyzes two independent samples to determine if the populations from which the samples were taken have equal proportions. This test is often used to determine whether two sample proportions are likely the same. The test is a called pooled test because the Null Hypothesis states that the two sample proportions are the same. The formula for Standard Error uses a pooled proportion that combines the proportions of both samples. This formula is shown in the following set of formulas.

p_bar1 = observed sample 1 proportion

p_bar1 = X1/n1

= (Number of successes in sample 1)/(Number of trials in sample 1)

p_bar2 = observed sample 2 proportion

p_bar2 = X2/n2

= (Number of successes in sample 2)/(Number of trials in sample 2)

Null Hypothesis H0: p_bar2 - p_bar1 = Constant = 0

This Null Hypothesis that states that p_bar1 = p_bar2 indicates that this is a pooled test.

The z Value for this test is the Test Statistic and is calculated as follows:

hypothesis test of proportion,hypothesis test, excel,excel 2010,excel 2013,statistics
(Click On Image To See a Larger Version)

hypothesis test of proportion,hypothesis test, excel,excel 2010,excel 2013,statistics
(Click On Image To See a Larger Version)

hypothesis test of proportion,hypothesis test, excel,excel 2010,excel 2013,statistics
(Click On Image To See a Larger Version)

hypothesis test of proportion,hypothesis test, excel,excel 2010,excel 2013,statistics
(Click On Image To See a Larger Version)

The Null Hypothesis is rejected if any of the following equivalent conditions are shown to exist:

1) The observed p_bar2 - p_bar1 is beyond the Critical Value.

2) The z Value (the Test Statistic) is farther from zero than the Critical z Value.

3) The p value is smaller than α for a one-tailed test or α/2 for a two-tailed test.

 

Example of a Two-Sample, Pooled,

Two-Tailed Hypothesis Test of

Proportion in Excel

A new 401K plan is being proposed to the employees of a large company as a replacement for the existing plan.

90 out of 200 randomly sampled male employees prefer the proposed plan over the existing plan.

59 out of 100 randomly sampled female employees prefer the proposed plan over the existing plan.

Determine with 95 percent certainty whether there is a difference between the proportions of male and female employees who prefer the proposed plan.

Note that this will be a pooled z Test because this objective of this hypothesis test is determine whether there is a difference between p_bar1 and p_bar2, i.e. p_bar1 – p_bar2 = 0 or p_bar2 – p_bar1 = 0

Two-independent-sample Hypothesis Tests of Proportion remain slightly more intuitive and allow for consistent use of the variable name p_bar2–p_bar1 if the larger sample proportion is always designated as p_bar2.and the smaller sample proportion is designated as p_bar1.

 

Summary of Problem Information

First Sample (Male Employees)

X1 = number of positive outcomes in n1 trials = 90

n1 = number of trial (sample size) = 200

p_bar1 = X1/n1 = 90/200 = 0.45

Second Sample (Female Employees)

X2 = number of positive outcomes in n2 trials = 59

n2 = number of trial (sample size) = 100

p_bar2 = X2/n2 = 59/100 = 0.59

p_bar2 – p_bar1 = 0.59 – 0.45 = 0.14

Level of Certainty = 0.95

Alpha = 1 - Level of Certainty = 1 – 0.95 = 0.05

As with all Hypothesis Tests of Proportion, we must satisfactorily answer these two questions and then proceed to the four-step method of solving the hypothesis test that follows.

 

The Initial Two Questions That Must be Answered Satisfactorily

1) What Type of Test Should Be Done?

2) Have All of the Required Assumptions For This Test Been Met?

 

The Four-Step Method For Solving All Hypothesis Tests of Mean

Step 1) Create the Null Hypothesis and the Alternate Hypothesis

Step 2) – Map the Normal Curve Based on the Null Hypothesis

Step 3) – Map the Regions of Acceptance and Rejection

Step 4) – Perform the Critical Value Test, the p Value Test, or the Critical z Value Test

The Initial Two Questions That Must Be Answered Before Performing the Four-Step Hypothesis Test of Proportion are as follows:

 

Question1) Type of Test?

 

a) Hypothesis Test of Mean or Proportion?

This is a Hypothesis Test of Proportion because each individual observation (the preference of each sampled employee) can have only one of two values: the employee either prefers or does not prefer the proposed plan over the existing plan. Samples for Hypothesis Test of Mean can have more than two values and often can assume any value within a possible range of values.

 

b) One-Tailed or Two-Tailed Hypothesis?

The problem asks whether the proportion of male employees who prefer the proposed plan over the existing plan is simply different than the proportion of female employees who have the same preference. This is a non-directional inequality making this hypothesis test a two-tailed test. If the problem asked whether the proportion of males preferring the proposed plan was greater than or less than the proportion of females with that preference, the inequality would be directional and the resulting hypothesis test would be a one-tailed test. A two-tailed test is more stringent than a one-tailed test.

 

b) One-Sample or a Two-Sample Test?

This is a two-sample hypothesis test because two independent samples are being compared. One sample included only male preferences and the other sample includes only female preferences.

 

d) Pooled Test or an Unpooled Test?

Once a hypothesis test has been determined to be a two-independent-sample test, the test should be designated as a pooled or unpooled test because each uses different formulas. A pooled Hypothesis Test of Proportion makes a basic assumption that the proportions of both populations are the same. An unpooled Hypothesis Test of Proportion makes a basic assumption that the proportions of both populations are not the same. This is a pooled test because the proportion of male and female employees who prefer the proposed plan is assumed to be the same.

 

e) t-Test or z-Test?

A Hypothesis Test of Proportion uses the normal distribution to approximate the underlying binomial distribution that the sampled objects follow. A Hypothesis Test of Proportion will therefore always be a z Test and not a t Test.

A hypothesis test of proportion will always be a z test because a hypothesis test of proportion always uses the normal distribution to model the distributed variable. A t Test uses the t distribution to model the distributed variable.

Samples taken for a Hypothesis Test of Proportion are binary: they can only assume one of two values. Binary objects are distributed according to the binomial distribution. The binomial distribution can be approximated by the normal distribution. A Hypothesis Test of Proportion uses the normal distribution to approximate the underlying binomial distribution that the sampled objects follow. A Hypothesis Test of Proportion will therefore always be a z Test and not a t Test.

This hypothesis test is a z Test that is two-independent-sample, pooled, two-tailed hypothesis test of proportion.

 

Question 2) Test Requirements Met?

Can Binomial Distribution Be Approximated By Normal Distribution?

The samples for a Hypothesis Test of Proportion follow the binomial distribution because each sample has only two possible outcomes and the probability of the positive outcome is always the same for each sample taken.

A Hypothesis Test of Proportion approximates the binomial distribution with the normal distribution so that normal-distribution-based statistical analysis tools such as z Scores can be used.

The most important requirement of a Hypothesis Test of Proportion is the validity of approximating the binomial distribution with the normal distribution. The binomial distribution can be approximated by the normal distribution if sample size, n, is large enough and p is not too close to 0 or 1. This can be summed up with the following rule:

The binomial distribution can be approximated by the normal distribution if np > 5 and nq >5. In this case, the calculation of np and qp is the following:

 

Sample 1

X1 = 90

n1 = 200

p1 = 0.45

q1 = 0.55

n1p1 = 90 and n1q1 = 110

 

Sample 2

X2 = 59

n2 = 100

p2 = 0.59

q2 = 0.41

n2p2 = 59 and n2q2 = 41

np > 5 and nq >5 for both samples so it is valid to approximate the binomial distribution with the normal distribution. Because the binomial distribution can be modeled by the normal distribution, a z Test can be used to perform a Hypothesis Test of Proportion.

The binomial distribution has the following parameters:

Mean = np

Variance = npq

Each unique normal distribution can be completely described by two parameters: its mean and its standard deviation. As long as np > 5 and nq > 5, the following substitution can be made:

Normal (mean, standard deviation) approximates Binomial (n,p)

When np is substituted for the normal distribution’s mean and npq is substituted for the normal distribution’s standard deviation, then the following is true:

Normal (mean, standard deviation)

becomes

Normal (np, npq)

This approximates Binomial (n,p).

The approximation can be demonstrated with Excel using data from this problem.

X = 90 = the number of positive outcomes in n trials

n = 200 = the number of trials in one sample

p = 0.45 = expected probability of a positive result in all trials

q = 1 – p = 0.55 = expected probability of a negative result in all trials

The normal approximation of the binomial distribution as follows:

BINOM.DIST(X, n, p, FALSE) ≈ NORM.DIST(X, np, npq, FALSE)

Analyzing the data from Sample 1 would produce the following comparison:

BINOM.DIST(X, n, p, FALSE)

= BINOM.DIST(90, 200, 0.45, FALSE) = 0.056

NORM.DIST(X, np, npq, FALSE)

= NORM.DIST(90, 90, 49.5, FALSE) = 0.008

The difference between BINOM.DIST(90, 200, 0.45, FALSE) and NORM.DIST(90, 90, 49.5, FALSE) is less than 0.05. That is reasonably close.

Note that the normal approximation of the binomial distribution only works for the PDF (Probability Density Function) and not the CDF (Cumulative Distribution Function). Replacing FALSE with TRUE in the above BINOM.DIST() and NORM.DIST() formulas would calculate their CDFs instead of their PDFs.

We now proceed to complete the four-step method for solving all Hypothesis Tests of Proportion. These four steps are as follows:

Step 1) Create the Null Hypothesis and the Alternate Hypothesis

Step 2 – Map the Normal or t Distribution Curve Based on the Null Hypothesis

Step 3 – Map the Regions of Acceptance and Rejection

Step 4 – Determine Whether to Accept or Reject theNull Hypothesis By Performing the Critical Value Test, the p Value Test, or the Critical t Value Test

Proceeding through the four steps is done is follows:

 

Step 1 – Create the Null and Alternative Hypotheses

The Null Hypothesis is always an equality and states that the items being compared are the same. In this case, the Null Hypothesis would state that the proportion of males employees who prefer the proposed plan is not different than that the proportion of males employees who prefer the proposed plan. This Null Hypothesis would be written as follows:

H0: p_bar2–p_bar1 = Constant = 0

This test is called a pooled test because the Null Hypothesis states that the two sample proportions are the same. The Constant in the Null Hypothesis equals zero for a pooled, two-independent-sample Hypothesis Test of Proportion. The formula for Standard Error in a pooled, two-independent-sample Hypothesis Test of Proportion uses a pooled proportion that combines the proportions of both samples.

The Null Hypothesis for an unpooled, two-independent-sample Hypothesis Test of Proportion states that the two sample proportions are not the same. The Constant for this Null Hypothesis is a non-zero number.

The Alternate Hypothesis is always in inequality and states that the two items being compared are different. In this case, the Alternative Hypothesis would state that the proportion of males employees who prefer the proposed plan is different than that the proportion of males employees who prefer the proposed plan. This Alternate Hypothesis is as follows:

H1: p_bar2–p_bar1 ≠ Constant, which equals 0

Therefore:

H1: p_bar2–p_bar1 ≠ 0

The “not-equals” sign indicates that this is a two-tailed hypothesis test and not a one-tailed test.

The Alternative Hypothesis is non-directional (“not equal” instead of “greater than” or “less than”) and the hypothesis test is therefore a two-tailed test. It should be noted that a two-tailed test is more rigorous (requires a greater differences between the two entities being compared before the test shows that there is a difference) than a one-tailed test.

It is important to note that the Null and Alternative Hypotheses refer to the proportion of the populations from which the samples were taken. A two-independent-sample Hypothesis Test of Proportion determines whether to reject or fail to reject the Null Hypothesis which states that the populations from which the two independent samples came from have equal proportions. In this case the Hypothesis test analyzes whether total population of male employees has the same proportion preferring the proposed plan as the total female population based upon much smaller samples taken from each of the two populations.

 

Step 2 – Map the Distributed Variable to Normal Distribution

A z Test can be performed if the sample proportion p_bar2–p_bar1 is distributed according to the normal distribution. The sample proportion, p_bar2–p_bar1, is distributed according to the binomial distribution because both p_bar1 and p_bar2 are binomially distributed. The normal distribution can be used to approximate this binomial distribution because the requirements that np and qp are greater than 5 for both p_bar1 and p_bar2 . The distribution of the sample proportion, p_bar2–p_bar1, can therefore be approximated by the normal distribution.

The sample proportion, p_bar2–p_bar1, will be mapped to a normal distribution. Each unique normal distribution can be fully described by two parameters: its mean and standard deviation.

The mean of the normal distribution curve that maps the distributed variable p_bar is equal to the Constant in the Null Hypothesis. The Null Hypothesis is as follows:

H0: p_bar2–p_bar1 = Constant = 0

The distributed variable p_bar2–p_bar1 will be mapped to a normal distribution curve with a mean = 0, which is the Constant.

Population parameters such as population standard deviation have to be estimated if only sample data is available. In this case the population standard deviation will be estimated by the Standard Error which is based on the sample size.

Standard Error (SEDiff) for a pooled, two-independent-sample Hypothesis Test of Proportion is calculated as follows:

hypothesis test of proportion,hypothesis test, excel,excel 2010,excel 2013,statistics
(Click On Image To See a Larger Version)

ppooled = (X1 + X2)/(n1 + n2) = (90 + 59)/(200 + 100) = 0.50

qpooled = 1 - ppooled = 1 – 0.50 = 0.50

hypothesis test of proportion,hypothesis test, excel,excel 2010,excel 2013,statistics
(Click On Image To See a Larger Version)

SEDiff = SQRT[ ppooled * qpooled * (1/n1 + 1/n2) ]

SEDiff = SQRT[ 0.50 * 0.50 * (1/200 + 1/100) ] = 0.06

The normal distribution curve that maps the distribution of variable p_bar2–p_bar1 now has the following parameters:

Mean = 0

Standard Error = 0.06

This Excel-generated normal distribution curve is shown as follows:

hypothesis test of proportion,hypothesis test, excel,excel 2010,excel 2013,statistics (Click On Image To See a Larger Version)

 

Step 3 – Map the Regions of Acceptance and Rejection

The goal of a hypothesis test is to determine whether to accept or reject the Null Hypothesis at a given level of certainty. If the two things being compared are far enough apart from each other, the Null Hypothesis (which states that the two things are not different) can be rejected.

In this case we are trying to show graphically how different the observed p_bar2–p_bar1 (0.14) is from the hypothesized p_bar2–p_bar1 (0).

This Hypothesis Test of Proportion calculates the probability of a difference sample having a difference proportion equal to the observed p_bar2–p_bar1 (0.14) if the true difference equals 0 and the difference sample proportion is normally distributed.

The Regions of Acceptance and Rejection

The normal distribution curve that maps the distribution of variable p_bar2–p_bar1 can be divided up into two types of regions: the Region of Acceptance and the Region of Rejection.

If p_bar2–p_bar1’s observed value of 0.14 falls in the Region of Acceptance, we fail to reject the Null Hypothesis. If p_bar2–p_bar1 falls in the Region of Rejection, we reject the Null Hypothesis.

This is a two-tailed test because the Region of Rejection is split between both outer tails. The Alternative Hypothesis indicates this. A hypothesis test is non-directional if the Alternative Hypothesis has the non-directional operator “not equal to.”

A hypothesis test is a one-tailed test if the Alternative Hypothesis has a directional operator, i.e., “greater than” or “less than.” A one-tailed test has the entire Region of Rejection contained in one outer tail. A “greater than” operator indicates a right-tailed test. A “less than” operator indicates a left-tailed test.

In this case the Alternative Hypothesis is the following:

H1: p_bar2–p_bar1 ≠ 0

This Alternate Hypothesis indicates that the hypothesis test has the Region of Rejection split between both outer tails and is therefore two-tailed.

The total size of the Region of Rejection is equal to Alpha. In this case Alpha, α, is equal to 0.05. This means that the Region of Rejection will take up 5 percent of the total area under this normal distribution curve.

Because this test is a two-tailed test, the 5 percent Region of Rejection is divided up between the two outer tails. Each outer tail contains 2.5 percent of the total 5 percent is the Region of Rejection.

Calculate Critical Values

The Critical Value is the boundary of the Region of Rejection. The Critical Value is the boundary on either side of the curve beyond which 2.5 percent of the total area under the curve exists. In this case both Critical Values can be found by the following:

Critical Values = Mean ± (Number of Standard Errors from Mean to Region of Rejection) * SE

Critical Values = Mean ± NORM.S.INV(1-α/2) * SEDiff

Critical Values = 0 ± NORM.S.INV(1- 0.05/2 ) * 0.06

Critical Values = 0 ± NORM.S.INV(0.975) * 0.06

Critical Values = 0 ± 0.12

Critical Values = -0.12 and +0.12

The Region of Rejection is therefore everything that is to the right of 0.12 and everything to the left of -0.12.

This Excel-generated normal distribution curve with the blue Region of Acceptance in the center and the yellow Regions of Rejection in the outer tails is shown is as follows:

hypothesis test of proportion,hypothesis test, excel,excel 2010,excel 2013,statistics (Click On Image To See a Larger Version)

 

Step 4 – Determine Whether to Reject Null Hypothesis

The object of a hypothesis test is to determine whether to accept of reject the Null Hypothesis. There are three equivalent tests that determine whether to accept or reject the Null Hypothesis. Only one of these tests needs to be performed because all three provide equivalent information. The three tests are as follows:

 

1) Compare p_bar2–p_bar1 With Critical Value

If the observed value of p_bar2–p_bar1 (0.14) falls into the Region of Acceptance (the blue region under the curve), the Null Hypothesis is not rejected. If the observed value of p_bar2–p_bar1 falls into the Regions of Rejection (either of the two yellow outer regions), the Null Hypothesis is rejected.

The observed p_bar2–p_bar1 (0.14) is farther to the curve’s mean (0) than the Critical Value on the right side (+0.118) and falls in the yellow Region of Rejection. We therefore reject the Null Hypothesis. We can state with 95 percent certainty that there is a real difference between the overall proportions of male and female employees who prefer the proposed plan based upon the small samples taken each of the two populations.

 

2) Compare z Value With Critical z Value

The Test Statistic for this Hypothesis Test is called the z Value. The z Value is the number of Standard Errors that the observed p_bar2–p_bar1 is from the mean of zero. The Critical z Value is the number of Standard Errors that the Critical z Value is from the mean.

If the z Value is closer to the standardized mean of zero than the Critical z Value, the Null Hypothesis is not rejected. If the z Value is farther from the standardized mean of zero than the Critical z Value, the Null Hypothesis is rejected. The test Statistic is calculated as follows:

hypothesis test of proportion,hypothesis test, excel,excel 2010,excel 2013,statistics
(Click On Image To See a Larger Version)

z Value (the Test Statistic) = (p_bar2–p_bar1 - Constant) / SEDiff

z Value (the Test Statistic) = (0.59 – 0.45 – 0)/0.06

z Value (the Test Statistic) = 2.29

Critical z Valueα=0.05,two-tailed,right tail = NORM.S.INV(1-α/2)

(Note that the two-tailed Critical z Value in the left tail = NORM.S.INV(α/2)

Critical z Valueα=0.05,two-tailed,right tail = NORM.S.INV(0.975) = 1.96

This means that the observed p_bar2–p_bar1 (0.14) is 2.29 Standard Errors from the curve’s mean (0).

Critical z Valueα=0.05,two-tailed = ±NORM.S.INV(1-α/2)

Critical z Valueα=0.05,two-tailed = ±NORM.S.INV(0.975) = 1.96

This means that the left and right boundaries of the Regions of Rejection are 1.96 Standard Errors from the curve’s mean.

The z Value (2.29) is farther to the curve’s standardized mean of zero than the Critical z Value (1.96) so the Null Hypothesis is rejected.

 

3) Compare p Value With Alpha

The p Value is the percent of the curve that is beyond the observed p_bar2–p_bar1 (0.14). If the p Value is smaller than Alpha/2 (since this is a two-tailed test), the Null Hypothesis is rejected. If the p Value is larger than Alpha/2, the Null Hypothesis is not rejected.

The p Value is calculated by the following Excel formula:

p Value = MIN(NORM.S.DIST(z Value,TRUE),1-NORM.S.DIST(z Value,TRUE))

p Value = MIN(NORM.S.DIST(2.29,TRUE),1-NORM.S.DIST(2.29,TRUE))

p Value = 0.0111

The p Value (0.0111) is smaller than Alpha/2 (0.025) and we therefore reject the Null Hypothesis.

The following Excel-generated graph shows that the red p Value (the curve area beyond p_bar2–p_bar1) is smaller than the yellow Alpha/2 Region of rejection in the outer right tail.

hypothesis test of proportion,hypothesis test, excel,excel 2010,excel 2013,statistics (Click On Image To See a Larger Version)

It should be noted that if this z Test were a one-tailed test, the Null Hypothesis would also be rejected because a two-tailed Hypothesis Test is more stringent than a one-tailed test.

The one and two-tailed tests both calculate the same p Value (0.011), z Value (2.29), and observed value of p_bar2–p_bar1 (0.14) . The critical values that these are compared to are different between the one and two-tailed tests. These critical values are the Critical Value, the Critical z Value, and the area of rejection in one outer tail of the Region of Rejection.

Critical values for a one-tailed would be the following:

Critical Value = Mean + NORM.S.INV(1-α) * SEDiff

Critical Value = 0 + NORM.S.INV(1- 0.05 ) * 0.06

Critical Value = 0 + NORM.S.INV(0.95) * 0.06

Critical Value = 0.0987

Critical z Valueα=0.05,one-tailed,right tail = NORM.S.INV(1-α)

Critical z Valueα=0.05,one-tailed,right tail = NORM.S.INV(0.95) = 1.64

Region of Rejection area in the right outer tail = α = 0.05.

Note that one of the main differences between critical values for a one and two-tailed test is that the one-tailed test critical values are calculated using α while the two-tailed critical values are calculated using α/2.

 

Excel Master Series Blog Directory

Statistical Topics and Articles In Each Topic

 

No comments:

Post a Comment