33
Chapter 10: STATISTICAL INFERENCE FOR TWO SAMPLES Part 1: Hypothesis tests on a μ - μ for independent groups Sections 10.1 & 10.2 Independent Groups (not covering subsections 10.1.2 and 10.2.2) It is common to compare two groups with a hypothesis test on the mean parameters of the groups μ 1 and μ 2 . We will discuss two data collection designs in this chapter, and we will discuss how the de- sign choice affects how we analyze the data. (1) Independent observations taken on each group or ‘two-sample t-test’ (2) Paired observations, where one observa- tion from population 1 is paired with one observation from population 2, or a ‘paired t-test’ 1

Chapter 10: STATISTICAL INFERENCE FOR TWO SAMPLES Part 1 ...homepage.divms.uiowa.edu/~rdecook/stat2020/notes/ch10_pt1.pdf · Chapter 10: STATISTICAL INFERENCE FOR TWO SAMPLES Part

  • Upload
    others

  • View
    8

  • Download
    1

Embed Size (px)

Citation preview

  • Chapter 10: STATISTICAL INFERENCEFOR TWO SAMPLES

    Part 1: Hypothesis tests on a µ − µfor independent groupsSections 10.1 & 10.2 Independent Groups

    (not covering subsections 10.1.2 and 10.2.2)

    • It is common to compare two groups with ahypothesis test on the mean parameters ofthe groups µ1 and µ2.

    •We will discuss two data collection designs inthis chapter, and we will discuss how the de-sign choice affects how we analyze the data.

    (1) Independent observations taken on eachgroup or ‘two-sample t-test’

    (2) Paired observations, where one observa-tion from population 1 is paired with oneobservation from population 2, or a‘paired t-test’

    1

  • • Examples:– Mean length of a part manufactured at

    plant A (µ1) compared to mean length ofa same part manufactured at plant B (µ2).

    – The weights of individuals before a dietstarts (µ1) compared to the weights of theindividuals after 10 weeks on the diet (µ2).

    We will not cover comparison ofproportions, p1 vs. p2, but they are alsocommon:

    – Proportion of defects in a device manufac-tured under process 1 vs. process 2.(Comparison of proportions, p1 vs. p2)

    – Satisfied customer rate for AT&T cellu-lar compared to satisfaction rate for T-mobile.

    2

  • • Hypothesis testing for comparison of means:

    H0 : µ1 = µ2 ⇒ H0 : µ1−µ2 = 0H1 : µ1 6= µ2 ⇒ H1 : µ1−µ2 6= 0

    •When comparing the means of two samples(X̄1 vs. X̄2), we must determine if the datafrom the groups are totally independent, or ifthey are related, because this affects the typeof analysis performed (more on this later).

    •We start with comparisons made usingindependent groups (sections 10-1 to10-2) or the ‘two-sample t-test’...

    3

  • • Example 1: Time spent exercising.

    QUESTION: Do males and females at UIspend the same amount of time, on average,at the UI CRWC?

    X=Time in minutes spent at fitness center.

    Women Menn1 = 15 n2 = 15

    63,32,86,53,49 52,75,74,68,93

    73,39,56,45,67 77,41,87,72,53

    49,51,65,54,56 84,65,66,69,62

    4

  • Summary statistics: (1=women, 2=men)x̄1 = 55.87 minutes x̄2 = 69.20 minutes

    s1 = 13.527 minutes s2 = 13.790 minutes

    The sample of females spends, on average,13.33 minutes less time at the Fitness centerthan this sample of males.

    x̄1 − x̄2 = 55.87− 69.20 = −13.33 minutes

    • Is this difference in sample means large enoughto say that µ1 6= µ2?

    •What is the probability of observing a differ-ence this large (or larger) even when the twopopulations actually spend the same amountof time, on average? i.e. when µ1 − µ2 = 0.

    5

  • • To get at this probability, we need to knowthe ‘behavior’ of the difference in sample meansX̄1 − X̄2.

    •We looked at the distribution of this randomvariable (X̄1− X̄2) in chapter 7, and we willrevisit it here.

    6

  • •Difference in sample means:

    1. If σ21 and σ22 are known, and the distri-

    bution of values from both groups is nor-mal, we have

    X̄1 − X̄2 ∼ N

    (µ1 − µ2,

    σ21n1

    +σ22n2

    )and

    Z =(X̄1 − X̄2)− (µ1 − µ2)√

    σ21n1

    +σ22n2

    where Z has a N(0,1) distribution.

    If the original distributions are not normalbut n is large, the above will also followfrom the central limit theorem.

    7

  • • Difference in sample means:

    2. If σ21 and σ22 are NOT known, we

    will have to estimate them. IF IT IS REA-SONABLE TO ASSUME BOTH GROUPSHAVE A COMMON σ2, we will pool theinformation from both groups to estimatethis common σ2.

    The pooled estimator of σ2 denoted by S2pis defined by

    S2p =(n1 − 1)S21 + (n2 − 1)S

    22

    n1 + n2 − 2

    This value estimates both σ21 and σ22 be-

    cause σ21 = σ22 = σ

    2.

    S21 is the sample variance from group 1.

    S22 is the sample variance from group 2.

    8

  • S2p is a weighted average of the two samplevariances.

    If the distribution of values from both groupsis normal, we have the random variable Tas

    T =(X̄1 − X̄2)− (µ1 − µ2)√

    S2pn1

    +S2pn2

    =(X̄1 − X̄2)− (µ1 − µ2)

    Sp

    √1n1

    + 1n2

    and T has a tn1+n2−2 distribution,i.e. a t-distribution with n1 + n2 − 2 de-grees of freedom.

    9

  • • Difference in sample means:

    3. If σ21 and σ22 are NOT known, AND

    they have different variances, then we shouldnot take a pooled estimate of the variabil-ity, we should instead leave them separateas S21 and S

    22 . In this case we have the

    random variable T as

    T =(X̄1 − X̄2)− (µ1 − µ2)√

    S21n1

    +S22n2

    where T has a tν distribution, and the de-grees of freedom ν for the t distribution isgiven by...

    10

  • ν =

    (S21n1

    +S22n2

    )2(S21n1

    )2n1−1 +

    (S22n2

    )2n2−1

    This is known as Welch’s approximate t.

    11

  • • Thus, in working with X̄1 − X̄2 to make aninference on µ1 − µ2

    – if we know σ21 and σ22 we will use a

    Z-distribution.

    – if we don’t known them and we thinkσ21 = σ

    22, we will use a t-distribution with

    n1 + n2 − 2 degrees of freedom and use apooled estimate of the common varianceas S2p.

    – if we don’t known them and we thinkσ21 6= σ

    22, we will use a t-distribution with

    ν degrees of freedom (ugly but useful, for-mula on previous slide) and have separateestimates for the variances as S21 and S

    22 .

    • Back to the example where we will utilize ahypothesis test...

    12

  • QUESTION: Do males and females at UIspend the same amount of time, on average,at the UI fitness center?

    1. H0 : µ1 = µ2 ⇒ H0 : µ1− µ2 = 0H1 : µ1 6= µ2 ⇒ H1 : µ1− µ2 6= 0

    Group 1 is the females, group 2 is themales.

    2. TEST STATISTIC:We have a small sample from each groupand σ21 and σ

    22 are not given to us. We

    will use a t-statistic.

    We will assume the groups have a commonvariance σ2 (we can check this assumptionlater).

    n1 = 15 n2 = 15x̄1 = 55.87 min. x̄2 = 69.20 min.s1 = 13.527 min. s2 = 13.790 min.

    13

  • Pooled estimate of common σ2:

    s2p =(n1 − 1)s21 + (n2 − 1)s

    22

    n1 + n2 − 2

    =14× 13.5272 + 14× 13.7902

    15 + 15− 2=186.572

    and sp =√

    186.572 = 13.659

    The observed test statistic under H0 true,

    t0 =(x̄1 − x̄2)− (µ1 − µ2)

    sp

    √1n1

    + 1n2

    =(−13.33)− (0)

    13.659√

    115 +

    115

    = −2.67

    and T0 ∼ t28 under H0 true (n1+n2−2=28).

    14

  • 3. P-VALUE:Under H0 true, T0 ∼ t28.

    Compute P (T0 ≤ −2.67) = 0.0062 (fromsoftware, not your t-table)

    This is a 2-sided test,so P-value = 2× 0.0062 = 0.0124

    4. DECISION:Because the P-value is < α = 0.05, we re-ject H0. There IS statistically significantevidence that the mean time spent at theFitness Centers is not the same for menand women.

    5. CHECK ANY ASSUMPTIONS:With the T test statistic (unknown σ2),we’ll check that the original distributionsare nearly normal.

    15

  • Women Men

    normal probability plot normal probability plot

    We could also check the constant varianceassumption (we note that s1 and s2 arevery similar, but there are specific testsand plots we can use to check this.)

    We should also make sure that we haveindependent random samples from the twopopulations we were interested in.

    16

  • There are many choices for statistical software,Minitab being one of them. Here is the outputfrom this analysis performed in the the freelyavailable software called R:

    > t.test(women,men,var.equal=T)

    Two Sample t-test

    data: women and men

    t = -2.6733, df = 28, p-value = 0.01239

    alternative hypothesis: true difference in means

    is not equal to 0

    95 percent confidence interval of difference:

    -23.55011 -3.11656

    sample estimates:

    mean of x mean of y

    55.86667 69.20000

    17

  • On occasion we may want to do a test such as

    H0 : µ1 − µ2 = 40

    Where we’re interested in a specific differencebetween the means...

    • Example 2: Viscosity

    Fifteen batches of polymer are manufacturedunder the present process and the viscosityis measured:

    734, 738, 772, 760, 745, 759, 752, 756, 742,740, 761, 749, 739, 747, 742

    A process change is made and eight batchesare manufactured and the viscosity is mea-sured:

    755, 785, 756, 770, 783, 760, 758, 77618

  • From a long history of viscosity measurements,they know the variability of viscosity is fairlystable, and they know σ = 12. They alsoknow the viscosity measurements are nor-mally distributed.

    They would like to detect it if the mean viscosityof the new process is more than 10 units abovethe old mean (this could cause problems inmanufacturing down the line).

    Perform a hypothesis test at the α=0.05 level.

    Because σ is known, the test statistic will bea Z-statistic.

    x̄2 = 767.9 and x̄1 = 749.1 andx̄2 − x̄1 = 18.8

    where group 2 is from the new manufacturingprocess.

    19

  • The difference in sample means IS more than10 units, but have we collected enough datato feel fairly confident that the populationmeans are more than 10 units apart?

    1. Hypotheses:H0 : µ2 − µ1 = 10H1 : µ2 − µ1 > 10

    where µ2 is the average viscosity for thenew process.

    2. Test statistic:

    z0 =(x̄2 − x̄1)− (µ2 − µ1)√

    σ22n2

    +σ21n1

    =(18.8)− (10)√

    1228 +

    12215

    = 1.68

    20

  • 3. P-value:P (Z > 1.68) = 0.0468 {1-sided test}

    4. Decision:p-value = 0.0468 is less than α = 0.05.We reject H0.

    There is statistically significant evidencethat the mean of the new process is morethan 10 units above the mean of the oldprocess.

    5. We were given info that viscosity followeda normal distribution.

    ——————————————————–

    21

  • • Example 3: Differential Gene Expression

    A gene that shows differential expression be-tween two groups can be very informativefrom a biological perspective.

    Comparisons:Cancer vs. Healthy patientsFast running mice vs. lazy miceObese individuals vs. healthy weight indvl’sHigh yield plants vs. low yield plants

    In a plant genetics study, the gene calledAt5g50550 in the Arabidopsis plant showedthe following two sample expression distri-butions for the genetic lines called Columbiaand Landsberg.

    22

  • Perform a hypothesis test for differential ex-pression (i.e. for non-equality of mean expres-sion).

    23

  • The numerical summaries:(expression values have been normalized)

    Columbia :n1 = 19 x̄1 = 0.60 s

    21 = 0.017

    Landsberg :n2 = 11 x̄2 = −0.16 s22 = 0.042

    We do not know the population variances, sowe will use a t-statistic.

    We will NOT assume a common variance, sowe will use Welch’s approximate t and getthe degrees of freedom ν from...

    24

  • ν =

    (S21n1

    +S22n2

    )2(S21n1

    )2n1−1 +

    (S22n2

    )2n2−1

    =

    (0.017

    19 +0.042

    11

    )2(0.01719 )218 +

    (0.042

    11

    )210

    =14.78

    and since more degrees of freedom meansmore information, we don’t want to implywe have more info than we do, so we round-down to 14 (to be conservative).

    25

  • 1. Hypotheses:H0 : µ1 = µ2 {equal expression}H1 : µ1 6= µ2

    where µ1 is the average gene expressionfor Columbia.

    2. Test statistic:

    t0 =(x̄1 − x̄2)− (µ1 − µ2)√

    s21n1

    +s22n2

    =(0.60−−0.16)− (0)√

    0.01719 +

    0.04211

    = 11.07

    And under H0 true, T0 ∼ t14

    3. P-value:

    2× P (T0 > 11.07) ≈ 0 Very small.

    26

  • 4. Decision:Reject H0. There is strong statistical sig-nificant evidence that these two groups havedifferent mean gene expression for this gene.

    5. Since we used a t-statistic, we should checknormality of the two distributions (normalprobability plots not shown here). Therewas one outlier in the Landsberg groupwhich may be of some concern.

    27

  • Comparison of two independent groups

    also called...

    Two-sample t-test(for H0 : µ1 − µ2 = 40)

    ...but if we know σ we actually do a Z-test.

    • This type of test is performed when the mea-surements in the first group are independentof the measurements in the second group

    • In these comparative experiments, we shouldhave a simple random sample from each pop-ulation (or group).

    28

  • Summary of which test statistic touse:

    1. If σ21 and σ22 are KNOWN, we’ll use a

    Z-statistic.

    (We should have the original distributionsbe normal, or n large enough for X̄ ’s tobe normal.)

    2. If σ21 and σ22 are NOT KNOWN, we’ll use

    a t-statistic:

    (a) If it is reasonable to assume both groupshave A COMMON σ2, we will pool theinformation from both groups to esti-mate this common σ2 with S2p, and thedegrees of freedom for the t is (n1+n2−2).

    29

  • (b) If the groups DO NOT HAVE ACOMMON σ2, we should not pool theinformation for a common estimate ofσ2. We will instead keep separate esti-mates for the variances as S21 and S

    22 ,

    and the degrees of freedom for the t willbe ν where ν comes from Welch’s ap-proximate t degrees of freedom formula.

    30

  • 100(1-α)% Confidence interval forµ − µ• The point estimate for µ1 − µ2 is x̄1 − x̄2.•We can form a 100(1-α)% confidence interval

    for the difference in parameters µ1−µ2 usingthe same criterion as the previous pages as:

    If σ21 and σ22 are KNOWN, use...

    x̄1 − x̄2 ± zα/2

    √σ21n1

    +σ22n2

    If σ21 and σ22 are NOT KNOWN...

    Case 1: with a common σ2, use...

    x̄1 − x̄2 ± tα/2,n1+n2−2

    √s2pn1

    +s2pn2

    Case 2: without a common σ2, use...

    x̄1 − x̄2 ± tα/2,ν

    √s21n1

    +s22n2

    where ν is from Welch’s approximate

    t degrees of freedom

    31

  • Comparison of two independent groups

    ... we do a Two-sample t-test(for H0 : µ1 − µ2 = 40)

    • This type of test is performed when the mea-surements in the first group are independentof the measurements in the second group

    • The µ1 − µ2 hypothesis examples so far fitthis scenario:

    – Time exercising for males and females

    ∗ n1 = 15 and n2 = 15 and the men andwomen chosen didn’t have anything incommon, they were independent

    32

  • – Viscosity from old process and new pro-cess

    ∗ n1 = 15 and n2 = 8 and the two groupsof measurements were taken indepen-dent of each other

    – Differential gene expression in Columbiaand Landsberg

    ∗ n1 = 19 and n2 = 11 for two indepen-dent groups of plants

    If the two groups are not independent andwe have paired data, we will perform aPaired t-test... next section.

    33