[Data] GenderParty: X = Gender (Female/Male) and Y = Party (Democrat/Independent/Republican).
[Data] AfterLife : X = Gender (Female/Male) and Y = Belief (Yes/No).
[Specification]
The expected
provides expected cell counts under the assumption of independence
The deviation
provides the difference of cell count and expected cell counts.
The chisq
conducts the Chi-squared test of independence.
The cellchi2
provides the square of Pearson Residuals. Summeration of these values equals the \(X^2\) test statistic.
[GenderParty - Code and Output]
data GenderParty;
input Gender $ Party $ Count;
datalines;
Female Democrat 762
Female Independent 327
Female Republican 468
Male Democrat 484
Male Independent 239
Male Republican 477
;
proc freq order=data data=GenderParty;
weight Count;
tables Gender*Party/expected deviation chisq cellchi2;
run;
The FREQ Procedure
Table of Gender by Party
Gender Party
Frequency |
Expected |
Deviation |
Cell Chi-Square|
Percent |
Row Pct |
Col Pct |Democrat|Independ|Republic| Total
---------------+--------+--------+--------+
Female | 762 | 327 | 468 | 1557
| 703.67 | 319.65 | 533.68 |
| 58.329 | 7.3547 | -65.68 |
| 4.835 | 0.1692 | 8.084 |
| 27.64 | 11.86 | 16.97 | 56.47
| 48.94 | 21.00 | 30.06 |
| 61.16 | 57.77 | 49.52 |
---------------+--------+--------+--------+
Male | 484 | 239 | 477 | 1200
| 542.33 | 246.35 | 411.32 |
| -58.33 | -7.355 | 65.683 |
| 6.2734 | 0.2196 | 10.489 |
| 17.56 | 8.67 | 17.30 | 43.53
| 40.33 | 19.92 | 39.75 |
| 38.84 | 42.23 | 50.48 |
---------------+--------+--------+--------+
Total 1246 566 945 2757
45.19 20.53 34.28 100.00
Statistics for Table of Gender by Party
Statistic DF Value Prob
------------------------------------------------------
Chi-Square 2 30.0701 <.0001
Likelihood Ratio Chi-Square 2 30.0167 <.0001
Mantel-Haenszel Chi-Square 1 28.9797 <.0001
Phi Coefficient 0.1044
Contingency Coefficient 0.1039
Cramer's V 0.1044
Sample Size = 2757
[AfterLife - Code and Output]
data Afterlife;
input Gender $ Belief $ Count;
datalines;
Female Yes 509
Female No 116
Male Yes 398
Male No 104
;
proc freq order=data data=Afterlife;
weight Count;
tables Gender*Belief/expected deviation chisq cellchi2;
run;
The FREQ Procedure
Table of Gender by Belief
Gender Belief
Frequency |
Expected |
Deviation |
Cell Chi-Square|
Percent |
Row Pct |
Col Pct |Yes |No | Total
---------------+--------+--------+
Female | 509 | 116 | 625
| 502.99 | 122.01 |
| 6.0053 | -6.005 |
| 0.0717 | 0.2956 |
| 45.16 | 10.29 | 55.46
| 81.44 | 18.56 |
| 56.12 | 52.73 |
---------------+--------+--------+
Male | 398 | 104 | 502
| 404.01 | 97.995 |
| -6.005 | 6.0053 |
| 0.0893 | 0.368 |
| 35.31 | 9.23 | 44.54
| 79.28 | 20.72 |
| 43.88 | 47.27 |
---------------+--------+--------+
Total 907 220 1127
80.48 19.52 100.00
Statistics for Table of Gender by Belief
Statistic DF Value Prob
------------------------------------------------------
Chi-Square 1 0.8246 0.3638
Likelihood Ratio Chi-Square 1 0.8224 0.3645
Continuity Adj. Chi-Square 1 0.6930 0.4052
Mantel-Haenszel Chi-Square 1 0.8238 0.3641
Phi Coefficient 0.0270
Contingency Coefficient 0.0270
Cramer's V 0.0270
Fisher's Exact Test
----------------------------------
Cell (1,1) Frequency (F) 509
Left-sided Pr <= F 0.8374
Right-sided Pr >= F 0.2024
Table Probability (P) 0.0398
Two-sided Pr <= P 0.3655
Sample Size = 1127