Hypothesis Testing-2 PDF
Hypothesis Testing-2 PDF
P-Value
Observed significance level
• P-value (or p-value or probability value)
• The probability of getting a value of the test
HYPOTHESIS TESTING statistic that is at least as extreme as the one
Lecture--2
Lecture representing the sample data, assuming that
the null hypothesis is true.
Niranjan S. Kanaki • Measure of the strength of evidence the
KBIPER sample data provides against the null
hypothesis
• The null hypothesis is rejected if the P-value is
very small, such as 0.05 or less.
P-Value Conclusions
Observed significance level in Hypothesis Testing
• Measure of the strength of evidence the
sample data provides against the null
always test the null hypothesis
hypothesis
• The null hypothesis is rejected if the P-value is
1. Reject the H0
very small, such as 0.05 or less.
2. Fail to reject the H0
P − value : p = P( Z ≥ zobs )
1
8/10/2015
• Reject H0 if the test statistic falls within • Reject H0 if P-value ≤ α (where α is the
• Fail to reject H0 if the test statistic does • Fail to reject H0 if P-value > α.
2
8/10/2015
• Instead of using a significance level such • Reject H0 if the sample parameter has a
as 0.05, simply identify the P-value and value that is not included in the
• Ho: µ=65
Answer
• HA :µ≠ 65
• α=0.05 Zα =1.96 (critical value)
_
x -µ 60.75-65
Z=---------- = ----------- = -5.38
σ √n √10/ √16
Sine the calculated values falls in the rejection
region , we reject the Ho, and accept the HA
3
8/10/2015
• Find the confidence intervals using z- • In the above example , if the population
distribution. variance is unknown, and the sample Sd is
3.84
Answer
α =5%
Degrees of freedom (df)= n-1= 15
t 1- α/2 =± 2.13
_
x -µ 60.75-65
t =-------------=------------= - 4.1315
s /√n 3.84/ √16
Sine the calculated values falls in the rejection region , we
reject the Ho, and accept the HA
Problem
• Find the confidence intervals using t- • A random sample of 10 boys had the following
distribution. IQ levels:
70, 120, 110, 101, 88, 83, 95, 98, 107, 100
4
8/10/2015
Problem Problem
• A drug in the powder form is packed into tins • The following data show the blood pressure
by a machine. A random sample of 10 tins is reduction ( in mm Hg) caused in 10 animals by
drawn and their contents are found to weigh a new antihypertensive compound.
in gms as follows:
20, 18, 15, 12, 8, 16, 18, 17, 14, 21
94, 83, 101, 99, 85, 100, 102, 94, 98, 95
• Test the hypothesis that the blood pressure
reduction for the population is 15 mm Hg.
• Test the hypothesis that average content in
the population is 100 gms. Also find the Find 95% fiducial limits for the population
fiducial limits for the drug content at α=5%. mean.
Problem Problem
• A tablet coating machine is designed to produce The data show the lives of a sample of bulbs
sugar coating with average thickness of 0.025 cm. manufactured by a company. The company
A random sample of 10 tablets was found to have
average thickness of 0.024 cm with standard claims that the average life of its bulbs is 90
deviation of 0.002. days. Do the data support company’s claim, at
• Do the data support the hypothesis that the 5% level of significance?
average thickness in the population is 0.025, at Life of bulb (days) No. of bulbs
5% level of significance? 40-55 10
• Find the confidence interval at 5% level of 55-70 12
significance. 70-85 15
• Find the confidence interval at 1% level of 85-100 13
significance. 100-115 10
5
8/10/2015
S1 and S2 = sample standard deviations of the two groups X1 and X2 = means of two groups
N1 and N2 = sample size of the two groups Sp = pooled standard deviation of the two groups
N1 and N2 = sample size of the two groups
6
8/10/2015
Animal 1 2 3 4 5 6
d = mean of differences of all pairs of observations
A 136 168 160 94 200 174
Sd = standard deviation of differences of all data pairs B 166 184 193 105 198 197
N = sample size
Problem Problem
• Ten individuals had supine systolic blood pressures taken at the • The following data were observed comparing two assays using
beginning and end of a half-an hour rest period. The readings are 12 batches of material. Do both the assays give similar results?
given below. Is there any change in the blood pressure after (α= 5%)
rest? (α= 5%)
Participant 1 2 3 4 5 6 7 8 9 10 Batch 1 2 3 4 5 6 7 8 9 10 11 12
Before 140 136 160 172 154 150 138 146 152 128 Test A 8.1 9.4 7.2 6.3 6.6 9.3 7.6 8.1 8.6 8.3 7.0 7.7
After 132 134 162 170 146 154 142 138 144 124 Test B 9.0 9.9 8.0 6.0 7.9 9.0 7.9 8.3 8.2 8.9 8.3 8.8
7
8/10/2015
Problem
F-test for equality of two variances • The nicotine content (in mg) of two samples of tobacco were
found to be as follows:
• To find whether two independent samples can
be regarded as drawn from the normal
population with the same variance. Sample A 24 27 26 21 25
Sample B 27 30 28 31 22 36
• H0 : σ12=σ22
Can it be said that the two samples came from the same
F = S 12 / S 22 normal population?
Problem
• Two granulations were prepared by different procedures. Seven
random samples of powdered mix of equal weight were
collected from each batch and assayed for active material, with
following results:
Granulation A 20.4 20.6 20.6 20.7 21.0 20.9 19.8
Granulation B 20.2 21.0 20.4 19.0 21.5 18.9 21.8
Chi (χ2)
Chi--Square Test (χ (χ2)
Chi--Square Test (χ
Chi
• For comparison of proportions from two • The chi-square statistic is calculated as
independent groups follows:
• For chi-square test, data is expressed as a
four-fold table (2 x 2 table)
Group I Group II
No. of successes a b • O= Observed frequency in each cell
No. of failures c d
• E= expected frequency in each cell
8
8/10/2015
Chi (χ2)
Chi--Square Test (χ (χ2)
Chi--Square Test (χ
Chi
Example • The expected number is the number that would result if
Group I Group II Total
each group had same proportion of successes or failures
No. of a= b= a+b= • The common proportion of success (p) is calculated by
successes 16 18 34 following formula:
No. of failures c= d= c+d=
4 12 16 • Pooled p = total no. of successes in both groups
Total a+c= b+d= a+b+c+d= Total no. of trials
20 30 50
= a+b
a+b+c+d
Chi (χ2)
Chi--Square Test (χ (χ2)
Chi--Square Test (χ
Chi
Expected frequencies
Group I Group II Total
No. of 13.6 20.4
successes 34
No. of failures 6.4 9.6 16
Total 20 30 50
D.f. = 1
9
8/10/2015
Chi (χ2)
Chi--Square Test (χ (χ2)
Chi--Square Test (χ
Chi
For Goodness of Fit Example
A die is thrown 150 times and the following results are obtained
as shown in the table below. Test the hypothesis that the die is
To investigate the agreement between theoritical
unbiased at 5% level of significance.
distribution and observed distribution
Number turned 1 2 3 4 5 6
up
Frequency 19 23 28 17 32 31
Chi (χ2)
Chi--Square Test (χ Example 1
Example
In an ecological study, water samples were collected in alternate • Suppose you conducted a drug trial on a group of animals and
you hypothesized that the animals receiving the drug would
months to study the phytoplantons populations. The following
show increased heart rates compared to those that did not
table shows the number of organisms per cubic cm in the six receive the drug. You conduct the study and collect the
samples. Test the hypothesis that the number of organisms following data. Test your hypothesis using appropriate
present in each sample does not depend on the particular statistical method.
sample. Heart rate No heart Total
increased rate
Sample 1 2 3 4 5 6 increase
No. of organisms 79 84 102 64 90 85 Treated 36 14 50
Untreated 30 25 55
Total 66 39 105
Example 2 Example 3
A new analytical method is to be compared to an old method.
• In a Mandelian experiment on hybridization of pea plant
The experiment is performed by a single analyst. She selects four
having round yellow seeds with one having wrinkled green
batches of product at random and obtains the following results.
seeds, the following results were obtained in F1 generation.
Test whether the data fits the Mandelian ratio of 9:3:3:1. Do you think that the two methods give different results on the
average?
Round Wrinkled
Yellow 315 101
Green 108 32
10
8/10/2015
Example 4 Example 5
• Quality control records show the average tablet • Two batches of tablets were prepared by two
weight to be 502 mg with a standard deviation of different processes.
5.3. There are sufficient data so that these values • The potency determinations made on five
may be considered known parameter values.
tablets from each batch were as follows:
• A new batch shows the following weights from a
• Batch A: 5.1, 4.9, 4.6, 5.3, 5.5;
random sample of six tablets: 500, 499, 504, 493,
497, and 495 mg. • Batch B: 4.8, 4.8, 5.2, 5.0, 4.5.
• Do you believe that the new batch has a different • Test to see if the means of the two batches are
mean from the process average? equal.
OR by shortcut formula
11
8/10/2015
12
8/10/2015
Two--way ANOVA
Two Two--way ANOVA
Two
• Also known as two-factor ANOVA Steps
• When there are two factors affecting the • Suppose there are h rows and k columns in
values of the response variable. the data.
Examples- • First calculate the row totals R1, R2, … and
– Comparing different analytical methods on column totals C1, C2, ….
different batches of products
• Calculate the grand total T.
– Comparing the effect of treatments on people of
different age groups or gender • Calculate the correction term, C.T.= T2/hk
– Comparing dissolution profile of formulations
Two--way ANOVA
Two Two--way ANOVA
Two
Steps (contd..) Steps (contd..)
• Calculate the total sum of squares, TSS • Calculate the column sum of squares, CSS
TSS=Σy2 - C.T. CSS=ΣCi2/h - C.T.
d.f.= hk-1 d.f.= k-1
• Calculate the row sum of squares, RSS • Calculate the error sum of squares, ESS
RSS=ΣRi2/k - C.T. ESS=TSS-RSS-CSS
d.f.= h-1 d.f.= (h-1)(k-1)
13
8/10/2015
Two--way ANOVA
Two Two--way ANOVA
Two
Steps (contd..) Steps (contd..)
• Calculate the row mean sum of squares, MSR To test H01: All row means are equal,
MSR=RSS/h-1 calculate Fr.
• Calculate column mean sum of squares, MSC Fr = MSR/MSE
MSC=CSS/k-1 To test H02: All column means are equal,
• Calculate the error mean sum of squares, MSE calculate Fc.
MSE=ESS/(h-1)(k-1) Fc = MSC/MSE
14
8/10/2015
Power of a Test
Problem
• Power - Probability a test rejects H0 (depends on µ1- µ2)
Crop I Crop II Crop III Crop IV – H0 True: Power = P(Type I error) = α
Fertilizer A 6 4 8 6 – H0 False: Power = 1-P(Type II error) = 1-β
Fertilizer B 7 6 6 9
Fertilizer C 8 5 10 9 · Example:
· H0: µ1- µ2 = 0 HA: µ1- µ2 > 0
• σ12 = σ22 = 25 n1 = n2 = 25
· Decision Rule: Reject H0 (at α=0.05 significance level) if:
y1 − y 2 y1 − y 2
z obs = = ≥ 1 .645 ⇒ y 1 − y 2 ≥ 2 .326
σ 12 σ 22 2
+
n1 n2
15
8/10/2015
Power of a Test
Power of a Test
Distribution (H0) Distribution (HA)
Power Curves for group sample sizes of 25,50,75,100 and varying true values µ1-µ2
with σ1=σ2=5.
• For given µ1-µ2 , power increases with sample size
• For given sample size, power increases with µ1-µ2
µ1 − µ 2
δ=
σ
• Step 2 - Choose the desired power to detect the the clinically meaningful difference (1-
β , typically at least .80). For 2-sided test:
2(zα / 2 + z β )
2
n1 = n2 = 2
δ
16