STAT1008-R代写
时间:2023-05-01
Chapter 10 – Two sample hypothesis tests
STAT1008
Quantitative Research Methods
Comparing the means of two
independent populations
• Example question: Is there a difference in the average
ATAR score between NSW and Victorian students?
• We have two populations of interest (NSW and Victorian
Year 12 students).
• Let !"#$ be the population mean ATAR score for NSW
students and similarly define !%&' for Victorian students
• The null and alternative hypothesis:
H0: !"#$= !%&'
HA: !"#$ ≠ !%&'
Comparing the means of two
independent populations
• Two-tailed test
H0: !"= !# or !" − !# = 0
HA: !" ≠ !# or !" − !# ≠ 0
• Left (one)-tailed test
H0: !" = !# or !" − !# = 0
HA: !" < !# or !" − !# < 0
• Right (one)-tailed test
H0: !"= !# or !" − !# = 0
HA: !" > !# or !" − !# > 0
Comparing the means of two
independent populations
• Suppose we have a random sample of size n1=30 ATAR
scores from NSW, and n2=40 ATAR scores from VIC
• We can calculate the sample means !"#$% and !"&'( , and
the sample standard deviations sNSW and sVIC.
• How can we use our sample statistics to answer our
research question? Formally, we need to conduct a
hypothesis test for the difference between two means of
two independent populations
• What is the test statistic? What is the rejection region?
Comparing the means of two
independent populations
• Pooled-variance t test and separate-
variance t test
Rule of thumb:
• If ratio of largest to
smallest sample
variance is ≤3.
use pooled variance
t-test
• If ratio of largest to
smallest sample
variance is >3.
use separate
variance t-test
Pooled variance t-test
• If n1≥ 30 and n2≥ 30 , the population data are not heavily
skewed, and it can be assumed the population variances
are equal (%&'= %''), the test statistic is
( = ( +,&− +,') − (/& − /')01' 13& + 13'
Where 01' = 567& 869: 597& 899567& : 597& (pooled variance)
The test statistic follows a (56:597' distribution. (That is, the
critical values are determined from a t distribution with n1+n2-2
degrees of freedom).
Pooled variance t-test
• If both or one of n1 or n2 are less than 30, then both
populations must be normally distributed in order to use the
pooled variance
t-test statistic formula.
• Also check that your populations are not heavily skewed or
show severe departures from normality, otherwise a much
much greater sample size than 30 is required for both
populations to run a valid pooled variance t-test.
Pooled variance t-test example
For the ATAR example, suppose !"#$%=69.00 and !"&'( =65.22, and sNSW = 15.1 and sVIC =12.5
/01 = 2345 ×57.589 :345 ×51.782345 9(:345) =186.8535
t= =>4=7.11 435?=.?727 @AB9 @CB =1.1449
Assume D = 0.05. So the critical value is ±G239:341,3.317= ±G=?,3.317 = ±1.9955
Accept/Reject HA ? Do not reject H0
Pooled variance t-test example
• What is the p-value of this hypothesis test??
2 x Pr( t68 > 1.1449) =0.2563 (> 0.05, do not reject the null)
In Excel: =2*(1-T.DIST(1.1449, 68, TRUE))=0.2563
• Find a 95% confidence interval for the difference in
mean ATAR scores between NSW and VIC Year 12
students.
(69-65.22) +/- 1.9955 x 186.8535 '() + '+)
(-2.81,10.37) (Note this confidence interval contains the
null value of zero difference)
Separate variance t-test for two
independent samples
• If it cannot be assumed the population
variances are equal, we need to use the
separate variance t-test.
• Rule of thumb: use separate variance t-test if
ratio of largest to smallest sample variance is
>3. ! = ( $%&− $%() − (*& − *()+&(,& + +((,(
Separate variance t-test for two
independent samples
• Example: We want to compare the heights in
centimetres of two groups of individuals.
Sample Data:
A: 175, 168, 168, 190, 156, 181, 182, 175, 174, 179
B: 120, 180, 125, 188, 130, 190, 110, 185, 112, 188
Separate variance t-test for two
independent samples
Let X1= Height (group A) and X2=Height (group B)!"# = 174.8; !"+ = 152.8./0 = 9.3429; ./3 = 35.7517
H0: 4# = 4+ ; 56: 4#≠ 4+
9 = (#;<.=>#?+.=)>AB.CD3B30E FCG.HG0H30E =1.8827
Separate variance t-test for two
independent samples
• Degrees of freedom for t-test with unequal
variances:
!" = $%&'% + $&&'& &$%&'% &'% − 1 + $&
&'& &'& − 1
Separate variance t-test for two
independent samples
• Degrees of freedom for t-test with unequal
variances:
!" = $.&'($()* +&,.-,)-()* ($.&'($()* ()*.) + &,.-,)-()* ()*.) =10.2235
Round down to nearest whole number. (Why round down?)
Find critical value for rejection region from a t10 distribution.
Separate variance t-test for two
independent samples
t10,0.025 =2.2281. The critical region is
t10> 2.2281 or t10< -2.2281
The test statistic value t=1.8827 is not in the critical
region. Hence do not reject H0. That is, we do not
have `statistical’ evidence to support the hypothesis
that the mean heights between the two groups differ.
P-value?? 2x Pr(t10 > 1.8827)=0.0891
in Excel: =2*(1-T.DIST(1.8827,10,TRUE))=0.0891
Paired t-test
Example: Do National Rugby Leagues (NRL) teams
score more points when playing `home’ games than
`away’ games??
Sample data: 2018 season results. For each team, we
have the variables:
X1 - total points scored in `home’ games;
X2 - total points scored in `away’ games
Data source:
https://www.rugbyleagueproject.org/seasons/nrl-
2018/summary.html
Paired t-test – example - data
X1 X2
Paired t-test - definition
• So for each team we have `two’ observations, and the
values of X1 and X2 for each team are related (as they
come from the same team).
• This is an example of `paired’ data.
• To test for the mean difference between two related
populations, we need to calculate a difference (D) score
for each team, then treat the differences `D’ as values
from a single sample
Paired t-test – hypotheses
• For the NRL example: D = X1 – X2 (`home’ game
points - `away’ game points).
• Let !" be the population mean difference.
• We wish to test:
H0: !"=0
HA: !" >0
Paired t-test – test statistic
! = #$ − &'(')
#$=sample mean difference=∑+,-. '+/
SD= sample standard deviation of differences=
∑+,-. ('+1#')3/14
Paired t-test – test statistic
• For the NRL example !" = 28.5 ()* +, = 48.0375
So 1 = 23.45678.9:;<=> =2.3731
Assume ? = 0.05, AB 1ℎD EFG1GE(H I(HJD GA1K5L,MN1L4,6.64 = 1.7531
The critical region is t15> 1.7531
In Excel: =T.INV(0.95,15)=1.7531
The value of the test statistic (t) is greater than the critical value. That is,
the test statistic lies in the rejection region. So at the ? = 0.05 significance
level, we have statistical evidence to reject H0 in favour of HA. That is, we
conclude that NRL teams do score more points in home games than away
games.
Paired t-test – p-value
• For the NRL hypothesis test above, calculate the
corresponding p-value
Pr(t15 > 2.3731) = 0.0157 (< 0.05)
In Excel: =1-T.DIST(2.3731,15,TRUE)=0.0157
Question
• What are the statistical implications of
treating paired data as unpaired data?
Comparing two population
proportions
• In evaluating differences between two population proportions, you can
use a Z test for the difference between two proportions.
• H0: !"- !#=0; HA: !" − !# ≠0
• You can use this Z test for the difference between population proportions
to determine whether there is a difference in the proportion of successes
in the two groups (two-tail test) or whether one group has a higher
proportion of successes than the other group (one-tail test)
&# = (#)# ; &" = (")" ; &̅ = (# + (")# + )"
Note: we use &̅ in the estimate of
the standard deviation of the
difference in proportions because
under the null, we assume !# and !" are equal.
Z= -./-0 / 1./10-̅(#/-̅) 0405 04.
Comparing two population proportions
Example: Australia’s performance at the Olympic Games.
At the 2012 London Olympic Games, Australian athletes won 35
medals across 11 sports. At the time, this was the lowest medal
count for Australia in the Summer Olympics since 1992.
Australia sent 410 athletes to London to compete in 23 sports.
At the 2016 Rio de Janeiro Olympics, Australian athletes won 29
medals across 12 sports. This result replaced the London result
as Australia’s lowest total medal count since 1992. Australia
sent 421 athletes to Rio de Janeiro to compete in 26 sports.
Comparing two population proportions
Aside the underwhelming medal count, the Australian team was also
criticised for lacking diversity across sports for potential success,
specifically, a heavy reliance on swimming to produce medals.
So in addition to the lower medal count at the 2016 Olympics, did
Australia also perform worse in terms of diversity of medal producing
sports?
Measure of diversity: number of sports in which Australia medalled
total number of sports Australia participated in
Comparing two population proportions
• Let !" be the diversity measure from the 2012
Olympic games and let !# be the diversity measure
from the 2016 Olympic games.
• Is the independence assumption valid between 2012
and 2016 data?
• Step 1:
H0: !#- !"= 0
HA: !#- !"< 0
• Step 2: ' = 0.05
n1= 23; n2=26
Comparing two population proportions
• Step 3:
Z= "#$"% $ &#$&%"̅()$"̅) %+%, %+#
Z= %##-$%%#. $//.123 ()$/.123) %#., %#- = - 0.08527
4) = ))56 = 0.4783; 45 = )552 = 0.4615; 4̅ = )),)556,52=0.469388
Comparing two population proportions
Step 4: The critical value is Z0.05=-1.645.
(Pr(Z < -1.645) = 0.05)
Step 5: The test statistic value is not less than
-1.645. Hence do not reject the null. That is, do
not conclude there was a significant drop in the
diversity of medal producing sports measure
between the 2012 and 2016 Olympics.
Note: The corresponding p-value is
Pr(Z < -0.08527) = 0.4660 (> 0.05)
Comparing two population proportions
Construct a 95% confidence interval for the
difference in the sports diversity measure between
the 2016 and 2012 Olympics.
(p2-p1)±" #$(&'#$))$ + #+(&'#+))+
Note: as there is no null hypothesis assumption for
a confidence interval, we do not need to calculate -̅.
Comparing two population proportions
1226 − 1123 ± 1.96 0.4615(1 − 0.4615)26 + 0.4783(1 − 0.4783)23
-0.01672±0.2800
(- 0.2800 , 0.2633)
We are 95% confident that the change in diversity measure
between the 2012 and 2016 Olympic games is between
-0.28 and 0.26.


essay、essay代写