Data Analysis (1) Qual Qual

55
Data Analysis (1/3)

description

Data Analysis

Transcript of Data Analysis (1) Qual Qual

Page 1: Data Analysis (1) Qual Qual

Data Analysis (1/3)

Page 2: Data Analysis (1) Qual Qual

Typical steps for a Statistical study

1. Define the goals

2. Collect the data

3. Organize the data

4. Present the data

5. Describe the data

6. Analyze the data

7. Interpret results 3

How this

lecture fits up

to this

point...

Page 3: Data Analysis (1) Qual Qual

Is there a correlation/association/relationship/interaction between the variables?

Dependence:

o Relationship exists between variables

o Change in one variable is accompanied by change in the other variable (these two things seem to happen at the same time).

Independence: o No relationship exists

between variables

o Change in one variable is NOT accompanied by change in the other variable.

Positive relationship Negative relationship

No relationship

As x increases, Y increases

As x increases, Y decreases

As x increases, Y doesn’t change

Page 4: Data Analysis (1) Qual Qual

Which statement makes more sense:

1) The age of a bus can influence the maintenance cost.

2) The maintenance cost can influence the age of the bus.

X-axis is the INDEPENDENT

Variable (Age) which influences the

dependent variable.

Y axis is the

DEPENDENT

variable (Cost)

which is influenced.

To study a relationship, one variable is called the DEPENDENT variable and the other is called the INDEPENDENT variable.

The dependent variable may be explained/predicted/influenced/

understood by the independent variable.

Page 5: Data Analysis (1) Qual Qual

Data Analysis and Tools

Chi-Square Chi-Square

Numerical

Categorical Numerical

Categorical

Independent Variable (X) De

pe

nd

ent

Var

iab

le (

Y)

The data and the type of research question you want answered will determine the most appropriate analytical

procedure to select.

Let’s go!

Page 6: Data Analysis (1) Qual Qual

There are two contingency table tests:

(1) Two-way table contingency test (also called “test of independence”)

(2) One-way table contingency test (also called “goodness of fit test”)

Page 7: Data Analysis (1) Qual Qual

8

1. Is there a relationship between the variables?

Visually (Stacked Bar Graph) Mathematically (statistical test) 2. If there is a relationship, how

STRONG is the relationship?

Two-way table contingency test (also called “test of independence”)

Page 8: Data Analysis (1) Qual Qual

Format convention

Bad Presentation

Ex. Variables GENDER and VIEW OF LIFE Which sentence makes more sense? Does gender have an effect on View of life (Is life exciting , routine, or dull?) Does View of life (Is life exciting , routine, or dull?) have an effect on gender?

The independent variable is on the horizontal axis (X) The dependent variable is on the vertical axis (Y).

Independent variable: Gender Dependent variable: View of Life

We will study the differences in outcomes of the dependent variable (view of life) across the independent variable (gender). We will compare two groups (male and female) responses.

Good Presentation

Page 9: Data Analysis (1) Qual Qual

No Relationship The 100%f stacked bar chart does

NOT significantly CHANGE for different categories of the IV.

Relationship The 100%f stacked bar chart DOES

significantly CHANGE for different categories of the IV. (at least one has to change for some relationship to be detected).

Dependent variable: Political Party

Independent variable: Area of residence

Is there a relationship/difference between the variables?

Page 10: Data Analysis (1) Qual Qual

11

1. Is there a relationship between the variables?

Visually (Stacked Bar Graph) Mathematically (statistical test) 2. If there is a relationship, how

STRONG is the relationship?

Two-way table contingency test (also called “test of independence”)

Page 11: Data Analysis (1) Qual Qual

Research Question: Is there a difference in house styles (DV) at different locations (IV)?

A sample is taken and organized into a

two way contingency table.

House Location

House Style Urban Rural Total

Split-Level 63 49 112

Ranch 15 33 48

Total 78 82 160

Is there a relationship between the variables?

Urban Rural

Split Split

100

80

60

40

20

Is there a significant difference?

Ranch Ranch

Page 12: Data Analysis (1) Qual Qual

1. Form hypothesis.

2. Calculate the chi “kai” square (2) statistic.

3. Find the (2) significant value in the table.

4. Compare 2 statistic to 2 significant.

How to we test this claim?

total totalRow ColumnExpected count=

total number of cellscell

2

2

each cell

statistic

observed Expected

Expected

Ho “null hypothesis”: No relationship exists (variables are Independent) Ha “alternative hypothesis”: Relationship exists (variables are Dependent)

2significant = 2

α,df

=.05 (default value used in any statistical program) we will discuss this in detail soon!

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

2Statistic > 2

Significant REJECT Ho. Accept Ha.

2Statistic < 2

Significant FAIL TO REJECT Ho.

Remember to state your result in the context of the specific problem!

Page 13: Data Analysis (1) Qual Qual

Find the (2) significant value in the table

df = (#rows-1)

x (# columns–1)

Page 14: Data Analysis (1) Qual Qual

Step 1: Form Hypothesis

Solution Step 2: Calculate chi-squared (2) statistic

Step 3: Find 2 significant

Step 4: Compare 2 statistic to 2 significant

Ho “null hypothesis”: No relationship exists (Variables are Independent)

Ha “alternative hypothesis”: Variables are related (Dependent)

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

= (2 - 1)(2 - 1) = 1 =.05 (default value)

2significant= 2

α,df = 2.05,1 = 3.841

2 Statistic (7.62) > 2 Significant (3.841 )

Reject Ho. There is evidence of relationship between the variables.

total totalRow ColumnExpected Count =

total number of cellsfor each cell

2

2

each cell

2 2

2 2

63 55 49 57

55 57

15 23 33 257.62

23 25

statistic

observed Expected

Expected

Observed Expected

Style Urban Rural Total Style Urban Rural Total

Split 63 49 112 Split 55 57 112

Ranch 15 33 48 Ranch 23 25 48

Total 78 82 160 Total 78 82 160

Location Location

= 112·78 = 55 160

The chi-square statistic compares the observed count in each table to the count that would be expected under the assumption of no association between the variables.

Remember to state your result in the context of the specific problem! The style of house differs depending on the location.

Page 15: Data Analysis (1) Qual Qual

The market research group for Alber’s Brewery of Tuscon, AZ, wants to know whether

preferences of beer type (light, regular, dark) differ among gender (male, female).

If beer preference is independent of gender, one advertising campaign will be initiated.

However, if beer preference depends on the gender of the beer drinker, the firm will

tailor its promotions to different target markets.

Your turn!

At the .05 level of significance, is there a statistically significant difference between beer preference for males and females? What about at the .01 level of significance?

M

Stacked bar graph

F

100%

75%

50%

25%

0

25% Light 43%

Light

25% Dark 14% Dark

50% Regular

43% Regular

A survey was conducted and the following

data was collected:

Are the variables related?

Page 16: Data Analysis (1) Qual Qual

Step 1: Form Hypothesis

Your turn! Solution Step 2: Calculate chi-squared (2) statistic

Step 3: Find 2 significant

Step 4: Compare 2 statistic to 2 significant

Ho “null hypothesis”: No relationship exists (Variables are Independent)

Ha “alternative hypothesis”: Variables are related (Dependent)

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

= (3 - 1)(2 - 1) = 2 =.05 (default value)

22,.05 = 5.991

22,.01= 9.210

total totalRow ColumnExpected Count =

total number of cellsfor each cell

2

2

each cell

2 2

2 2

2 2

20 27 40 37

27 37

20 16 30 23

16 23

30 33 10 14

33 14

6.604

statistic

observed Expected

Expected

REJECT Ho at the .05 level of significance (2 Statistic (6.604) > 2 Significant (5.991)). There is a difference in beer preferences for men and woman. More females prefer light beer than men. Men prefer regular beer over light/dark and females prefer light/regular over dark beer.

FAIL TO REJECT Ho at the .01 level of significance (2 Statistic (6.604) < 2 Significant (9.210)). There is not enough evidence to reject Ho. Any differences in cell frequencies could be explained by chance.

Page 17: Data Analysis (1) Qual Qual

What is α “Significance Level”? (also called a type 1 error).

The significance level is: how often you are wrong The most common α value is .05. This means there is a 5% chance that we are wrong in our findings from testing the claim. Conversely, there is a 95% chance that we are correct. What should α be? It is subjective. Other common values for α are .01 (99% confident in our results) and .10 (90% sure of our results).

Page 18: Data Analysis (1) Qual Qual

Verdict: “GUILTY” REJECT Ho. There is enough evidence to

convict (guilty).

Important wording of conclusion “REJECT” vs “FAIL TO REJECT”

Let’s use the legal system as an example. The defendant is on trial for murder. A person is presumed innocent until proven guilty.

Ho = Innocent Ha = Guilty We assume Ho to be true. If there is enough evidence to prove Ha then we REJECT Ho and Ha is true.

Verdict: “NOT GUILTY” FAIL TO REJECT Ho. We do not say “Accept Ho”. There is

NOT enough evidence to convict but we are not proving innocence.

How much evidence we need is related to how confident we want to be in our results. α (the level of significance) is how often we are wrong (also called type 1 error). Small Claims Court for endangerment of a child: Less evidence needed to convict, α=.05 means there is a 5% chance you are wrong. Casey Anthony verdict is Reject Ho (“GUILTY”) Jury for 1st degree murder: More evidence needed to convict: α =.01 means there is a 1% chance you are wrong. Casey Anthony verdict is Fail to Reject Ho (“NOT GUILTY”)

Page 19: Data Analysis (1) Qual Qual

“Statistically Significant” The value of α used depends

on how confident you want to be in your results. What is “statistically significant” to one person might not be to another.

Statisticians Has to have at least a 95% chance of being true to be considered worth telling people about (why α=.05 is default for any statistical program).

Manager If something has a 90% chance of being true (α =.1), it is probably better to act as if it were true rather than false!

Page 20: Data Analysis (1) Qual Qual

The jury finds the defendant “GUILTY”… But we are WRONG and an innocent person goes to jail!!! This is Type I error. If 𝜶=5%, there is a 5%

chance that this error will occur. That is, we are wrong to

REJECT Ho.

Unfortunately, neither the legal system nor statistical testing are perfect. Remember that Ho = Innocent and Ha = Guilty.

Type I and Type II errors

Which is worse? How you feel about it depends on the level of 𝜶 that you choose. α & β have an Inverse Relationship. If we increase α, we decrease β, and vice versa!

The jury finds the defendant “NOT GUILTY”… But we are WRONG and a guilty person is set free (ex.

OJ Simpson, Casey Anthony)!!! This is Type II error. If β=5%, there is a 5% chance

that this error will occur. That is, we are wrong to FAIL

TO REJECT Ho.

Page 21: Data Analysis (1) Qual Qual

Maybe this will help you remember Type I and Type II errors

We will learn how to calculate Type II error in another lecture…

Page 22: Data Analysis (1) Qual Qual

The chi-square distribution is defined by the degrees of freedom (df).

df = (# outcomes of row – 1) (# outcomes of column – 1)

Chi-Square (2) Distribution

As the number of possible outcomes of a variable increases, the curve approaches a normal distribution.

Page 23: Data Analysis (1) Qual Qual

REJECT Ho FAIL TO REJECT Ho

Compare 2 statistic to 2 significant

or p-value to 𝜶

𝝌𝟐statistic > 𝝌𝟐significant

p-value < 𝜶 Reject Ho

p-value > 𝜶 𝝌𝟐statistic < 𝝌𝟐significant

Fail to Reject Ho

𝝌𝟐statistic < 𝝌𝟐significant p-value > 𝜶

Fail to Reject Ho

Page 24: Data Analysis (1) Qual Qual

CHISQ.TEST Excel function

p value

p-value Statistical significance

>.10 Not Sig.

<.10 Marginal

<.05 Fair

<.01 Good

<.001 Excellent

Since .04 (p-value) < .05 (α) Reject Ho

Page 25: Data Analysis (1) Qual Qual

The sample size is large (expected frequency of each cell is > 5)

Chi-square Assumptions

Your turn!

Yes! We satisfy the assumption. If we did not, we cannot trust the results of this test!

Page 26: Data Analysis (1) Qual Qual

What if Assumptions are not met?

Possibly Combine categories to increase values in each cell!

Here, there are substantially fewer older adults than any other group. We could combine the middle age and older adult categories into a “not young” category. Then we would have 2x3 cross tab with larger n values.

Young Not Young Music 14 12 News 4 23 Sports 7 12

6

6

Fisher’s exact test can be used if E(x) <5…but only for 2x2 tables

Page 27: Data Analysis (1) Qual Qual

28

1. Is there a relationship between the variables?

Visually (Stacked Bar Graph) Mathematically (statistical test) 2. If there is a relationship, how

STRONG is the relationship?

Two-way table contingency test (also called “test of independence”)

Page 28: Data Analysis (1) Qual Qual

There are two families of effect sizes (r and d)

“d” family Quantifying the size of the difference between two groups

“r” family Measuring the association (CORRELATION) between the variables. How much can the change (variance) in one variable be explained by the other?

Effect size is a measure of the strength of a relationship

At the .05 significance level, Reject Ho. There is evidence of relationship between the variables implies that men and women have different beer preferences. So…

1. Which cell(s) caused the difference (difference between proportions)?

More females prefer light beer than men. Men prefer regular beer over light/dark and females prefer light/regular over dark beer.

2. Is the difference indicative of a weak, moderate, or strong relationship? (effect size)

Urban Rural

Split Split

100

80

60

40

20

How BIG is the difference?

Ranch Ranch

Page 29: Data Analysis (1) Qual Qual

1. We are only concerned with effect size if the result of the (chi-square) test was statistically significant. 2. The size of the p-value is no indication of the strength of the association (ex. small P-value does not imply strong association) 3. We are covering only the most widely used statistical tools (there are still many more but this is a basic course in statistics and those tools are for another course).

Some important points…

Page 30: Data Analysis (1) Qual Qual

Some common measures in the “r” family

Phi “Fi” (2x2 tables)

Cramer’s V (not 2x2 tables)

.40-.59 relatively strong

.60-.79 strong

General Guidelines for interpreting strength: A value of .1 is considered a weak (small) effect, .3 a moderate effect and .5 a strong (large) effect.

Page 31: Data Analysis (1) Qual Qual

Phi 𝜙 2 7.62

0.22160n

For effect size strength, .20(sqrt(2-1))=.20, which is a small effect size. The relationship is WEAK!

The common measures in the “r” family

2 6.6040.15

150 2V

n df

Cramer’s V

Another WEAK relationship!

According to Cohen’s guidelines in the SPSS book (A Guide to Doing Statistics in Second Language Research Using SPSS, Table 4.8, p. 119) for effect size strength, w=.17(sqrt(3-1))=.24, which is a small to medium effect size.

Squaring phi will give you the variance that can be explained. Whether the house location is urban or rural explains (.22x.22=.05) 5% of the variance in the style of house built.

The percentage variance effect sizes

The gender of a person explains 20% of the variance in marital status.

For effect size strength, .20(sqrt(2-1))=.20, which is a small effect size. The relationship is WEAK!

The relationship is WEAK!

The relationship is WEAK!

Squaring Cramer’s V will give you the variance that can be explained. The gender of a person explains (.15x.15=.023) 2.3% of the variance in beer preference.

2

2

each cell

2 2

2 2

63 55 49 57

55 57

15 23 33 257.62

23 25

statistic

observed Expected

Expected

2

2

each cell

2 2

2 2

2 2

20 27 40 37

27 37

20 16 30 23

16 23

30 33 10 14

33 14

6.604

statistic

observed Expected

Expected

Page 32: Data Analysis (1) Qual Qual

Evaluate difference for each category republican

rural vs suburban rural vs urban suburban vs urban

Independent rural vs suburban rural vs urban suburban vs urban

Democrat rural vs suburban rural vs urban suburban vs urban

Other rural vs suburban rural vs urban suburban vs urban

The chi-squared test shows a relationship exists…but where does the relationship (difference) occur?

(at least one has to change for some relationship to be detected). find where any significant associations may be in the r x c table by calculating adjusted residuals, and by partitioning the table according to the Lancaster-Irwin method.

• Standardized residual method:

• The chi-square test is an overall test to see if there are differences between any of the cell frequencies. If just two of the cells in the design are significantly different, the test will be significant. Only the Republican party showed significant change.

• If you find a SIGNIFICANT

relationship, you need to do a

post-hoc test to discover which

pairs of cells are significantly

different.

The “d” family (amount of difference)

2x2 table Not 2x2 table

Measure of effect size:

• Odds ratio (OR)

Measure of effect size:

• Adjusted standardized residuals

Urban Rural

Split Split

100%

80%

60%

40%

20%

How BIG is the difference?

M F

100%

75%

50%

25%

0

25% Light 43%

Light

25% Dark 14% Dark

50% Regular

43% Regular

The chi-squared test shows a relationship exists…but where does

the relationship (difference) occur?

Rural Rural

Page 33: Data Analysis (1) Qual Qual

22 / 852.41

9 / 84no fluRR

Odds Ratio

63 33 20792.83

15 49 735

adOR

bc

“Group 1 had odds of having outcome 1 OR times (“more” if OR>1; “less” OR<1) than those who were in group 2”.

Urban locations had odds of having a split-level house style 2.83 times more than those who were in the rural area.

Vitamin C No Vitamin C Total

Cold 17 31 48

No cold 122 109 231

Total 139 140 279

Vaccine Placebo Total

Flu 9 22 31

No flu 75 63 138

Total 84 85 169

Treatment Thrombus No thrombus Total

Placebo 18 7 25

Aspirin 6 13 19

Total 24 20 44

Group 1 Group 2 Total

Outcome 1 a c a+c

Outcome 2 b d b+d

Total a+b c+d a+b+c+d

House Location

House Style Urban Rural Total

Split-Level 63 49 112

Ranch 15 33 48

Total 78 82 160

No universal agreement regarding what constitutes a ‘strong’ or ‘weak’ association: ◦ OR > 2.0 is ‘moderately strong’; OR > 5.0 is ‘strong’

Weak associations are more likely to be explained by undetected biases or confounders.

Page 34: Data Analysis (1) Qual Qual

Hankinson SE et al. Obstet Gynecol. 1991;80:708-714.

Hildreth et al, 1981 Rosenberg et al, 1982 La Vecchia et al, 1984

Tzonou et al, 1984 Booth et al, 1989

Hartge et al, 1989 WHO, 1989

Wu et al, 1988 Prazzini et al, 1991

Newhouse et al, 1977 Casagrande et al, 1979

Cramer et al, 1982 Willet et al, 1981

Weiss, 1981 Risch et al, 1983

CASH, 1987 Harlow et al, 1988

Shu et al, 1989 Walnut Creek, 1981

Vessey et al, 1987 Beral et al, 1988

Odds Ratio 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5

Ho

sp

ital-

Based

C

ase-C

on

tro

l

Co

mm

un

ity-B

ased

C

ase-C

on

tro

l C

oh

ort

www.contraceptiononline.org

OR used to COMPARE STUDIES

Oral Contraceptive Use and Ovarian Cancer -ve Association + ve Association

Understanding the effect measures is important! You can compare studies (which you will do in the

Evidence-Based Practice course).

Consistency • Repeated observation of an association in studies

conducted on different populations under different circumstances

• If studies conducted by….different researchers; at different times; in different settings ; on different populations ; using different study designs;

……all produce consistent results, this strengthens the argument for causation

Page 35: Data Analysis (1) Qual Qual

Out of every 10 people that smoke, on average 2 will likely get cancer.

People that smoke have odds of developing the cancer 3.9 times (390%) higher than those that don’t smoke

One would need to harm 5 patients ( with smoke) see one case of cancer develop.

Vitamin C No Vitamin C Total

Cold 17 31 48

No cold 122 109 231

Total 139 140 279

Question of interest: Is smoking related to cancer?

Vaccine Placebo Total

Flu 9 22 31

No flu 75 63 138

Total 84 85 169

Treatment Thrombus No thrombus Total

Placebo 18 7 25

Aspirin 6 13 19

Total 24 20 44

Those that smoke are 3 times (or 300%) more likely to develop lung cancer than those that don’t smoke.

/ ( ) 30 /1003

/ ( ) 10 /100

a a bRR

c c d

( / ( )) ( / ( ))

(30 /100) (10 /100) .2

ARR a a b c c d

There is a 200% increase in lung cancer cases for smokers compared to those that don’t smoke.

/ ( ) / ( ) (30 /100) (10 /100)2

/ ( ) 10 /100

a a b c c dRRR

c c d

1/ 1/ .2 5NNT ARR

30 903.9

70 10

adOR

bc

Measure of effect sizes for medical studies

Group 1 Group 2 Total

Outcome 1 a c a+c

Outcome 2 b d b+d

Total a+b c+d a+b+c+d

Odds ratio (OR)

Relative Risk

Relative risk improvement/reduction

Absolute risk improvement/reduction

Number needed to treat/harm (NNT/NNH)

Page 36: Data Analysis (1) Qual Qual

ABSOLUTE vs RELATIVE Risk Remember our calculation for the smoking example:

Out of every 10 people that smoke, on average 2 will likely get cancer , 20% (ARI).

(X 3) or 300% more likely to develop lung cancer than those that don’t smoke (RR).

There is a 200% increase in lung cancer cases for smokers compared to those that don’t smoke (RRR). 30

100

10

100

Those that smoke and got cancer

Those that don’t

smoke and got cancer

Group A

Group B

RRI ARI

10% 30% 200% 20%

1% 3% 200% 2%

.1% .3% 200% .2%

There are different ways of describing the same risk which can profoundly affect how we perceive it. Ultimately, when deciding on whether to take a treatment, ideally you should decide with your doctor if the reduction in the ACTUAL (absolute risk) outweighs the risks, side-effects and costs of treatment.

The relationship between RR and RRR

The RRR sounds better for marketing purposes!...

Page 37: Data Analysis (1) Qual Qual
Page 38: Data Analysis (1) Qual Qual

Evaluate difference for each category republican

rural vs suburban rural vs urban suburban vs urban

Independent rural vs suburban rural vs urban suburban vs urban

Democrat rural vs suburban rural vs urban suburban vs urban

Other rural vs suburban rural vs urban suburban vs urban

The chi-squared test shows a relationship exists…but where does the relationship (difference) occur?

(at least one has to change for some relationship to be detected). find where any significant associations may be in the r x c table by calculating adjusted residuals, and by partitioning the table according to the Lancaster-Irwin method.

• Standardized residual method:

• The chi-square test is an overall test to see if there are differences between any of the cell frequencies. If just two of the cells in the design are significantly different, the test will be significant. Only the Republican party showed significant change.

• If you find a SIGNIFICANT

relationship, you need to do a

post-hoc test to discover which

pairs of cells are significantly

different.

The “d” family (amount of difference)

2x2 table Not 2x2 table

Measure of effect size:

• Odds ratio (OR)

Measure of effect size:

• Adjusted standardized residuals

Urban Rural

Split Split

100%

80%

60%

40%

20%

How BIG is the difference?

M F

100%

75%

50%

25%

0

25% Light 43%

Light

25% Dark 14% Dark

50% Regular

43% Regular

The chi-squared test shows a relationship exists…but where does

the relationship (difference) occur?

Rural Rural

Page 39: Data Analysis (1) Qual Qual

Example: Income

Happiness Below Average Above Not much 208 131 49 Moderate 527 835 294 Very 185 454 272

Example: Income

Happiness Below Average Above Not much 208 (23%) 131 (9%) 49 (8%) Moderate 527 (57%) 835 (59%) 294 (48%) Very 185 (20%) 454 (32%) 272 (44%)

• Standardized residuals that have a positive value mean that the cell was over-represented in the actual sample, compared to the expected frequency, i.e. there were more subjects in this category than we expected.

• Standardized residuals that have a negative value mean that the cell was under-represented in the actual sample, compared to the expected frequency, i.e. there were fewer subjects in this category than we expected.

There is a significant difference across gender for WIDOWED only! The residuals can be deceiving,

you must use the standardized residuals.

A statistically significant relationship was found (chi-square test rejected Ho). SPECIFICALLY, there is a statistical difference in male and female responses for those that chose Light beer (look for values that are above +2 or below -2).

20 27

272.3

50 80(1 )(1 )(1 )(1 )

150 150row column

total total

O E

E

n n

n n

Add in statement…3.7 standard deviations…(way to phrase the 3.7 value).

Take out bottom part? Was confusing to explain

but maybe just becuase need statement.

To determine which of the categories are major contributors to the

statistical significance, the adjusted standardized residual is computed for each cell:

The “d” family for not 2x2 tables

2

2

each cell

2 2

2 2

2 2

20 27 40 37

27 37

20 16 30 23

16 23

30 33 10 14

33 14

6.604

statistic

observed Expected

Expected

male female

Light -2.3 3.5

Regular 0.9 -0.9

Dark 1.6 -1.9

adjusted

standardized

Page 40: Data Analysis (1) Qual Qual

There are two contingency table tests:

(1) Two-way table contingency test (also called “test of independence”)

(2) One-way table contingency test (also called “goodness of fit test”)

Page 41: Data Analysis (1) Qual Qual

42

1. Is there a relationship between the variable and a specific distribution?

Visually (Bar Graph) Mathematically (statistical test) 2. What is the effect size?

Page 42: Data Analysis (1) Qual Qual

One-way contingency table test is called a “Goodness of Fit” test

A hypothesis is a belief about the results of a statistical study.

The “Goodness of Fit” tests if the outcomes of a variable

follows a hypothesized distribution (or put another way the

Relationship of variable to a specific distribution).

10

20

5

0

5

10

15

20

25

Democrat Republican Independent

12 12 11

0

5

10

15

20

25

Democrat Republican Independent

20

10

5

0

5

10

15

20

25

Democrat Republican Independent

“The Republican party is significantly larger than any other.”

“There is an equal amount of individuals in each party.”

“The Democrat party is significantly larger than any other.”

Page 43: Data Analysis (1) Qual Qual

44

1. Is there a relationship between the variable and a specific distribution?

Visually (Bar Graph) Mathematically (statistical test) 2. What is the effect size?

Page 44: Data Analysis (1) Qual Qual

Collected Raw

Data must be

organized into a

frequency table.

Seat f

Back 23

Middle 35

Front 29

Total 87

United Airlines compared these actual results to hypothesized results, which is the belief that fatality is the same whether one sits in the front, back, or middle of an airplane.

87/3 = 29

Front is 29 Middle is 29 Back is 29

This is a uniform distribution!

Example Is it safer to fly in the front, middle, or back of the airplane?

Matt McCormick, a survival expert for the National Transportation Safety Board, told Travel Magazine that “There is no one safe place to sit”.

In an effort to test this claim, United Airlines recorded the seat position for 87 fatalities.

Page 45: Data Analysis (1) Qual Qual

1. Form hypothesis.

2. Calculate chi-squared (2) statistic.

3. Find 2 significant in table.

4. Compare 2 statistic to 2 significant.

How to we test this claim?

Ho “null hypothesis”: The data are consistent with a specified distribution.

Ha “alternative hypothesis”: The data are NOT consistent with a specified distribution.

2

2exp

exp

observed ected

ected

2,df

=.05 (default value) df = # outcomes– 1

2 statistic > 2 significant, Reject Ho, Accept Ha.

2 statistic < 2 significant, Fail to Reject Ho.

Page 46: Data Analysis (1) Qual Qual

Step 1: Form Hypothesis

Solution Step 2: Calculate chi-squared (2) statistic

2

2

2 2 2

exp

exp

23 29 35 29 29 29

29 29 29

1.24 1.24 0 2.48

observed ected

ected

Step 3: Find 2 significant

Step 4: Compare 2 statistic

to 2 significant

Outcome f (observed)

Hypothesized distribution “f (expected)”

Back 23 29

Middle 35 29

Front 29 29

Total 87 87

Ho “null hypothesis”: The data are consistent with a specified distribution. There is no one

safe place to sit.

Ha “alternative hypothesis”: The data are NOT consistent with a specified distribution.

There is a safe place to sit.

df = # outcomes– 1 = 3 – 1 = 2 =.05 (default value) 2

,df = 2.05,2 = 5.991

2.48<5.991

2 statistic < 2 significant

Fail to Reject Ho.

There is not enough evidence to refute the claim that there is “no one safe place to sit!”.

Page 47: Data Analysis (1) Qual Qual

Your turn! Goodness of Fit Is Sudden Infant Death Syndrome (SIDS) Seasonal? Data from King County, Washington regarding the number of deaths from SIDS for each season:

Season f

Winter 78

Spring 71

Summer 87

Fall 86

Total 322

Conclusion: Sudden infant death syndrome proportions across seasons are not statistically different from what’s expected by chance (i.e. all seasons being equal).

Step 1: Form Hypothesis

Step 2: Calculate chi-squared (2) statistic

Step 3: Find 2 significant

Step 4: Compare 2

statistic to 2 significant

df = # outcomes– 1 = 4 – 1 = 3 =.05 (default value) 2

,df = 2.05,3 = 7.815

2 statistic (2.10) < 2 significant (7.815)

Fail to Reject Ho.

2 2

2

2 2

78 80.5 71 80.5

80.5 80.5

87 80.5 86 80.5

80.5 80.5

2.10

statistic

Ho “null hypothesis”: Data follows hypothesized distribution (uniform – SIDS deaths for all seasons are the same. Ha “alternative hypothesis”: Data doesn’t follow the hypothesized distribution.

Season fo fe

Winter 78 322/4 =80.5

Spring 71 80.5

Summer 87 80.5

Fall 86 80.5

Total 322 322

Page 48: Data Analysis (1) Qual Qual

CHISQ.TEST Excel function output compares p value to α

p value (.55)

𝝌𝟐statistic (2.10) < 𝝌𝟐significant (7.815) p value (.55) > α (.05) Fail to Reject Ho

Page 49: Data Analysis (1) Qual Qual

Goodness of Fit Test Assumptions

Test Assumptions

Exact Binomial test (we didn’t learn by hand)

2 outcomes Samples up to n=1000

Chi-square test Large sample: E(x)>5

Page 50: Data Analysis (1) Qual Qual

51

1. Is there a relationship between the variable and a specific distribution?

Visually (Bar Graph) Mathematically (statistical test) 2. What is the effect size?

Page 51: Data Analysis (1) Qual Qual

.80-1.00 very strong departure from “fit”

.40-.59 relatively strong

.60-.79 strong

.40-.59 Relatively

strong departure from “fit”

0.00-.09 A perfect fit

.10-.19 small departure from “fit”

The interpretation is different from the test of independence!

.60-.79 Strong

departure from “fit”

.20-.39 Moderate departure from “fit”

Goodness of fit effect size Just like the test of Independence, use Cramer’s V

(more than 2 outcomes) or Phi (2 outcomes). Unlike the test of independence, compute the effect size whether you Reject or Fail to Reject Ho.

A value of .1 is considered a close to perfect fit

.3 a moderate effect

.5 a weak fit.

Page 52: Data Analysis (1) Qual Qual

Goodness of fit effect size

Interpretation: A value of 0 indicates that the sample proportions are exactly equal (a perfect fit) to the hypothesized proportions (i.e., O = E). As v increases, the degree of departure from “a perfect fit” increases. Since V=.05, there is a small effect, or small departure from “fit”

2 2.10.05

322 3V

n df

Cramer’s V

Is Sudden Infant Death Syndrome (SIDS) Seasonal? Data from King County, Washington regarding the number of deaths from SIDS for each season:

Season f

Winter 78

Spring 71

Summer 87

Fall 86

Total 322

2 2

2

2 2

78 80.5 71 80.5

80.5 80.5

87 80.5 86 80.5

80.5 80.5

2.10

statistic

Page 53: Data Analysis (1) Qual Qual

To test if a sample of data came from a population

with a specific distribution is called a GOODNESS-

OF-FIT TEST.

Why are we learning this?

We can use the GOODNESS-OF-FIT TEST to validate the use of a specific distribution for:

SIMULATION

PROBABILITY

Page 54: Data Analysis (1) Qual Qual

Typical steps for a Statistical study

55

Reminder…How this lecture fits in with everything we have learned so far...

1. Define the goals • Research Question

2. Collect the data • Research Designs

3. Organize the data • Tables for each variable (f, %f, cf, %cf )

• Table for 2 qualitative variables (f contingency table, %f

total, %f independent (column) variable)

4. Present the data • Graphs of each variable (pareto pie, bar, ogive, histogram,

boxplot)

• Graphs for 2 qualitative variables (Stacked & Clustered bar

graph)

• Graph for 1 quantitative variable and 1 qualitative variable

(Comparative Boxplot )

5. Describe the data • Statistics and Parameters

6. Analyze the data • Statistical tests (chi-square, Fisher’s Exact)

• Effect size (OR, Adjusted Standardized Residual, Phi, Cramer’s V)

7. Interpret results

Page 55: Data Analysis (1) Qual Qual

Remember If you need help…call me, see me, or email me.

End of the Lecture!