WF ED 540, CLASS MEETING 6, Contingency Tables, 2016
-
Upload
penn-state-university -
Category
Education
-
view
122 -
download
0
Transcript of WF ED 540, CLASS MEETING 6, Contingency Tables, 2016
![Page 1: WF ED 540, CLASS MEETING 6, Contingency Tables, 2016](https://reader033.fdocuments.in/reader033/viewer/2022051122/589c07041a28ab4f598b602d/html5/thumbnails/1.jpg)
Contingency TablesDATA ANALYSIS27 SEPTEMBER 2016
![Page 2: WF ED 540, CLASS MEETING 6, Contingency Tables, 2016](https://reader033.fdocuments.in/reader033/viewer/2022051122/589c07041a28ab4f598b602d/html5/thumbnails/2.jpg)
A refresher:Hypothesis testingTHEORY, PROPOSITIONS, LOGIC
![Page 3: WF ED 540, CLASS MEETING 6, Contingency Tables, 2016](https://reader033.fdocuments.in/reader033/viewer/2022051122/589c07041a28ab4f598b602d/html5/thumbnails/3.jpg)
Language of hypothesis testing… Hypotheses are“tested”
Hypotheses are never“proved”
Hypotheses only are“rejected”
Theories are built and verified by testing hypotheses
![Page 4: WF ED 540, CLASS MEETING 6, Contingency Tables, 2016](https://reader033.fdocuments.in/reader033/viewer/2022051122/589c07041a28ab4f598b602d/html5/thumbnails/4.jpg)
Decision-by-truth tableTruth
Ho true Ho falseD
ecis
ion Fail to
reject Ho
Reject Ho
![Page 5: WF ED 540, CLASS MEETING 6, Contingency Tables, 2016](https://reader033.fdocuments.in/reader033/viewer/2022051122/589c07041a28ab4f598b602d/html5/thumbnails/5.jpg)
Decision-by-truth table
Error
Error
TruthHo true Ho false
Dec
isio
n Fail to reject Ho
Reject Ho
![Page 6: WF ED 540, CLASS MEETING 6, Contingency Tables, 2016](https://reader033.fdocuments.in/reader033/viewer/2022051122/589c07041a28ab4f598b602d/html5/thumbnails/6.jpg)
Decision-by-truth table
Type 1error
Type 2error
TruthHo true Ho false
Dec
isio
n Fail to reject Ho
Reject Ho
![Page 7: WF ED 540, CLASS MEETING 6, Contingency Tables, 2016](https://reader033.fdocuments.in/reader033/viewer/2022051122/589c07041a28ab4f598b602d/html5/thumbnails/7.jpg)
Decision-by-truth table
TRADITIONALLY, probability of Type 1
error set at .05
Minimize Type 2error by
increasing sample size
TruthHo true Ho false
Dec
isio
n Fail to reject Ho
Reject Ho
![Page 8: WF ED 540, CLASS MEETING 6, Contingency Tables, 2016](https://reader033.fdocuments.in/reader033/viewer/2022051122/589c07041a28ab4f598b602d/html5/thumbnails/8.jpg)
Contingency tablesAlso known as CROSSTABULATIONS
![Page 9: WF ED 540, CLASS MEETING 6, Contingency Tables, 2016](https://reader033.fdocuments.in/reader033/viewer/2022051122/589c07041a28ab4f598b602d/html5/thumbnails/9.jpg)
What is a contingency table?A contingency table is a table of counts.A two-dimensional contingency table is
formed by classifying subjects by two variables.
One variable identifies the row categories; the other variable defines the column categories.
The combinations of row and column categories are called cells.
![Page 10: WF ED 540, CLASS MEETING 6, Contingency Tables, 2016](https://reader033.fdocuments.in/reader033/viewer/2022051122/589c07041a28ab4f598b602d/html5/thumbnails/10.jpg)
Structure of rows-by-column contingency table…
R1; C1 R1; C2
R2; C1 R2; C2
Column 1 Column 2Ro
w 1
Row
2
R1tot
R2tot
C1 tot C2 tot Total
![Page 11: WF ED 540, CLASS MEETING 6, Contingency Tables, 2016](https://reader033.fdocuments.in/reader033/viewer/2022051122/589c07041a28ab4f598b602d/html5/thumbnails/11.jpg)
Data from NLSY79
![Page 12: WF ED 540, CLASS MEETING 6, Contingency Tables, 2016](https://reader033.fdocuments.in/reader033/viewer/2022051122/589c07041a28ab4f598b602d/html5/thumbnails/12.jpg)
Example of contingency table…
R1; C1 R1; C2
R2; C1 R2; C2
Male FemaleRo
w 1
Row
2
R1total
R2total
C1 total C2 total Total
![Page 13: WF ED 540, CLASS MEETING 6, Contingency Tables, 2016](https://reader033.fdocuments.in/reader033/viewer/2022051122/589c07041a28ab4f598b602d/html5/thumbnails/13.jpg)
Example of contingency table…
R1; C1 R1; C2
R2; C1 R2; C2
Male Female
2005
Hou
seho
ldNo
t in
Pove
rty20
05 H
ouse
hold
In
Pov
erty
R1total
R2total
C1 total C2 total Total
![Page 14: WF ED 540, CLASS MEETING 6, Contingency Tables, 2016](https://reader033.fdocuments.in/reader033/viewer/2022051122/589c07041a28ab4f598b602d/html5/thumbnails/14.jpg)
Example of contingency table…
Males not in poverty
Females not in poverty
Males in poverty Females in poverty
Male Female
R1total
R2total
C1 total C2 total Total
2005
Hou
seho
ldNo
t in
Pove
rty20
05 H
ouse
hold
In
Pov
erty
![Page 15: WF ED 540, CLASS MEETING 6, Contingency Tables, 2016](https://reader033.fdocuments.in/reader033/viewer/2022051122/589c07041a28ab4f598b602d/html5/thumbnails/15.jpg)
Example of contingency table…
Males not in poverty
Females not in poverty
Males in poverty Females in poverty
Male Female
Nopovtotal
Pov total
Male total Female total Total
2005
Hou
seho
ldNo
t in
Pove
rty20
05 H
ouse
hold
In
Pov
erty
![Page 16: WF ED 540, CLASS MEETING 6, Contingency Tables, 2016](https://reader033.fdocuments.in/reader033/viewer/2022051122/589c07041a28ab4f598b602d/html5/thumbnails/16.jpg)
Example of contingency table…
Males not in poverty
Females not in poverty
Males in poverty Females in poverty
Male Female
Nopovtotal
Pov total
Male total Female total Total
2005
Hou
seho
ldNo
t in
Pove
rty20
05 H
ouse
hold
In
Pov
erty
Marginals =>
<=
Mar
gina
ls
![Page 17: WF ED 540, CLASS MEETING 6, Contingency Tables, 2016](https://reader033.fdocuments.in/reader033/viewer/2022051122/589c07041a28ab4f598b602d/html5/thumbnails/17.jpg)
R analysis for cell countsR script:
Console output:
![Page 18: WF ED 540, CLASS MEETING 6, Contingency Tables, 2016](https://reader033.fdocuments.in/reader033/viewer/2022051122/589c07041a28ab4f598b602d/html5/thumbnails/18.jpg)
Example of contingency table…
3,086 3,039
443 623
Male Female
Male total Female total Total
2005
Hou
seho
ldNo
t in
Pove
rty20
05 H
ouse
hold
In
Pov
erty
Nopovtotal
Pov total
![Page 19: WF ED 540, CLASS MEETING 6, Contingency Tables, 2016](https://reader033.fdocuments.in/reader033/viewer/2022051122/589c07041a28ab4f598b602d/html5/thumbnails/19.jpg)
R analysis for marginal counts
R script:
Console output:
![Page 20: WF ED 540, CLASS MEETING 6, Contingency Tables, 2016](https://reader033.fdocuments.in/reader033/viewer/2022051122/589c07041a28ab4f598b602d/html5/thumbnails/20.jpg)
Example of contingency table…
3,086 3,039
443 623
Male Female
3,529 3,662 7,191
2005
Hou
seho
ldNo
t in
Pove
rty20
05 H
ouse
hold
In
Pov
erty
6,125
1,066
![Page 21: WF ED 540, CLASS MEETING 6, Contingency Tables, 2016](https://reader033.fdocuments.in/reader033/viewer/2022051122/589c07041a28ab4f598b602d/html5/thumbnails/21.jpg)
Research question
3,086 3,039
443 623
Male Female
3,529 3,662 7,191
2005
Hou
seho
ldNo
t in
Pove
rty20
05 H
ouse
hold
In
Pov
erty
6,125
1,066
Is gender independent of household poverty status?
![Page 22: WF ED 540, CLASS MEETING 6, Contingency Tables, 2016](https://reader033.fdocuments.in/reader033/viewer/2022051122/589c07041a28ab4f598b602d/html5/thumbnails/22.jpg)
Research question
3,086 3,039
443 623
Male Female
3,529 3,662 7,191
2005
Hou
seho
ldNo
t in
Pove
rty20
05 H
ouse
hold
In
Pov
erty
6,125
1,066
If you know a person’s gender, can you predict poverty status?
![Page 23: WF ED 540, CLASS MEETING 6, Contingency Tables, 2016](https://reader033.fdocuments.in/reader033/viewer/2022051122/589c07041a28ab4f598b602d/html5/thumbnails/23.jpg)
Research question
3,086 3,039
443 623
Male Female
3,529 3,662 7,191
2005
Hou
seho
ldNo
t in
Pove
rty20
05 H
ouse
hold
In
Pov
erty
6,125
1,066
If you know a person’s poverty status, can you predict gender?
![Page 24: WF ED 540, CLASS MEETING 6, Contingency Tables, 2016](https://reader033.fdocuments.in/reader033/viewer/2022051122/589c07041a28ab4f598b602d/html5/thumbnails/24.jpg)
Under the null hypothesis…
3,086 3,039
443 623
Male Female
3,529 3,662 7,191
2005
Hou
seho
ldNo
t in
Pove
rty20
05 H
ouse
hold
In
Pov
erty
6,125
1,066
A cell value should be equal to (row total x column total) ÷ total
![Page 25: WF ED 540, CLASS MEETING 6, Contingency Tables, 2016](https://reader033.fdocuments.in/reader033/viewer/2022051122/589c07041a28ab4f598b602d/html5/thumbnails/25.jpg)
Under the null hypothesis…
3,086Expected value
is 30063,039
443 623
Male Female
3,529 3,662 7,191
2005
Hou
seho
ldNo
t in
Pove
rty20
05 H
ouse
hold
In
Pov
erty
6,125
1,066
E.g., (6125 x 3529) ÷ 7191 should be equal to 3086, but is 3006
![Page 26: WF ED 540, CLASS MEETING 6, Contingency Tables, 2016](https://reader033.fdocuments.in/reader033/viewer/2022051122/589c07041a28ab4f598b602d/html5/thumbnails/26.jpg)
Under the null hypothesis…
3,086Expected value
is 30063,039
443 623
Male Female
3,529 3,662 7,191
2005
Hou
seho
ldNo
t in
Pove
rty20
05 H
ouse
hold
In
Pov
erty
6,125
1,066
An expected cell count is a hypothetical count that would occur if there is no relationship between the two variables
![Page 27: WF ED 540, CLASS MEETING 6, Contingency Tables, 2016](https://reader033.fdocuments.in/reader033/viewer/2022051122/589c07041a28ab4f598b602d/html5/thumbnails/27.jpg)
test of independence
3,086Expected value
is 30063,039
443 623
Male Female
3,529 3,662 7,191
2005
Hou
seho
ldNo
t in
Pove
rty20
05 H
ouse
hold
In
Pov
erty
6,125
1,066
A value is the sum of the squared deviations of observed minus expected divided by the expected value
![Page 28: WF ED 540, CLASS MEETING 6, Contingency Tables, 2016](https://reader033.fdocuments.in/reader033/viewer/2022051122/589c07041a28ab4f598b602d/html5/thumbnails/28.jpg)
test of independence
3,086Expected value
is 30063,039
443 623
Male Female
3,529 3,662 7,191
2005
Hou
seho
ldNo
t in
Pove
rty20
05 H
ouse
hold
In
Pov
erty
6,125
1,066
A value is the sum of the squared deviations of observed minus expected divided by the expected value
![Page 29: WF ED 540, CLASS MEETING 6, Contingency Tables, 2016](https://reader033.fdocuments.in/reader033/viewer/2022051122/589c07041a28ab4f598b602d/html5/thumbnails/29.jpg)
Hypothesis tested about …Null hypothesis is H0: R x C = 0
Alternate hypothesis is H1: R x C ≠ 0
a = .05 Described as a test of independence
![Page 30: WF ED 540, CLASS MEETING 6, Contingency Tables, 2016](https://reader033.fdocuments.in/reader033/viewer/2022051122/589c07041a28ab4f598b602d/html5/thumbnails/30.jpg)
Calculating in R….it’s simple
Console output:
R script:
![Page 31: WF ED 540, CLASS MEETING 6, Contingency Tables, 2016](https://reader033.fdocuments.in/reader033/viewer/2022051122/589c07041a28ab4f598b602d/html5/thumbnails/31.jpg)
Calculating in R….it’s simple
Console output:
R script:
Degrees of freedom (df) = (# rows – 1)(# columns – 1)
![Page 32: WF ED 540, CLASS MEETING 6, Contingency Tables, 2016](https://reader033.fdocuments.in/reader033/viewer/2022051122/589c07041a28ab4f598b602d/html5/thumbnails/32.jpg)
Calculating in R….it’s simple
Console output:
R script:
p-value < .05, so reject null
![Page 33: WF ED 540, CLASS MEETING 6, Contingency Tables, 2016](https://reader033.fdocuments.in/reader033/viewer/2022051122/589c07041a28ab4f598b602d/html5/thumbnails/33.jpg)
test of independence
A test of the hypothesis that rows and columns in a table are independent
In our case, a test of the independence of gender and poverty status reveals• Household poverty status and gender
are not independent• Knowing household poverty status helps
predict gender
![Page 34: WF ED 540, CLASS MEETING 6, Contingency Tables, 2016](https://reader033.fdocuments.in/reader033/viewer/2022051122/589c07041a28ab4f598b602d/html5/thumbnails/34.jpg)
test of independence
A test of the hypothesis that rows and columns in a table are independent
In our case, a test of the independence of gender and poverty status reveals• Household poverty status and gender
are not independent• Knowing household poverty status helps
predict gender
But how much?
![Page 35: WF ED 540, CLASS MEETING 6, Contingency Tables, 2016](https://reader033.fdocuments.in/reader033/viewer/2022051122/589c07041a28ab4f598b602d/html5/thumbnails/35.jpg)
Contingency TablesDATA ANALYSIS27 SEPTEMBER 2016