Friday, May 30, 2014

2-Sample Pooled t-Test in 4 Steps in Excel 2010 and Excel 2013

This is one of the following eight articles on 2-Independent-Sample Pooled t-Tests in Excel

2-Independent-Sample Pooled t-Test in 4 Steps in Excel 2010 and Excel 2013

Excel Variance Tests: Levene’s, Brown-Forsythe, and F Test For 2-Sample Pooled t-Test in Excel 2010 and Excel 2013

Excel Normality Tests Kolmogorov-Smirnov, Anderson-Darling, and Shapiro Wilk Tests For Two-Sample Pooled t-Test

Two-Independent-Sample Pooled t-Test - All Excel Calculations

2-Sample Pooled t-Test – Effect Size in Excel 2010 and Excel 2013

2-Sample Pooled t-Test Power With G*Power Utility

Mann-Whitney U Test in 12 Steps in Excel as 2-Sample Pooled t-Test Nonparametric Alternative in Excel 2010 and Excel 2013

2- Sample Pooled t-Test = Single-Factor ANOVA With 2 Sample Groups

 

Two-Independent-

Sample, Pooled t-Test in 4

Steps in Excel

This hypothesis test evaluates two independent samples to determine whether the difference between the two sample means (x_bar1 and x_bar2) is equal to (two-tailed test) or else greater than or less than (one-tailed test) than a constant. This is a pooled test because a single pooled standard deviation replaces both sample standard deviations because they are similar enough.

x_bar1 - x_bar2 = Observed difference between the sample means

t-test,t test,pooled t test,pooled t-test,excel,excel 2010,excel 2013,stastistics
(Click On Image To See a Larger Version)

t-test,t test,pooled t test,pooled t-test,excel,excel 2010,excel 2013,stastistics
(Click On Image To See a Larger Version)

Pooled t-Tests are performed if the variances of both sample groups are similar. A rule-of-thumb is as follows: A Pooled t-Test should be performed if the standard deviation of one sample, s1, is no more than twice as large as the standard deviation in the other sample s2. That is the case here for the following example.

dfpooled = degrees of freedom = n1 + n2 – 2

t-test,t test,pooled t test,pooled t-test,excel,excel 2010,excel 2013,stastistics
(Click On Image To See a Larger Version)

Null Hypothesis H0: x_bar1 - x_bar2 = Constant

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

1) The observed x_bar1 - x_bar2 is beyond the Critical Value.

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

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

 

Example of 2-Independent-Sample,

1-Tailed, Pooled t-Test in Excel

In this example two different brand of the same type of battery are being tested to determine if there probably is a real difference in the average length of time that batteries from each of the two brands last. The length of each battery’s lifetime of operation in minutes was recorded. Determine with 95 percent certainty whether Brand A batteries have a longer average lifetime than Brand B batteries.

Here are the data samples from batteries of the two brands:

t-test,t test,pooled t test,pooled t-test,excel,excel 2010,excel 2013,stastistics
(Click On Image To See a Larger Version)

Running the Excel data analysis tool Descriptive Statistics separately on each sample group produces the following output:

t-test,t test,pooled t test,pooled t-test,excel,excel 2010,excel 2013,stastistics (Click On Image To See a Larger Version)

Note that when performing two-sample t-Tests in Excel, always designate Sample 1 (Variable 1) to be the sample with the larger mean.

The results of the Pooled t-Test will be more intuitive if the sample group with the larger mean is designated as the first sample and the sample group with the smaller mean is designated as the second sample.

Another reason for designating the sample group with the larger mean as the first sample is to obtain the correct result from the Excel data analysis tool t-Test: Two-Sample Assuming Equal Variances. The test statistic (T Stat in the Excel output) and the Critical t value (t Critical two-tail in the Excel output) will have the same sign (as they always should) only if the sample group with the larger mean is designated the first sample.

 

Summary of Problem Information

Sample Group 1 – Brand A (Variable 1)

x_bar1 = sample1 mean = AVERAGE() = 43.56

µ1 (Greek letter “mu”) = population mean from which Sample 1 was drawn = Not Known

s1 = sample1 standard deviation =STDEV.S() = 16.92

Var1 = sample1 variance =VAR() = 286.13

σ1 (Greek letter “sigma”) = population standard deviation from which Sample 1 was drawn = Not Known

n1 = sample1 size = COUNT() = 16

 

Sample Group 2 – Brand B (Variable 2)

x_bar2 = sample2 mean = AVERAGE() = 33.53

µ2 (Greek letter “mu”) = population mean from which Sample 2 was drawn = Not Known or needed to solve this problem

s2 = sample2 standard deviation =STDEV.S() = 15.28

Var2 = sample2 variance =VAR() = 233.39

σ2 (Greek letter “sigma”) = population standard deviation from which Sample 2 was drawn = Not Known or needed to solve this problem

n2 = sample2 size = COUNT() = 17

x_bar1 - x_bar2 = 43.56 – 33.53 = 10.03

Level of Certainty = 0.95

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

As with all Hypothesis Tests of Mean, 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

What Type of Test Should Be Done?

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 or t Distribution 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 t Value Test

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

 

Question 1) What Type of Test Should Be Done?

a) Hypothesis Test of Mean or Proportion?

This is a Hypothesis Test of Mean because each individual observation (each sampled battery’s lifetime) within each of the two sample groups can have a wide range of values. Data points for Hypothesis Tests of Proportion are binary: they can take only one of two possible values.

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

This is a two-sample hypothesis test because two independent samples are being compared with each other. The two sample groups are the lifetimes in minutes of 16 Brand A batteries and the lifetimes of 17 Brand B batteries.

c) Independent or Dependent (Paired) Test?

It is an unpaired test because data observations in each sample group are completely unrelated to data observations in the other sample group. The designation of “paired” or “unpaired” applies only for two-sample hypothesis tests.

d) One-Tailed or Two-Tailed Test?

The problem asks to determine whether the average lifetime of Brand A batteries is greater than the average lifetime of Brand B batteries. This is a directional inequality making this hypothesis test a one-tailed test. If the problem asked whether the average lifetimes of both brands was simply different, the inequality would be non-directional and the resulting hypothesis test would be a two-tailed test. A two-tailed test is more stringent than a one-tailed test.

e) t-Test or as a z-Test?

A two-independent-sample hypothesis test of mean must be performed as a t-Test if sample size is small (n1 + n2 < 40). In this case the sample size is small as n1 + n2 = 33. This Hypothesis Test of Mean must be performed as a t-Test. A t-Test uses the t distribution and not the normal distribution as does a z-Test.

f) Pooled or Unpooled t-Test?

Pooled t-Tests are performed if the variances of both sample groups are similar. A rule-of-thumb is as follows: A Pooled t-Test should be performed if the standard deviation of one sample is no more than twice as large as the standard deviation in the other sample. That is the case here as the following are true:

s1 = sample1 standard deviation = 16.92

and

s2 = sample2 standard deviation = 15.28

The Null Hypothesis of the Brown-Forsythe Test states that the average distance to the median for the two groups are the same. Acceptance of this Null Hypothesis would imply that the sample groups have the same variances. The p Value shown in the Excel ANOVA output equals 0.6627. This is much larger than the Alpha (0.05) that is typically used for an ANOVA Test so the Null Hypothesis cannot be rejected.

We therefore conclude as a result of the Brown-Forsythe Test that the variances are the same or, at least, that we don’t have enough evidence to state that the variances are different.

Each of the above tests can be considered relatively equivalent to the others. The variances of both sample groups are verified to be similar enough to permit using a Pooled test for this two-independent sample hypothesis test.

This hypothesis test is a t-Test that is two-independent-sample, one-tailed, Pooled hypothesis test of mean.

 

Question 2) Requirements Met?

a) Normal Distribution of Both Sample Means

A t-Test can be performed if the distribution of the Test Statistic (the t value) can be approximated under the Null Hypothesis by the t Distribution. The t Value for this test is calculated as follows:

t-test,t test,pooled t test,pooled t-test,excel,excel 2010,excel 2013,stastistics

To perform a hypothesis test that is based on the normal distribution or t distribution, both sample means must be normally distributed. In other words, if we took multiple samples just like either one of the two mentioned here, the means of those samples would have to be normally distributed in order to be able to perform a hypothesis test that is based upon the normal or t distributions.

For example, 30 independent, random samples of the battery lifetimes from each of the two battery brands could be evaluated just like the single sample of the lifetimes of 15+ batteries from each of the two battery brands as mentioned here. If the means of all of the 30 samples from one battery brand and, separately, the means of the other 30 samples from the other battery brand are normally distributed, a hypothesis test based on the normal or t distribution can be performed on the two independent samples taken.

 

The means of the samples would be normally distributed if any of the following are true:

 

1) Sample Size of Both Samples Greater Than 30

The Central Limit Theorem states that the means of similar-sized, random, independent samples will be normally distributed if the sample size is large (n >30) no matter how the underlying population from which the samples came from is distributed. In reality, the distribution of sample means converges toward normality when n is as small as 5 as long as the underlying population is not too skewed.

 

2) Both Populations Are Normally Distributed

If this is the case, the means of similar sized, random, independent samples will also be normally distributed. It is quite often the case that the distribution of the underlying population is not known and should not be assumed.

 

3) Both Samples Are Normally Distributed

If the sample is normally distributed, the means of other similar-sized, independent, random samples will also be normally distributed. Normality testing must be performed on the sample to determine whether the sample is normally distributed.

In this case the sample size for both samples is small: n1 and n2 are both less than 30. The normal distribution of both sample means must therefore be tested and confirmed. Normality testing on each of the samples has to be performed to confirm the normal distribution of the means of both samples.

 

b) Similarity of Sample Variances

The two-independent sample, Pooled t-Test requires that the two independent samples have similar variances. Samples that have similar variances are said to be homoscedastistic. Samples that have significantly different variances are said to be heteroscedastistic. The samples in this example have the similar variance variances. This is confirmed by the variances comparison tests that were previously mentioned in this example.

 

c) Independence of Samples

This type of a hypothesis test requires both samples be totally independent of each other. In this case they are completely independent. There is no relationship between the observations that make up each of the two sample groups.

 

Evaluating the Normality of the Sample Data

The following five normality tests will be performed on the sample data in a blog article shortly after this one:

An Excel histogram of the sample data will be created.

A normal probability plot of the sample data will be created in Excel.

The Kolmogorov-Smirnov test for normality of the sample data will be performed in Excel.

The Anderson-Darling test for normality of the sample data will be performed in Excel.

The Shapiro-Wilk test for normality of the sample data will be performed in Excel.

The quickest way to evaluate normality of a sample is to construct an Excel histogram from the sample data.

Histogram in Excel

t-test,t test,pooled t test,pooled t-test,excel,excel 2010,excel 2013,stastistics (Click On Image To See a Larger Version)

To create this histogram in Excel, fill in the Excel Histogram dialogue box as follows:

clip_image008 (Click On Image To See a Larger Version)

clip_image009 (Click On Image To See a Larger Version)

To create this histogram in Excel, fill in the Excel Histogram dialogue box as follows:

clip_image010 (Click On Image To See a Larger Version)

Both sample groups appear to be distributed reasonably closely to the bell-shaped normal distribution. It should be noted that bin size in an Excel histogram is manually set by the user. This arbitrary setting of the bin sizes can has a significant influence on the shape of the histogram’s output. Different bin sizes could result in an output that would not appear bell-shaped at all. What is actually set by the user in an Excel histogram is the upper boundary of each bin.

 

When Data Are Not Normally Distributed

When normality of data cannot be confirmed for a small sample, it is necessary to substitute a nonparametric test for a t-Test. Nonparametric tests do not have the same normality requirement that the t-Test does. The most common nonparametric test that can be substituted for the two-independent-sample t-Test when data normality cannot be confirmed is the Mann-Whitney U Test.

The Mann-Whitney U Test is performed on the data in this example at the end of this section. Nonparametric tests are generally less powerful (less able to detect a difference) than parametric tests. The parametric two-independent sample, one-tailed t-Test performed here does detect a difference at alpha = 0.05. the nonparametric Mann-Whitney U test conducted at the end of this section on the same data did not detect a difference at alpha = 0.05.

The required questions have been satisfactorily answered. We will however perform the t-Test to demonstrate how a two-independent-sample, Pooled t-Test is done. We now proceed to complete the four-step method for solving all Hypothesis Tests of Mean.

 

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 Null and Alternate 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 average optimism scores for both sample groups are the same. We will use the variable x_bar1-x_bar2 to represent the difference between the means of the two groups. If the mean scores for both groups are the same, then the difference between the two means, x_bar1-x_bar2, would equal zero. The Null Hypothesis is as follows:

H0: x_bar1-x_bar2 = Constant = 0

The Alternate Hypothesis is always in inequality and states that the two items being compared are different. This hypothesis test is trying to determine whether the mean of the population from which the first sample (x_bar1) was taken is greater than the mean of the population from which the second sample was taken (x_bar2). The Alternate Hypothesis is as follows:

H1: x_bar1-x_bar2 > Constant, which is 0

H1: x_bar1-x_bar2 > 0

The Alternative Hypothesis is directional (“greater than” or “less than” instead of “not equal”) and the hypothesis test is therefore a one-tailed test. The “greater than” operator in the Alternative hypothesis indicates that this one-tailed test occurs in the right tail. 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.

The following formulas are used by the Two-Independent Sample, Pooled t-Test:

 

Pooled Degrees of Freedom

df = degrees of freedom = n1 + n2 - 2

df = 16 + 17 – 2 = 31

 

Pooled Sample Standard Deviation

t-test,t test,pooled t test,pooled t-test,excel,excel 2010,excel 2013,stastistics
(Click On Image To See a Larger Version)

sPooled = SQRT[{(n1-1)s12 +(n2-1)s22}/df]

sPooled = SQRT[{(16-1)*(16.915)2 +(17-1)*(15.277)2}/31]

sPooled = 16.09

 

Pooled Sample Standard Error

t-test,t test,pooled t test,pooled t-test,excel,excel 2010,excel 2013,stastistics
(Click On Image To See a Larger Version)

SEPooled = sPooled *SQRT(1/n1 + 1/n2)

SEPooled = 16.09 * SQRT(1/16 + 1/17)

SEPooled = 5.6046

Note that this calculation of the Standard Error using the sample variance, s2, is an estimate of the true Standard Error which would be calculated using the population variance, σ2, of the populations from which the samples were drawn.

These parameters are used to map the distributed variable, x_bar1-x_bar2, to the t Distribution as follows:

 

Step 2 – Map Distributed Variable on a t-Distribution Curve

A t-Test can be performed if the sample mean, and the Test Statistic (the t Value) are distributed according to the t Distribution. If the sample has passed a normality test, the sample mean and closely-related Test Statistic are distributed according to the t Distribution.

The t Distribution always has a mean of zero and a standard error equal to one. The t Distribution varies only in its shape. The shape of a specific t Distribution curve is determined by only one parameter: its degrees of freedom, which equals n – 1 if n = sample size.

The means of similar, random samples taken from a normal population are distributed according to the t Distribution. This means that the distribution of a large number of means of samples of size n taken from a normal population will have the same shape as a t Distribution with its degrees of equal to n – 1.

The sample mean and the Test Statistic are both distributed according to the t Distribution with degrees of freedom equal to n – 1 if the sample or population is shown to be normally distributed. This step will map the sample mean to a t Distribution curve with a degrees of freedom equal to n – 1.

The t Distribution is usually presented below in this Excel-generated graph in its finalized form with standardized values of a mean that equals zero and a standard error that equals one. The horizontal axis is given in units of Standard Errors and the distributed variable is the t Value (the Test Statistic) as follows:

t-test,t test,pooled t test,pooled t-test,excel,excel 2010,excel 2013,stastistics (Click On Image To See a Larger Version)

A non-standardized t Distribution curve would simply have its horizontal axis given in units of the measure used to take the samples. The distributed variable would be the sample mean, x_bar1-x_bar2.

The variable x_bar1-x_bar2 is distributed according to the t Distribution. Mapping this distributed variable to a t Distribution curve is shown in this Excel-generated graph as follows:

t-test,t test,pooled t test,pooled t-test,excel,excel 2010,excel 2013,stastistics
(Click On Image To See a Larger Version)

This non-standardized t Distribution curve is constructed from the following parameters:

Mean = 0, which is the Constant taken from the Null Hypothesis

Standard Error Pooled = 5.604

Degrees of Freedom = 31

Distributed Variable = : x_bar1-x_bar2

 

Step 3 – Map the Regions of Acceptance and Rejection

The goal of a hypothesis test is to determine whether to reject or fail to 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 x_bar1 is from x_bar2 by showing how different x_bar1-x_bar2 (10.033) is from zero.

The non-standardized t Distribution curve can be divided up into two types of regions: the Region of Acceptance and the Region of Rejection. A boundary between a Region of Acceptance and a Region of Rejection is called a Critical Value.

If the difference between the sample means, x_bar1-x_bar2 (10.033), falls into a Region of Rejection, the Null Hypothesis is rejected. If the difference between the sample means, x_bar1-x_bar2 (10.033), falls into a Region of Acceptance, the Null Hypothesis is not rejected.

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 t distribution curve.

This 5 percent Alpha (Region of Rejection) is entirely contained in the outer right tail. The operator in the Alternative Hypothesis whether the hypothesis test is two-tailed or one-tailed and, if one tailed, which outer tail. The Alternative Hypothesis is the follows:

H1: x_bar1-x_bar2 > 0

A “greater than” or “less than” operator indicates that this will be a one-tailed test. The “greater than” sign indicates that the Region of Rejection will be in the right tail.

The boundaries between Regions of Acceptance and Regions of Rejection are called Critical Values. The locations of these Critical Values need to be calculated.

Calculate Critical Values

One-Tailed Critical Values

A Critical Value is the boundary between a Region of Acceptance and a Region of Rejection. The entire 5-percent alpha region lies beyond the Critical Value because this is a one-tailed test. The Critical Value can be found as follows:

Critical Value = Mean + (Number of Standard Errors from Mean to Region of Rejection) * SE

Critical Value = Mean + T.INV(1-α,df) * SE

Critical Value = 0 + T.INV(1-0.05, 31) * 5.604

Critical Value = 0 + 9.503

Critical Value = +9.503

The Region of Rejection therefore includes everything that is to the right of +9.503.

This Excel-generated distribution curve graph with the blue Region of Acceptance and the yellow Region of Rejection is shown is as follows:

t-test,t test,pooled t test,pooled t-test,excel,excel 2010,excel 2013,stastistics (Click On Image To See a Larger Version)

If this were a two-tailed test, the Critical values would be determined as follows:

Two-Tailed Critical Values

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

Critical Values = Mean ± T.INV(1-α/2,df) * SE

Critical Values = 0 ± T.INV(0,975, 31) * 5.604

Critical Values = 0 ± 11.43

Critical Values = -11.43 and +11.43

The Critical Values for the two-tailed test (-11.43 and +11.43) are farther from the mean than the Critical Value for one-tailed test (+9.503). This means that a two-tailed test is more stringent than a one-tailed test.

 

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 the Sample Mean x_bar1-x_bar2 With Critical Value

Reject the Null Hypothesis if the sample mean, x_bar1-x_bar2 = 10.033, falls into the Region of Rejection. Do not reject the Null Hypothesis if the sample mean, x_bar1-x_bar2 = 10.033, falls into the Region of Acceptance

Equivalently, reject the Null Hypothesis if the sample mean, x_bar1-x_bar2 = 10.033, is further the curve’s mean of 0 than the Critical Value.

The Critical Value has been calculated to be 9.503. The observed x_bar1-x_bar2 (10.033) is further from the curve mean (0) than Critical Value (9.503). The Null Hypothesis would therefore be rejected.

 

2) Compare t Value With Critical t Value

The t Value is the number of Standard Errors that x_bar1-x_bar2 (10.033) is from the curve’s mean of 0.

The Critical t Value is the number of Standard Errors that the Critical Value (9.503) is from the curve’s mean.

Reject the Null Hypothesis if the t Value is farther from the standardized mean of zero than the Critical t Value.

The t Value, the Test Statistic in a t-Test, is the number of Standard Errors that x_bar1-x_bar2 is from the mean. The Critical t Value is the number of Standard Errors that the Critical Value is from the mean. If the t Value is larger than the Critical t Value, the Null Hypothesis can be rejected.

t-test,t test,pooled t test,pooled t-test,excel,excel 2010,excel 2013,stastistics
(Click On Image To See a Larger Version)

t Value (test statistic) = (x_bar1 - x_bar2 - 0) / SE

t Value (test statistic) = (10.033)/5.604 = 1.790

One-Tailed (Right Tail) Critical t Value = T.INV(1-α,df)

One-Tailed (Right Tail) Critical t Value = T.INV(1-0.05, 31) = 1.696

This indicates that (x_bar1 - x_bar2) is 1.696 standard errors to the right of the Constant, which is 0.

The t Value (1.790) is farther from the standardized mean of zero than the Critical t Value (1.696) so the Null Hypothesis is rejected.

 

3) Compare the p Value With Alpha

The p Value is the percent of the curve that is beyond x_bar1-x_bar2 (10.033). If the p Value is smaller than Alpha, the Null Hypothesis is rejected.

p Value = T.DIST.RT(ABS(t Value), df)

p Value = T.DIST.RT(ABS(1.790), 31)

p Value = 0.042

The p Value (0.042) is smaller than Alpha (0.05) and we therefore reject the Null Hypothesis. A graph below shows that the red p Value (the curve area beyond x_bar1-x_bar2) is smaller than the yellow Alpha, which is the 5 percent Region of Rejection in the outer right tail. This is shown in the following Excel-generated graph of this non-standardized t Distribution curve:

t-test,t test,pooled t test,pooled t-test,excel,excel 2010,excel 2013,stastistics (Click On Image To See a Larger Version)

The value of x_bar1-x_bar2, 10, has a t Value of 1.79 and therefore is 1.79 standard errors from the mean. This is further from the mean than the critical value of 9.6, which is the t critical distance of 1.69 standard errors from the mean.

It should be noted that if this t-Test were a two-tailed test, which is more stringent than a one-tailed test, the Null Hypothesis would be accepted because:

1) The p Value (0.042) would now be larger than Alpha/2 (0.025)

2) x_bar1-x_bar2 (10.033) would now be in the Region of Acceptance, which would now have its outer right boundary at 11.43 (mean + T.INV(1-α/2,df)*SE)

 

Excel Master Series Blog Directory

Statistical Topics and Articles In Each Topic

 

No comments:

Post a Comment