View the data

structable(~gender + right + left, data=VisualAcuity)
##             right    1    2    3    4
## gender left                          
## male   1           821  116   72   43
##        2           112  494  151   34
##        3            85  145  583  106
##        4            35   27   87  331
## female 1          1520  234  117   36
##        2           266 1512  362   82
##        3           124  432 1772  179
##        4            66   78  205  492

Select and process women

women <- subset(VisualAcuity, gender=="female", select=-gender)
structable(~right + left, data=women)
##       left    1    2    3    4
## right                         
## 1          1520  266  124   66
## 2           234 1512  432   78
## 3           117  362 1772  205
## 4            36   82  179  492
sieve(Freq ~ right + left,  data = women, 
      gp=shading_Friendly, labeling=labeling_values,
      main="Vision data: Women")

Select and process men

men <- subset(VisualAcuity, gender=="male", select=-gender)
structable(~right + left, data=men)
##       left   1   2   3   4
## right                     
## 1          821 112  85  35
## 2          116 494 145  27
## 3           72 151 583  87
## 4           43  34 106 331
sieve(Freq ~ right + left,  data = men, 
      gp=shading_Friendly, labeling=labeling_values,
      main="Vision data: Men")

plot both together

cotabplot(Freq ~ right + left | gender, data=VisualAcuity, 
          panel=cotab_sieve, gp=shading_Friendly)

Some statistical tests for association

chisq.test(xtabs(Freq ~ left + right, data=women))
## 
##  Pearson's Chi-squared test
## 
## data:  xtabs(Freq ~ left + right, data = women)
## X-squared = 8097, df = 9, p-value <2e-16
chisq.test(xtabs(Freq ~ left + right, data=men))
## 
##  Pearson's Chi-squared test
## 
## data:  xtabs(Freq ~ left + right, data = men)
## X-squared = 3304, df = 9, p-value <2e-16

mutual independence of gender, right, left

MASS::loglm(Freq ~ gender + right + left, data=VisualAcuity)
## Call:
## MASS::loglm(formula = Freq ~ gender + right + left, data = VisualAcuity)
## 
## Statistics:
##                    X^2 df P(> X^2)
## Likelihood Ratio  9686 24        0
## Pearson          11913 24        0
IycgLS0tDQojJyB0aXRsZTogIlZpc3VhbEFjdWl0eSBkYXRhOiBzaWV2ZSBkaWFncmFtcyINCiMnIGF1dGhvcjogIk1pY2hhZWwgRnJpZW5kbHkiDQojJyBkYXRlOiAiYHIgZm9ybWF0KFN5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