Hi all,
I am having problems to compute the chi-square statistics based only on the valid entries (without missing values) using table1_mc from SSC.
The same problem I get with prtest, proportions are calculated with missing values.
You can check that lamentably table1_mc use missing values to Chi2 test.
I am having problems to compute the chi-square statistics based only on the valid entries (without missing values) using table1_mc from SSC.
The same problem I get with prtest, proportions are calculated with missing values.
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float(m1 m2 age female dept offcampus) str11 comment 2 2 18 0 1 0 "" 4 4 20 1 4 0 "Great!" 2 2 18 1 1 0 "" 1 1 19 1 1 1 "I'm leaving" 2 2 18 0 1 0 "" 2 2 . . . 1 "" 2 2 18 1 . 0 "" 3 4 20 1 4 1 "" 4 3 18 1 3 0 "" 2 2 19 0 2 1 "" 2 2 19 1 2 1 "" 2 2 19 1 . 1 "" 2 2 20 0 4 1 "" 4 3 20 0 . 1 "" 2 4 20 1 3 0 "" 3 2 20 0 . 1 "" 2 2 19 0 4 1 "" 2 2 18 1 1 0 "" 2 2 18 0 1 0 "" 4 4 18 0 2 0 "" 4 4 20 0 4 0 "" 2 2 18 0 1 0 "" 3 3 19 0 1 0 "" 2 1 18 1 1 0 "" 2 2 . . . 0 "" 1 2 18 0 1 0 "" 2 2 18 0 4 0 "" 4 4 21 0 4 0 "" 2 2 19 1 1 0 "" 2 2 20 0 1 0 "" 4 4 20 1 4 0 "" 2 2 18 0 1 1 "" 2 2 19 1 4 1 "" 2 2 18 0 3 1 "" 2 2 19 0 2 1 "" 2 2 19 1 1 0 "" 4 2 19 1 1 0 "" 2 2 19 0 3 1 "" 4 4 19 1 4 0 "" 2 2 19 1 4 1 "" 2 2 18 1 2 0 "" 2 2 19 1 3 1 "" 2 2 19 0 4 1 "" 3 3 19 1 3 0 "" 2 2 18 0 . 0 "" 2 4 19 0 3 0 "" 2 2 20 1 3 0 "" 2 2 19 1 4 1 "" 1 2 19 0 1 1 "" 2 2 20 0 1 0 "" 2 2 18 1 1 0 "" 2 2 19 0 . 0 "" 2 2 18 0 3 1 "" 2 2 19 0 1 1 "" 2 3 19 1 1 0 "" 2 2 19 1 2 0 "" 2 2 18 1 4 0 "" 2 3 20 1 2 0 "" 2 2 19 0 4 1 "" 2 2 17 1 1 0 "" 2 2 . . . 0 "" 2 2 19 1 1 0 "" 2 2 19 1 1 1 "" 4 4 20 0 4 1 "" 2 2 18 1 3 0 "" 3 2 18 0 3 0 "" 2 2 19 1 2 1 "" 2 2 17 0 3 0 "" 2 2 19 1 3 0 "" 2 2 19 0 3 0 "" 2 3 20 0 4 0 "" 2 2 20 1 3 1 "" 2 2 18 0 1 0 "" 4 2 19 0 1 0 "" 4 2 20 0 4 0 "" 2 2 18 1 2 1 "" 2 2 20 1 4 1 "" 2 2 18 0 1 1 "" 2 2 19 1 2 0 "" 2 2 19 0 1 1 "" 2 2 19 0 3 1 "" 2 2 19 1 1 1 "" 2 2 19 0 1 1 "" 2 3 21 0 3 1 "" 4 4 19 1 4 0 "" 2 1 17 0 1 1 "" 3 3 19 1 4 0 "" 4 4 19 1 1 0 "" 2 2 20 0 4 1 "" 2 2 19 1 2 0 "" 4 3 18 1 4 0 "" 4 3 20 0 2 0 "" 3 2 18 1 3 0 "" 2 3 18 1 4 0 "" 2 2 19 0 1 0 "" 3 3 18 0 4 0 "" 3 4 20 1 2 0 "" 2 2 19 0 2 1 "" 4 4 19 1 4 0 "" 2 3 20 1 2 0 "" end tab female dept, chi2 | dept female | 1 2 3 4 | Total -----------+--------------------------------------------+---------- 0 | 18 5 9 12 | 44 1 | 14 10 9 14 | 47 -----------+--------------------------------------------+---------- Total | 32 15 18 26 | 91 Pearson chi2(3) = 2.2240 Pr = 0.527 tab female dept, miss chi2 | dept female | 1 2 3 4 . | Total -----------+-------------------------------------------------------+---------- 0 | 18 5 9 12 4 | 48 1 | 14 10 9 14 2 | 49 . | 0 0 0 0 3 | 3 -----------+-------------------------------------------------------+---------- Total | 32 15 18 26 9 | 100 Pearson chi2(8) = 34.0972 Pr = 0.000 table1_mc, by(female) miss onecol vars(dept cat) extraspace statistic test clear +--------------------------------+ | factor N_0 N_1 m_0 m_1 | |--------------------------------| | dept 48 49 0 0 | +--------------------------------+ N_ ... #records used below, m_ ... #records not used +------------------------------------------------------------------------------+ | female = 0 female = 1 Test Statistic p-value | |------------------------------------------------------------------------------| | N=48 N=49 | |------------------------------------------------------------------------------| | dept Chi-square Chi2(4)= 2.98 0.56 | | 1 18 (38%) 14 (29%) | | 2 5 (10%) 10 (20%) | | 3 9 (19%) 9 (18%) | | 4 12 (25%) 14 (29%) | | Missing 4 ( 8%) 2 ( 4%) | +------------------------------------------------------------------------------+ Data are presented as n (%).
Comment