Professional Documents
Culture Documents
Hypothesis tests.
One-sample and paired t-tests.
20
10
Frequency
Body height
Krisztina Boda 4
Question: which of the following hyptheses to accept
H0: population mean µ=20
Ha: population mean µ≠20.
How to find the answer?
◼ To be sure, we have two know the age of the TOTAL population
(impossible)
◼ To be confident, we draw a sample from the population (i.e., get the
age of some first year medical students). n=137
◼ Calculate mean age of the sample: x = 20.87
◼ If the sample is representative, we believe that the sample mean
approximates the population mean: x ~
◼ To be 95% confident, calculate the 95% confidence interval for the
population mean: 95% CI: (20.35-21.39)
◼ We are 95% confident, that if true population mean (i.e. the mean age
of the ALL first year medical students) were known, it would lie
somewhere between 20.35 and 21.39.
◼ Answer: ??
Krisztina Boda 5
Hypothesis testing
Hypothesis testing
Krisztina Boda 7
Hypothesis
◼ Hypothesis: a statement about the population.
◼ Examples
▪ H1: p=0.5 (a coin is fair - half the flips would result in Heads and half, in
Tails)
▪ H2: p≠0.5 ( a coin is not fair)
▪ H3: =20 (the population mean is 20)
▪ H4: ≠20 (the population mean is not 20)
◼ Statisticians usually test the hypothesis which tells them what to
expect by giving a specific value to work with. They refer to this
hypothesis as the null hypothesis and symbolize it as H0.
◼ The null hypothesis is often the one that assumes fairness, honesty,
regularity, lack of effect, lack of correlation, independence or
equality.
◼ The opposite hypothesis is called alternative hypothesis and is
symbolized by Ha. This hypothesis, however, is often the one that is
of interest. (Often called the research hypothesis. The claim to be
tested.)
Krisztina Boda 8
Steps of hypothesis-testing
◼ Step 1. State the motivated (alternative) hypothesis Ha (Involves
the claim to be tested).
◼ Step 2. State the null hypothesis H0.
◼ Step 3. Select the , the probability of Type I error, or the α
significance level. α =0.05 or α =0.01.
◼ Step 4. Choose the size n of the random sample. (Hard math
problem.)
◼ Step 5. Select a random sample from the appropriate population
and obtain your data.
◼ Step 6. Calculate the decision rule –it depends on problem,
assumptions, type of data, etc...
◼ Step 7. Decision.
▪ a) Reject the null hypothesis (accept the alternative hypothesis) and say:
the difference is significant at α100% level.
▪ b) Fail to reject the null hypothesis (accept it) and say:
the difference is not significant at α 100% level.
Krisztina Boda 9
Testing the mean of a sample drawn from a
normal population: one-sample t-test
Krisztina Boda 10
Decision rule based on confidence interval
Krisztina Boda 11
Two-sided alfa
x−c
11 1.363 1.796 2.201 2.718 3.106 4.437
12 1.356 1.782 2.179 2.681 3.055 4.318
t= 13
14
1.350
1.345
1.771
1.761
2.160
2.145
2.650
2.624
3.012
2.977
4.221
4.140
SE 15 1.341 1.753 2.131 2.602 2.947 4.073
16 1.337 1.746 2.120 2.583 2.921 4.015
▪
17 1.333 1.740 2.110 2.567 2.898 3.965
If H0 is true, this test-statistic has a t-distribution with n-1 18 1.330 1.734 2.101 2.552 2.878 3.922
19 1.328 1.729 2.093 2.539 2.861 3.883
degrees of freedom. 20 1.325 1.725 2.086 2.528 2.845 3.850
21 1.323 1.721 2.080 2.518 2.831 3.819
22 1.321 1.717 2.074 2.508 2.819 3.792
23 1.319 1.714 2.069 2.500 2.807 3.768
▪ The acceptance (non-rejection) interval is the set of values for 24
25
1.318
1.316
1.711
1.708
2.064
2.060
2.492
2.485
2.797
2.787
3.745
3.725
which we accept the null hypothesis (- ttable, ttable) 26
27
1.315
1.314
1.706
1.703
2.056
2.052
2.479
2.473
2.779
2.771
3.707
3.690
▪ ttable is the critical t-value in the Student t-table in the row of df 28
29
1.313
1.311
1.701
1.699
2.048
2.045
2.467
2.462
2.763
2.756
3.674
3.659
and in the column of . 30
1.310
1.282
1.697
1.645
2.042
1.960
2.457
2.326
2.750
2.576
3.646
3.291
Krisztina Boda 12
Decision rule based on t-value, example
◼ Calculate the decision rule. y=student(x;136)
▪ Calculate the test-statistic: 0.5 1.0
x − c 20.87 − 20
t= = = 3.321
SE 0.262 0.4 0.8
▪
0.2 0.4
The acceptance (non-rejection) interval is the set of values for
which we accept the null hypothesis (- 1.977, 1.977)
0.1 0.2
Krisztina Boda 13
Decision rule based on p-value
◼ p-value (calculated by computer): it is the two
tailed tail area under the curve cut by our
calculated t-value
◼ It is the probability of obtaining a test statistic at
least as extreme as the one that was actually
observed, assuming that the null hypothesis is
true.
◼ Decision:
▪ If p<, we decide that the difference is significant
at 100% level
▪ If p>, we decide that the difference is not
significant at 100% level
◼ Decision, example:
▪ p=0.001152 (red shaded area).
▪ p<0.05, Acceptance interval
we decide to reject H0 and say: the difference is t=3.321
significant at 5% level p=.001152
Krisztina Boda 14
Decision rule based on p-value
◼ p-value (calculated by computer): it is the two
tailed tail area under the curve cut by our
calculated t-value
◼ It is the probability of obtaining a test statistic at
least as extreme as the one that was actually
observed, assuming that the null hypothesis is
true.
◼ Decision:
▪ If p<, we decide that the difference is significant
at 100% level
▪ If p>, we decide that the difference is not
significant at 100% level
◼ Decision, example:
▪ p=0.001152 (red shaded area).
▪ p<0.05, Acceptance interval
we decide to reject H0 and say: the difference is t=3.321
significant at 5% level p=.001152
Krisztina Boda 15
Summary of the equivalent decision rules for one-sample t-test
Assumption: normality (the sample is drawn from a normal distribution)
1. H0: =c, (c given constant).
2. Ha: c.
3. Select
4. Find the sample size n
5. Select a random sample x1 , x2 ,..., xn ., calculate the sample mean and SD
6. The decision rule:
7. Decision:
Decision
Confidence Critical points p-value
interval (t-value)
a) Ha : reject H0, the confidence
the difference is interval does not t t p<
significant at 100%- contain c
level.
a) H0 : do not reject H0, the confidence
the difference is interval contains the t t p>
not significant at value c
100%-level.
Krisztina Boda 16
SPSS result
One-Sample Statistics
Std. Error
N Mean Std. Deviation Mean
Age Age in years 137 20.87 3.071 .262
One-Sample Test
Test Value = 20
95% Confidence
Interval of the
Mean Difference
t df Sig. (2-tailed) Difference Lower Upper
Age Age in years 3.324 136 .001 .872 .35 1.39
p-value,
To decide based on t-value If p<, the difference is significant,
and degrees of freedom, If p>, the difference is not significant.
we need a t-table Now p=0.001<0.05 the difference
is significant at 5% level
Krisztina Boda 17
Results using R
> t.test(Age,mu=20)
data: Age
t = 3.324, df = 136, p-value = 0.00114
alternative hypothesis: true mean is not equal to 20
95 percent confidence interval:
20.35332 21.39120
sample estimates:
mean of x p-value
20.87226 If p<, the difference is
t-value (test statistic) significant at level,
and degrees of freedom.
To decide, we need a t-
Confidence interval for the population’s
table mean. We check whether the constant of
the null hypothesis (=true mean) is in this
interval or not
Krisztina Boda 18
Krisztina Boda 19
One-sample t-test, example 2.
◼ A company produces a 16 ml bottle of some drug (solution). The
bottles are filled by an automated bottle-filling process. If this process is
substantially overfilling or under filling bottles, then this process must be
shut down and readjusted. Overfilling results in lost profits for the company,
while under filling is unfair to consumers. For a given adjustment of the
bottles consider the infinite population of all the bottle fills that could
potentially be produced. We let denote the mean of the infinite population
of all the bottle fills.
◼ The company has decided that it will shut down and readjust the process if
it can be very certain that the mean fill is above or below the desired 16 ml.
◼ Now suppose that the company observes the following sample of n=6 bottle
fills:
◼ 15.68, 16.00, 15.61, 15.93, 15.86, 15.72
◼ It can be verified that this sample has mean=15.8 and standard deviation
SD=0.156.
◼ Question: Is it „true” that the mean bottle fill in the population is 16?
Krisztina Boda 21
Decision rule based on t-value
◼ Calculate our t-statistic:
(15.8 − 16)
t= 6 = −3.2
0.153
t=-3.2
Krisztina Boda 22
Decision rule based on p-value
◼ p-value (calculated by computer): it
is the two tailed tail area under the
curve cut by our calculated t-value*
◼ It is the probability of obtaining a
test statistic at least as extreme as
the one that was actually observed,
assuming that the null hypothesis is
true
◼ Decision:
▪ If p<, we decide that the difference
is significant at 100% level
▪ If p>, we decide that the difference
is not significant at 100% level
probability
df 0.2 0.1 0.05 0.02 0.01 0.001
1 3.077684 6.313752 12.7062 31.82052 63.65674 636.6192
2 1.885618 2.919986 4.302653 6.964557 9.924843 31.59905
3 1.637744 2.353363 3.182446 4.540703 5.840909 12.92398
4 1.533206 2.131847 2.776445 3.746947 4.604095 8.610302
5 1.475884 2.015048 2.570582 3.36493 4.032143 6.868827
6 1.439756 1.94318 2.446912 3.142668 3.707428 5.958816
7 1.414924 1.894579 2.364624 2.997952 3.499483 5.407883
8 1.396815 1.859548 2.306004 2.896459 3.355387 5.041305
9 1.383029 1.833113 2.262157 2.821438 3.249836 4.780913
10 1.372184 1.812461 2.228139 2.763769 3.169273 4.586894
11 1.36343 1.795885 2.200985 2.718079 3.105807 4.436979
12 1.356217 1.782288 2.178813 2.680998 3.05454 4.317791
13 1.350171 1.770933 2.160369 2.650309 3.012276 4.220832
14 1.34503 1.76131 2.144787 2.624494 2.976843 4.140454
15 1.340606 1.75305 2.13145 2.60248 2.946713 4.072765
Krisztina Boda 24
1. H0: =c, (c given constant). H0: =16.
2. Ha: c. Ha: 16
3. Select =0.05or =0.01
4. Find the sample size n n=6
5. Select a random sample x1 , x2 ,..., xn . 15.68, 16.00, 15.61, 15.93, 15.86, 15.72
6. The decision rule:
Krisztina Boda 25
A one-sample t test for paired differences
(paired t-test)
◼ Self-control experiment
◼ Related data:
▪ before treatment – after treatment
▪ left side – right side
▪ matched pairs.
◼ Null hypothesis: there is no treatment-effect, the
difference is only by chance
H0: before= after or difference= 0.
◼ Alternative hypothesis: there is a treatment effect
Ha: before≠ after or difference≠ 0.
◼ Assumption: the differences are normally distributed.
Krisztina Boda 26
Paired t-test, example
◼ A study was conducted to determine
weight loss, body composition, etc.
in obese women before and after 12 Before After Difference
weeks of treatment with a very-low- 85 86 -1
calorie diet .
95 90 5
◼ We wish to know if these data
provide sufficient evidence to allow 75 72 3
us to conclude that the treatment is 110 100 10
effective in causing weight reduction 81 75 6
in obese women. 92 88 4
◼ The mean difference is actually 4. Is 83 83 0
it a real difference? Big or small? If
the study were to be repeated, would 94 93 1
we get the same result or less, even 88 82 6
0? 105 99 6
◼ Idea: if the treatment is not effective, Mean 90.8 86.8 4
the mean sample difference is small SD 10.79 9.25 3.333
(close to 0), if it is effective, the mean
difference is big
◼ We perform a paired t-test the check
whether the mean difference is 0 in
the population
Krisztina Boda 27
Paired t-test, example (cont).
◼ H0: before= after or difference= 0 (c=0)!!
◼ Ha: before≠ after or difference≠ 0
◼ Let =0.05
◼ Degrees of freedom=10-1=9,
◼ ttable=t0.05,9=2.262
◼ Mean=4, SD=3.333
◼ SE=3.333/10=1.054
◼ 95%CI: (4-2.262*1.054, 4+2.262*1.054)=(1.615, 6.384). The mean
loss of body weight was 4 kg. We are 95% confident, that the true
population mean would be even 6.36 but minimum 1.615.
◼ Decision based on confidence interval: 0 is outside the confidence
interval, we decide to reject H0 and say, the difference is significant
at 5% level, the treatment was effective.
Krisztina Boda 28
◼ Decision based on test statistic
(t-value):
x−c x−0 4
t= = = = 3.795
SE SE 1.054
▪ This t has to be compared to
the critical t-value in the table.
▪ |t|=3.795>2.262(=t0.05,9), the
difference is significant at 5%
level
◼ Decision based on p-value:
▪ p=0.004, p<0.05, the
difference is significant at 5%
level Acceptance region
tcomputed, test statistic
Krisztina Boda 29
Results using SPSS
Krisztina Boda 30
Results using R
> hist(after-before)
> t.test(before, after, paired=TRUE)
Paired t-test
Krisztina Boda 31
Example from the medical literature
Krisztina Boda 32
A few repetition
Krisztina Boda 33
Krisztina Boda 34
Krisztina Boda 35
Krisztina Boda 36
Krisztina Boda 37
Thank you for your attention!
Krisztina Boda 38
Review questions and problems
◼ What is a hypothesis
◼ Null-and alternative hypothesis
◼ Steps of hypothesis testing
◼ The null- and alternative hypothesis of the one-sample t-test
◼ The assumption of the one-sample t-test
◼ Decision rules of the one-sample t-test
◼ Testing significance based on a confidence interval
◼ Testing significance based on t-statistic
◼ Testing significance based on p-value
◼ Meaning of the p-value
◼ In a study, systolic blood pressure of 10 healthy women was measured. The mean
was 119, the standard error 0.664. Supposing that this sample was drawn from a
normal distribution, check whether the population mean is 125! (=0.05, ttable=2.26).
◼ To test the effect of a new drug, the systolic blood pressure was measured on the
same 5 patients before and after the treatment. The mean of the differences is = 6,
the standard error of the differences is SE=4.65. To test the effect of the drug, what
is the appropriate test? Find the value of the test statistics and decide whether the
difference is significant or not. ( =0.05, ttable=2.57)
Krisztina Boda 39