Statistical Computing I
Asrat D.
DIRE DAWA UNIVERSITY
COLLEGE OF NATURAL AND COMPUTATIONAL SCIENCES
DEPARTMENT OF SATATISTICS
January, 2022
Asrat D. (DDU) Statistical Computing I January, 2022 1 / 37
Chapter 4: T Tests and One Way ANOVA using SPSS
Outlines
4 T Tests and One Way ANOVA using SPSS
4.1 Introduction
4.2 One Sample T-Test
4.3 Independent Sample T-Test
4.4 Paired T-Test
4.5 One Way ANOVA
3.6 Report writing of the Analysis Results
Asrat D. (DDU) Statistical Computing I January, 2022 2 / 37
Chapter 4: T Tests and One Way ANOVA using SPSS
Chapter Objectives
When you have completed this chapter you will be able to;
Check the assumption of parametric tests
Conduct one sample t test, indepandent and paired t test,
Compare means using t-test and ANOVA
Report the result of the analysis
Asrat D. (DDU) Statistical Computing I January, 2022 3 / 37
Chapter 4: T Tests and One Way ANOVA using SPSS
7.1) Introduction
B Estimation and hypothesis testing of the two general areas of statistical
inference.
Asrat D. (DDU) Statistical Computing I January, 2022 4 / 37
Chapter 4: T Tests and One Way ANOVA using SPSS
Cont’d...
Asrat D. (DDU) Statistical Computing I January, 2022 5 / 37
Chapter 4: T Tests and One Way ANOVA using SPSS
Statistical estimation
B Estimate
1 Point estimate: Sample mean, sample proportion
2 Interval estimate: confidence interval for mean, confidence interval for
proportion
B Point estimate is always within the interval estimate
Asrat D. (DDU) Statistical Computing I January, 2022 6 / 37
Chapter 4: T Tests and One Way ANOVA using SPSS
Cont’d...
Asrat D. (DDU) Statistical Computing I January, 2022 7 / 37
Chapter 4: T Tests and One Way ANOVA using SPSS
Cont’d....
B Sample Statistics as Estimators of Population Parameters.
B Parameter = Statistic ± ItsError
B An estimator of a population parameter is a sample statistic used to
estimate or predict the population parameter.
B A point estimate is a single value used as an estimate of a population
parameter.
B The objective of estimation is to determine the approximate value of a
population parameter on the basis of a sample statistic.
B There are two types of estimators:
Asrat D. (DDU) Statistical Computing I January, 2022 8 / 37
Chapter 4: T Tests and One Way ANOVA using SPSS
Cont’d...
B For example, suppose we want to estimate the mean income of sociology
students. For n=25 students, is calculated to be X̄ = 40$/week. Then,
The point estimate of population mean is 40$
The interval estimate of population mean income is between 380 and
420 $/week
Asrat D. (DDU) Statistical Computing I January, 2022 9 / 37
Chapter 4: T Tests and One Way ANOVA using SPSS
Confidence Interval for µ
B The probability (1 − α)X 100% is called the confidence level.
B The population mean is a fixed but unknown quantity. Its incorrect to
interpret the confidence interval estimate as a probability statement about.
B The interval acts as the lower and upper limits of the interval estimate of
the population mean.
Asrat D. (DDU) Statistical Computing I January, 2022 10 / 37
Chapter 4: T Tests and One Way ANOVA using SPSS
General Steps in Hypotesis Testing
B E.g.: Test the assumption that the true mean number of of TV sets in U.S.
homes is at least three (σ Known)
Asrat D. (DDU) Statistical Computing I January, 2022 11 / 37
Chapter 4: T Tests and One Way ANOVA using SPSS
Cont’d...
Asrat D. (DDU) Statistical Computing I January, 2022 12 / 37
Chapter 4: T Tests and One Way ANOVA using SPSS
Cont’d...
Null & Alternative Hypotheses
B H0 Null Hypothesis states the Assumption to be tested e.g. SBP of par-
ticipants=120 (H0 : µ = 120).
B H1 Alternative Hypothesis is the opposite of the null hypothesis (SBP of
participants , 120 (H1 : µ , 120). It may or may not be accepted and it is
the hypothesis that is believed to be true by the researcher.
Level of Significance α
Defines unlikely values of sample statistic if null hypothesis is true,
Called rejection region of sampling distribution
Typical values are 0.01, 0.05.
Selected by the Researcher at the Start
Provides the Critical Value(s) of the Test
Asrat D. (DDU) Statistical Computing I January, 2022 13 / 37
Chapter 4: T Tests and One Way ANOVA using SPSS
Cont’d...
Level of Significance, α and the Rejection Region
B Definition: A P-Value is the smallest level of significance or the smallest
value of α for which the null hypothesis is to be rejected. For example:
If p-value = 0.002, then we can reject the null hypothesis for all values
ofα greater than 0.002 (such as α = 0.01 = 1%, α = 5% levels of
significance).
If p-value = 0.03, then we can reject the null hypothesis for all values
of α greater than 0.03.
Note: In SPSS output, the p-value corresponds to the value of Sig
Asrat D. (DDU) Statistical Computing I January, 2022 14 / 37
Chapter 4: T Tests and One Way ANOVA using SPSS
Cont’d...
The t- test is a useful technique for comparing mean values of two
sets of numbers.
The comparison will provide you with a statistic for evaluating whether
the difference between two means is statistically significant.
T tests can be used to compare:
two independent groups (independent-samples t test) or
to compare observations from two measurement occasions for the
same group (pairedsamples t test).
If you are using the t test to compare two groups, the groups should
be randomly drawn from normally distributed and independent
populations.
If you have more than two groups or more than two variables, you
should use the One-Way ANOVA option.
There are four types of t tests; the options are all located under the
Analyze menu item: Analyze, Compare Means, One-Sample T
test..., Independent-Samples T test..., Paired-Samples T test...,
One-Way ANOVA ...
Asrat D. (DDU) Statistical Computing I January, 2022 15 / 37
Chapter 4: T Tests and One Way ANOVA using SPSS
4.2) One Sample T-Test
The one-sample t test is used compare a single sample with a
population value.
For example, a test could be conducted to compare the average
salary of managers within a company with a value that was known to
represent the national average for managers.
From the analyze menu:
Analyze → Compare Means → One-Sample T Test
Then, the following dialog box will produce
Asrat D. (DDU) Statistical Computing I January, 2022 16 / 37
Chapter 4: T Tests and One Way ANOVA using SPSS
Cont’d...
Move the variables to Test variable(s) box by selecting in the list and
clicking the arrow button
Enter the hypothesized mean in the Test Value
Click Option button to alter the Confidence Interval Percentage.
Click Continue then, click OK.
Example: The following data represents the weekly average level of earth
quick (in Rector Scale) for 10 weeks in Beijing. Test that the mean of the
earth quick level is different from 1.5 Rector Scale with 5% significance
level.
2.1 1.6 0.33 1.12 0.87 0.6 1.42 2.2 1.58 0.36
Asrat D. (DDU) Statistical Computing I January, 2022 17 / 37
Chapter 4: T Tests and One Way ANOVA using SPSS
Solution
B Your result should looks like the following
Two sections (boxes) appear in the output: One-Sample Statistics
and One-Sample Test.
The first section, One-Sample Statistics, provides basic information
about the selected variable, Earth Quick, including the valid
(nonmissing) sample size (n), mean, standard deviation, and
standard error.
Asrat D. (DDU) Statistical Computing I January, 2022 18 / 37
Chapter 4: T Tests and One Way ANOVA using SPSS
Cont’d...
In this example, the mean Earth Quick of the sample is 1.218, which
is based on 10 nonmissing observations and and 1.2180 is the point
estimate of the unknown population mean.
The second section, One-Sample Test, displays the results most
relevant to the One Sample t Test.
State Hypothesis to be tested (Step-1):
→ H0 : µ = 1.5 Vs H1 : µ , 1.5
Select α (Step-2): α = 0.05 (Given)
Select appropriate test statistics (Step 3):
→ t-test is appropriate and tcal = −1.322 from the output
Select tabulated value (Step 4):
→ tα/2 (n − 1) = t0.025 (9) = 2.262
Decision and Interpretation of results (step-5)
Asrat D. (DDU) Statistical Computing I January, 2022 19 / 37
Chapter 4: T Tests and One Way ANOVA using SPSS
Cont’d...
The decision-making process for a hypothesis test can be based on the
probability value (p-value) for the given test.
If the p-value is less than or equal to a predetermined level of
significance (α -level), then you reject the null hypothesis and claim
support for the alternative hypothesis.
If the p-value is greater than the α -level, you fail to reject the null
hypothesis and can not claim support for the alternative hypothesis.
Or using calculated value: If the calculated t value is greater than the
critical t value, then we reject the null hypothesis.
In the One sample T-Test table, |tcal | = | − 1.322| = 1.322, since |tcal | =
1.322 is less than t0.025 (9) = 2.262 (or the p-value (0.219), Since P-value is
greater than = 5% value), hence we dont reject the null hypothesis (H0 )and
provides no sufficient evidence that the mean of the earth quick level is
different from 1.5 at 5% level of significance.
Asrat D. (DDU) Statistical Computing I January, 2022 20 / 37
Chapter 4: T Tests and One Way ANOVA using SPSS
4.3) Independent Sample T-Test
Is a useful technique when the research question requires
comparison of two groups of samples (Independent sample t-test)
e.g. what is the effect of drug on teenagers? Does the monthly salary
of employees vary across gender?
it could be used to compare the salaries of managers and custodials
to evaluate whether there is a difference or not.
The variables used in this test are known as: Dependent variable, or
test variable and Independent variable, or grouping variable
The Hypothesis: For employment Data in SPSS
H0 : Managers and custodial employees do not differ in their mean
current salaries
H1 : Managers and custodial employees do differ in their current
salaries.
From the menu go to: Analyze > Compare Means > Independent
Samples T test to produce the following dialog box:
Asrat D. (DDU) Statistical Computing I January, 2022 21 / 37
Chapter 4: T Tests and One Way ANOVA using SPSS
Cont’d...
Asrat D. (DDU) Statistical Computing I January, 2022 22 / 37
Chapter 4: T Tests and One Way ANOVA using SPSS
Cont’d...
Asrat D. (DDU) Statistical Computing I January, 2022 23 / 37
Chapter 4: T Tests and One Way ANOVA using SPSS
Cont’d...
Two sections (boxes) appear in the output: Group Statistics and
Independent Samples Test.
The first section, Group Statistics, provides basic information about
the group comparisons, including the sample size (n), mean, standard
deviation, and standard error for current salary by group.
In this example, there are 27 Custodial and 84 Manager. The mean
current salary for custodial category 30,938$, and the mean current
salary for manager is 63,977$.
The second section, Independent Samples Test, displays the results
most relevant to the Independent Samples t Test.
There are two parts that provide different pieces of information: (A)
Levenes Test for Equality of Variances and (B) t-test for Equality
of Means.
Asrat D. (DDU) Statistical Computing I January, 2022 24 / 37
Chapter 4: T Tests and One Way ANOVA using SPSS
Cont’d...
Levene’s Test for Equality of Variances
Recall that the Independent Samples t Test requires the assumption
of homogeneity of variance – i.e., both groups have the same
variance.
SPSS conveniently includes a test for the homogeneity of variance,
called Levene’s Test, whenever you run an independent samples t
test.
The hypotheses for Levenes test are:
H0 : σ12 − σ22 = 0 (”the pop. variances of group 1 and 2 are equal”)
H1 : σ12 − σ22 , 0
This implies that if we reject the null hypothesis of Levene’s Test, it
suggests that the variances of the two groups are not equal; i.e., that
the homogeneity of variances assumption is violated.
The output in the Independent Samples Test table includes two rows:
Equal variances assumed and Equal variances not assumed.
Asrat D. (DDU) Statistical Computing I January, 2022 25 / 37
Chapter 4: T Tests and One Way ANOVA using SPSS
Cont’d...
If Levene’s test indicates that the variances are equal across the two
groups (i.e., p-value large), you will rely on the first row of output,
Equal variances assumed, when you look at the results for the
actual Independent Samples t Test (under the heading t-test for
Equality of Means).
F=29.227 is the test statistic of Levene’s test and the p-value of
Levene’s test is ”0.000” p very small), so we reject the null of Levene’s
test and conclude that the variance of current salary for Custodial
category is significantly different than that current salary of Manager
category.
This tells us that we should look at the ”Equal variances not
assumed” row for the t test (and corresponding confidence interval)
results.
Asrat D. (DDU) Statistical Computing I January, 2022 26 / 37
Chapter 4: T Tests and One Way ANOVA using SPSS
Cont’d...
t-test for Equality of Means
Provides the results for the actual Independent Samples t Test.
The calculated t-value=-16.261 and the associated p value is 0.000,
so, we reject the null hypothesis Since p =0.000 is less than our
chosen significance level α = 0.05, and conclude that the mean
current salary for Custodial and Manager employment category is
significantly different.
The average current salary for Custodial was $33,038.91 lower than
the average current salary for manager.
The 95% CI for the difference mean is [-$37,075.770, -$29,008.047],
which does not contain zero; this agrees with the small p-value of the
significance test.
Asrat D. (DDU) Statistical Computing I January, 2022 27 / 37
Chapter 4: T Tests and One Way ANOVA using SPSS
Exercise
The following data represents crop production obtained in Quintal from us-
ing two types of Varieties (1 &2). Then test that the difference in the crop
production of Varity 1 & 2 is different from 0 with 95% confidence. Using
both Minitab & SPSS software
Asrat D. (DDU) Statistical Computing I January, 2022 28 / 37
Chapter 4: T Tests and One Way ANOVA using SPSS
4.4) Paired T-Test
B The paired t-test (also known as the paired-samples t-test or dependent
t-test) determines whether there is a statistically significant difference in the
mean of a dependent variable between two related groups. Or
B The Paired Samples t Test compares the means of two measurements
taken from the same individual, object, or related units. These ”paired”
measurements can represent things like:
A measurement taken at two different times (e.g., pre-test and
post-test score with an intervention administered between the two
time points)
A measurement taken under two different conditions (e.g., completing
a test under a ”control” condition and an ”experimental” condition)
Measurements taken from two halves or sides of a subject or
experimental unit (e.g., measuring hearing loss in a subject’s left and
right ears).
The purpose of the test is to determine whether there is statistical
evidence that the mean difference between paired observations is
significantly
Asrat D. (DDU) different from zero.
Statistical Computing I January, 2022 29 / 37
Chapter 4: T Tests and One Way ANOVA using SPSS
Cont’d...
The hypotheses can be expressed in two different ways that express
the same idea and are mathematically equivalent:
H0 : µ1 = µ2 (”the paired population means are equal”)
H1 : µ1 , µ2
OR
H0 : µ1 − µ2 = 0 (”difference b/n the paired pop. means is equal to 0”)
H1 : µ1 − µ2 , 0
If the calculated t value is greater than the critical t value (t(n-1)), then
we reject the null hypothesis (and conclude that the means are
significantly different).
Example: The following data gives paired yields of two varieties of wheat.
Each pair was planted in different locality. Test the hypothesis that the mean
yields are equal at 5% level of significance.
Variety 1: 45 32 58 57 60 38 47 51 42 38
Variety 2: 47 34 60 59 63 44 49 53 46 41
Asrat D. (DDU) Statistical Computing I January, 2022 30 / 37
Chapter 4: T Tests and One Way ANOVA using SPSS
Cont’d...
B Your result in SPSS should looks like the following
Analyze > Compare Means > Paired T test
Interpret results: Since the p-value=0.000 is less than 0.05. Hence we
reject H0 and conclude that the mean yields of varity 1 & 2 are not equal.
Asrat D. (DDU) Statistical Computing I January, 2022 31 / 37
Chapter 4: T Tests and One Way ANOVA using SPSS
4.5) One Way ANOVA
One-Way ANOVA (”analysis of variance”) compares the means of two
or more independent groups in order to determine whether there is
statistical evidence that the associated population means are
significantly different.
In One-way ANOVA, comparing k populations/groups with their
respective mean µi , i=1, 2, 3, .... ,hypothesis will be:
B H0 : All means are equal/no difference (µ1 = µ2 = µ3 = ... = µk ) Vs
B H1 : At least one of the mean is different from the others
The variables used in this test are known as: Dependent variable and
Independent variable (also known as the grouping variable, or factor).
Dependent variable that is continuous (i.e., interval or ratio level) and
Independent variable that is categorical (i.e., two or more groups)
Note: Both the One-Way ANOVA and the Independent Samples t Test
can compare the means for two groups. However, only the One-Way
ANOVA can compare the means across three or more groups.
Asrat D. (DDU) Statistical Computing I January, 2022 32 / 37
Chapter 4: T Tests and One Way ANOVA using SPSS
Cont’d....
In SPSS
First Create two variable and enter the data of the response variable
in one column with the sequence of each leve then, the Second
variable Factors as 0 for the first sampel, 1 for the second sample, 3
for the third sample,....
Then click on Analyze > Compare means > One Way ANOVA
Move variables to the right by selecting them in the list and clicking
the blue arrow buttons.
You can move a variable(s) to either of two areas: Dependent List or
Factors.
Click Options. Check the box for Means plot, then click Continue.
When the initial F test indicates that significant differences exist
between group means, contrasts are useful for determining which
specific means are significantly different when you have specific
hypotheses that you wish to test.
Asrat D. (DDU) Statistical Computing I January, 2022 33 / 37
Chapter 4: T Tests and One Way ANOVA using SPSS
Example
One health specialist wishes to test the effect of Diet on the Blood pres-
sure of human being. The types of diets she used were vegetable & fruits,
meat, packed foods and Cereals. She used 20 people with optimum blood
pressure and the number of replication is 5. After the experiment had been
done for 2 months she observed the following blood pressures, so using
the data test the effect of Diet on Blood pressure at α = 5%.
Asrat D. (DDU) Statistical Computing I January, 2022 34 / 37
Chapter 4: T Tests and One Way ANOVA using SPSS
Cont’d...
The result will be as follows
Asrat D. (DDU) Statistical Computing I January, 2022 35 / 37
Chapter 4: T Tests and One Way ANOVA using SPSS
Cont’d...
Interpret results:
In the one way ANOVA model, F=28.657 and the P value=0.000
which is less than α = 0.05 hence we reject H0 reveals that one of the
mean is different from the other.
In the individual 95% confidence intervals table, the mean of
Vegetable, packed food and cereals are almost the same but the
mean of Meat is protruded from the others. This implies that blood
pressure is significantly higher in those who use meat.
Asrat D. (DDU) Statistical Computing I January, 2022 36 / 37
Chapter 4: T Tests and One Way ANOVA using SPSS
Thank You!!!
Asrat D. (DDU) Statistical Computing I January, 2022 37 / 37