
 
%% Berkeley Admissions
          % a/b < c/d
          % e/f < g/h
          % (a + e)/(b + f ) > (c + g)/(d + h)
          
% Admit,Gender,Dept,Freq
% -------------------------------
% Admitted,Male,A,512
% Rejected,Male,A,313
%     Admitted,Female,A,89
%     Rejected,Female,A,19
% Admitted,Male,B,353
% Rejected,Male,B,207
%     Admitted,Female,B,17
%     Rejected,Female,B,8
% Admitted,Male,C,120
% Rejected,Male,C,205
%     Admitted,Female,C,202
%     Rejected,Female,C,391
% Admitted,Male,D,138
% Rejected,Male,D,279
%     Admitted,Female,D,131
%     Rejected,Female,D,244
% Admitted,Male,E,53
% Rejected,Male,E,138
%     Admitted,Female,E,94
%     Rejected,Female,E,299
% Admitted,Male,F,22
% Rejected,Male,F,351
%     Admitted,Female,F,24
%     Rejected,Female,F,317

cumulberkeley =[1198    2691-1198;  557 1835-557];
[chi2 pval expected  assoc]=tablerxc(cumulberkeley)

% chi2 = 92.2053
% pval =0
% expected = 1.0e+03 *
%     1.0435    1.6475
%     0.7115    1.1235
% assoc =   phi: 0.1427
%       C: 0.1413
%       V: 0.1427

addpath 'C:\STAT1\Two\Twomat'
risk(cumulberkeley)

%        p1: 0.4452
%        p2: 0.3035
%        rd: 0.1416
%     rdint: [0.1134 0.1698]
%        rr: 1.4666
%     rrint: [1.3523 1.5906]
%        or: 1.8411
%     orint: [1.6244 2.0867]


berkeley=...
   [512  313;    89    19; ...
   353   207;    17     8; ...
   120   205;   202   391; ...
   138   279;   131   244; ...
    53   138;    94   299; ...
    22   351;    24   317];

berkeley2 =...
    [512 89; 313 19; ...
     353 17; 207 8;  ...
     120 202; 205 391;  ...
     138 131; 279 244; ...
      53 94; 138 299; ...
      22 24; 351 317];
  
% chi2 =92.2053
% 
% pval =0
% 
% expected =
%     1043.5    1647.5
%       711.5    1123.5
% 
% assoc = 
%     phi: 0.1427
%       C: 0.1413
%       V: 0.1427
% 


[chi2mh  pval]=mantelhaenszel(berkeley)

% chi2mh =1.4269
% pval =0.2323
[chi2mh  pval]=mantelhaenszel(berkeley2)

%chi2mh =1.4269
%pval = 0.2323


