Chi Square_Additional Lectures

download Chi Square_Additional Lectures

of 9

Transcript of Chi Square_Additional Lectures

  • 8/3/2019 Chi Square_Additional Lectures

    1/9

    Chi-Square

    2

    Introduction to Nonparametrics

    Psychology 320

    Gary S. Katz, Ph.D.

    Definitions

    Parametric Tests

    Statistical tests that involve assumptions about

    or estimations of population parameters.

    (what weve been learning)

    Nonparametric Tests

    Also known as distribution-free tests

    Statistical tests that do not rely on assumptions

    of distributions or parameter estimates

    (what were going to be learning)

    More Definitions

    The Chi-Square (X2) test is a nonparametric

    test that is used to test hypotheses about

    distributions of frequencies across

    categories of data.

    Different from what weve been learning

    Then Now

    Averages Frequencies

    Scales Categories

    Two Applications of the Chi-Square Test

    The X2 goodness-of-fit test.

    Used when we have distributions of frequencies

    across two or more categories on one variable.

    Test determines how well a hypothesized

    distribution fits an obtained distribution.

    The X2 test of independence.

    Used when we compare the distribution of

    frequencies across categories in two or more

    independent samples.

    Used in a single sample when we want to knowwhether two categorical variables are related.

    The X2 Goodness-of-Fit Test

    Flowers & GeneticsIn my backyard, I have a new hybrid rose bush.

    I hypothesize that (according to Mendelian genetic

    theory) that I should have 50% pink flowers,

    25% white flowers, and 25% red flowers.

    Pp Pp

    PP Pp Pp pp

  • 8/3/2019 Chi Square_Additional Lectures

    2/9

    FlowersI grow 120 of these plants from seed. The resulting

    colors of flowers are as follows:

    Pink White Red

    75 20 25

    Flowers - Reality & ExpectationsRecall, my expectations were 50% Pink, 25% White, 25% Red.

    Pink White Red

    75 20 25Observed

    60 30 30Expected

    So, if I planted 120 seeds, Id expectthis set of colored flowers.

    Flowers - Reality & Expectations

    Pink White Red

    75 20 25Observed

    60 30 30Expected

    If my hypothesis is true (50%, 25%, 25%), how likely is it that I

    could get this difference between my actual distribution

    and my expected distribution of colored flowers?

    The Chi-Square Test

    Used to determine if the probability < , in

    which case the hypothesis is rejected

    or

    if the probability > , in which case the

    hypothesis is not rejected.

    If my hypothesis is true (50%, 25%, 25%), how likely is it that I

    could get this difference between my actual distribution

    and my expected distribution of colored flowers?

    The Chi-Square Test

    Hypotheses

    H0: P(pink, white, red) = .5, .25, .25

    The population proportions of pink, white, and

    red flowers are .5, .25, and .25, respectively.

    H1: P(pink, white, red) .5, .25, .25The population proportions of pink, white, and

    red flowers are something other than .5, .25,

    and .25, respectively.

    mutually-exclusive, exhaustive categories (P=1).

    The Chi-Square Test

    Notice that the hypotheses for the Chi-

    Square Goodness-of-Fit Test are stated in

    terms of proportions.

    The Chi-Square TEST is conducted on

    actualfrequencies not proportions.

    Specifically, the X2 test operates on

    differences between observed and expected

    frequencies.

    First - make sure everything is a frequency.

  • 8/3/2019 Chi Square_Additional Lectures

    3/9

    The Chi-Square Test

    Observed frequencies = O

    Expected frequencies = E

    E = N Expected Proportion

    E = N P(cell)

    Notice that E = O, always.

    Pink White Red

    75 20 25Observed

    120(.5) = 60 120(.25) = 30 120(.25) = 30Expected

    O = 120

    E = 120

    In the Chi Square Test

    we calculate (O-E)2

    /E in each cell, sum all of the (O-E)2/E values over all cells,

    and compare this summed value to a critical

    value.

    ( ) = EEOo2

    2

    The Chi-Square Distribution

    Statisticians have found that if H0 is true

    and we calculate the X2 statistic for all

    possible samples of size N, the values for a

    probability distribution called the X2

    distribution.

    Characteristics of the X2

    distribution

    A family of distributions varying in df (like

    the tdistribution).

    Positively skewed; the amount of skew

    decreases as dfincreases.

    Minimum value = 0 (X2 cant be negative)

    Average (typical) value increases (the entire

    distribution shifts to the right) as df

    increases.

    Characteristics of the X2 distribution

    A family of distributions varying in df (like the tdistribution).

    0

    df=1df=3

    df=5

    df=10

    Characteristics of the X2 distribution

    As differences between Os and Es getbigger, X2 gets bigger.

    Since we are only interested in rejecting H0if the differences between the obtained

    frequencies and the expected frequencies is

    greaterthan expected by chance, the

    rejection region is in the upper tail.

    ( ) = EEOo2

    2

  • 8/3/2019 Chi Square_Additional Lectures

    4/9

    Chi-Square: Upper One-Tailed Test

    X2c

    Decision Rule: Reject H0 if X2

    o > X2

    c

    Finding X2c

    Table E.1 has the tabled values. df?

    df = k - 1

    Why?

    If you have 3 categories, only the counts in 2 of

    them are free to vary.

    Choose , read down list ofdfto find X2c

    Finding X2cdf 0.050 0.025 0.010 0.005

    1 3.841 5.024 6.635 7.879

    2 5.991 7.378 9.210 10.597

    3 7.815 9.348 11.345 12.838

    4 9.488 11.143 13.277 14.860

    5 11.070 12.832 15.086 16.750

    6 12.592 14.449 16.812 18.548

    7 14.067 16.013 18.475 20.278

    8 15.507 17.535 20.090 21.955

    9 16.919 19.023 21.666 23.589

    10 18.307 20.483 23.209 25.188

    11 19.675 21.920 24.725 26.757

    12 21.026 23.337 26.217 28.300

    13 22.362 24.736 27.688 29.819

    14 23.685 26.119 29.141 31.319

    15 24.996 27.488 30.578 32.801

    16 26.296 28.845 32.000 34.267

    17 27.587 30.191 33.409 35.718

    18 28.869 31.526 34.805 37.156

    19 30.144 32.852 36.191 38.582

    20 31.410 34.170 37.566 39.997

    The Dreaded Six Steps

    State H0 and H1.

    Choose

    Relevant probability distribution is X2 with

    k- 1 df.

    Find X2c & state decision rule: I will reject

    H0 if X2o > X

    2c

    Calculate X2o

    Apply decision rule.

    Calculating X2o

    Pink White Red

    75 20 25Observed

    60 30 30Expected

    Finding X2oPink White Red

    75 20 25Observed

    60 30 30Expected

    Pink White Red

    15 -10 -5Observed - Expected

    (O-E) = 0, always

  • 8/3/2019 Chi Square_Additional Lectures

    5/9

    Finding X2o

    Pink White Red

    225 100 25(Observed - Expected)2

    Pink White Red

    15 -10 -5Observed - Expected

    Finding X2o

    3.75 3.33 .83(Observed - Expected)2 / Expected

    Components of

    X2

    WhitePink Red

    [(O-E)2/E] = X2o = 7.91

    Since X2o > X2c, reject H0

    Pink White Red

    225 100 25(Observed - Expected)2

    60 30 30Expected

    Interpretation

    Since we reject H0, the geneticists

    hypothesis does not fit the data.

    The population distribution across the three

    categories is probably different than .50

    pink, .25 white, .25 red.

    Another Example: Breakfast!

    The manufacturer of Posts Raisin Bran cereal, which lags

    behind Kelloggs in sales, believe that, given the chance to

    try both, most consumers will prefer Posts. They devise a

    blind taste test. A sample of 100 people eat a small bowl

    of each cereal, without knowing which is which, and they

    are asked which cereal they like better. Fifty-seven people

    say they like Posts better, while 43 choose Kelloggs.

    Can the manufacturer advertise, More people prefer Posts?

    H0: P(Posts) = P(Kelloggs) or P(Posts, Kelloggs) = .5, .5

    H1: P(Posts) P(Kelloggs) or P(Posts, Kelloggs) .5, .5

    Breakfast Answers

    2) Use = .05

    3) df = 1, X2 distribution with 1 df

    4) X2c for = .05, df = 1, is 3.84; Decision rule: reject H0 if X2o > 3.84

    5) Calculations

    E(Posts) = E(Kelloggs) = 100 (.5) = 50

    Cereal O E O-E (O-E) 2 (O-2) 2/E

    Post's 57 50 7 49 0.98

    Kellogg's 43 50 -7 49 0.98

    100 100 0 1.96 = X2o

    Since X2o < X2c (1.96 < 3.84), we retain H0.

    The manufacturerscannot claim that more people prefer Posts.

    Extra Credit Breakfast

    In the Breakfast Example, we found that a 57 to 43

    majority isnt enough to reject H0.

    What is the smallest number of Posts preferences

    that will lead to a significant finding (rejection of H0)

    at = .05?

    Correct and well-reasoned answers are worth 5pts

    on top of your final (total) grade.

  • 8/3/2019 Chi Square_Additional Lectures

    6/9

    Assumptions of the

    Goodness-of-Fit Test

    Observations in different categories are

    independent.

    Categories are mutually exclusive.

    Categories are exhaustive.

    No expected frequency < 2.

    Few expected frequencies < 5.

    The X2 distribution does not accurately

    describe the probabilities of various sampling

    outcomes if expected frequencies are small.

    The X2 test of Independence

    The X2 Test of Independence

    Used when:

    We want to compare the distribution of

    frequencies across categories in two or more

    independent samples.

    We want to determine whether the paired

    observations obtained in two or more

    categorical variables are independent or

    associated.

    Same test.

    Physical Contact in Neonates

    A developmental psychologist hypothesizes that mothers who

    have physical contact with their infants immediately after

    birth are more likely to hold them on the left side, where the

    sound of the mothers heartbeat is more pronounced, than

    mothers who do not have such early contact with their infants.

    She observes 125 early-contact mothers and 105 late-

    contact mothers with the following results:

    Late 55

    Early 80

    50

    45

    Left Right

    105

    125

    230

    Is there a

    significant

    difference?

    Contingency Tables

    This type of table is called a contingency

    table.

    We are trying to determine if the frequencies in

    one variable are contingent upon the

    frequencies of the other variable.

    This is a 2 2 contingency table.

    Late 55

    Early 80

    50

    45

    Left Right

    Stating H0 & H1

    When two or more groups are being

    compared, H0 states that the population

    distributions across all categories are thesame.

    H1 states that the population distributions

    differ.

  • 8/3/2019 Chi Square_Additional Lectures

    7/9

    Stating H0 & H1

    H0 : Early and late contact mothers do not

    differ in how they hold their neonates.

    H1 : Early and late contact mothers hold their

    neonates differently.

    OR

    H0 : Group membership and distribution

    across categories are unrelated.

    H1 : Group membership and distribution

    across categories are related.

    Stating H0 & H1

    H0 : Group membership and distribution

    across categories are unrelated.

    H1 : Group membership and distribution

    across categories are related.

    OR

    H0 : Time of first contact and how neonates

    are held arenot related

    H1 : Time of first contact and how neonates

    are held are related.

    Stating H0 & H1

    H0 : Time of first contact and how neonates

    are held arenot related

    H1 : Time of first contact and how neonates

    are held are related.

    OR

    H0 : Time of first contact and how neonates

    are held are independent.

    H1 : Time of first contact and how neonates

    are held aredependent / correlated /related.

    The X2 Test of Independence

    Test statistic for the test of independence is

    the same as in the goodness-of-fit test:

    Two differences:

    Calculation of expected frequencies

    Calculation ofdf

    ( ) = EEOo2

    2

    Calculation of Expected Frequencies:

    X2 test of Independence

    For each cell,

    ( )( )N

    Esumcolumnsumrow

    =

    Where N = total number of observations.

    Calculation of Expected Frequencies:

    X2 test of Independence

    ( )( )4.73

    230

    135125),( ==leftearlyE

    Left Right Row Sums

    Early 80 45 125Late 55 50 105

    Column Sums 135 95 N = 230

    ( )( )6.51

    230

    95125),( ==rightearlyE

    ( )( )6.61

    230

    135105),( ==leftlateE

    ( )( )4.43

    230

    95105),( ==rightlateE

  • 8/3/2019 Chi Square_Additional Lectures

    8/9

    Observed and Expected Frequencies

    Left Right Row SumsEarly 80 45 125Late 55 50 105

    Column Sums 135 95 N = 230

    Observed Frequencies

    Left Right Row Sums

    Early 73.4 51.6 125

    Late 61.6 43.4 105

    Column Sums 135 95 N = 230

    Expected Frequencies

    Marginal Frequencies are Fixed in X2Analyses.

    Why this Row and Column Sum?

    N

    rowPsumrow

    )( =

    N

    columnPsumcolumn

    )( =

    NNP

    sumcolumnsumrow)columnrow AND( =

    Expected frequencies = N P

    NNNE

    sumcolumnsumrow)columnrow AND( =

    NE

    sumcolumnsumrow)columnrow AND(

    =

    dfin X2 Independence Tests

    df = (# rows - 1) (# columns - 1)

    Why?

    Remember marginals are fixed in X2

    independence tests.

    100

    100

    50 60 90

    How many cells are truly free to vary?

    Mothers and Neonates

    H0 : Time of first contact and how neonates

    are held are independent.

    H1 : Time of first contact and how neonates

    are held aredependent / correlated /

    related.

    = .05

    X2 distribution with 1 df

    X2

    c for

    = .05, 1 df = 3.84; reject H0 if X

    2o > 3.84

    Mothers and Neonates

    Left Right

    Early 80 45Late 55 50

    Observed FrequenciesLeft Right

    Early 73.4 51.6Late 61.6 43.4

    Expected Frequencies

    Left Right

    Early 6.6 -6.6

    Late -6.6 6.6

    Observed - Expected Left Right

    Early 43.56 43.56

    Late 43.56 43.56

    (Observed - Expected) 2

    Left Right

    Early 0.59 0.84

    Late 0.71 1.00

    (O - E)^2 / E ( ) = EEOo2

    2

    X2o = 3.14

    Decision: Retain H0, there is no relationship between side and time.

    Overview of X2

    X2 - a nonparametric test applied to

    categorical, frequency data.

    Relevant probability distribution is the X2

    distribution.

    A family of distributions varying in df

    Positively skewed with minimum = 0

    Skew decreases as dfincreases.

    Center of distribution and critical values

    increase as dfincreases.

  • 8/3/2019 Chi Square_Additional Lectures

    9/9

    Overview of X2

    Rejection region in the upper tail.

    Decision rule: reject H0 if X2o > X2c

    Two forms:

    Goodness-of-fit

    used to determine whether an obtained distribution

    fits a hypothetical one.

    Independence

    used to test whether two categorical variables are

    related

    used to test whether two different samples are

    related