1
$\begingroup$

I have the following issue: Lets say I have a 2x2 contingency table of left and right handed men and women and the outer sums (marginal distribution)

$$ \begin{matrix} & Left & Rigth & \\ Men & a & b & M = a+b\\ Women & c &d & W = 1-M = c+d\\ & L = a+c & R = 1-L = b+d & 1 \end{matrix} $$

I have the full table once (say for one classroom). And a bunch of Row and Column sums for say the other classes in the school.

Now if handedness and gender are independent I can easily construct a to d with just the row and columns sums.

Is some kind of information or measure of dependence i can gather from the one full matrix (that I have for one classroom) and use that information to construct a to d (joint distribution) using just the outer sums (marginal) from the other classrooms. Under the assumption that whatever piece of information I extracted is the same?

Just to showcase what I am looking for (if it even exists): My first thought was to use the determinant, but this does not restrict the cells between 0 and 1.

$$ det = ad - bc = a (1-L-M+a) - [(M-a)(L-a)] =\\ a(1-L-M+a) - [ML -Ma -La +a^2] = a -La-Ma +a^2 - ML +Ma +La -a^2 = \\ det =a - ML $$ So given the determinant, L and M I can calculate a and therefore all the others as well. And two tables with different row and column sums but the same determinant are in some way "similar".

I found some other questions that mention "copula", but I am not sure if and how I can apply this here (Constructing a joint distribution from pairwise bivariate marginal distributions?).

Thank you in advance, and sorry for my lackluster terminology.

$\endgroup$

1 Answer 1

1
$\begingroup$

Even if handedness and gender are independent, each classroom will have random variation, so you should not try to use data from one classroom to analyze or interpret data from another.

The letters $a,b,c,$ and $d$ in your Question refer to observed counts, not to expected counts. They are used as you have shown to find the marginal totals. Under the assumption that the two categorical variables are independent, marginal totals can be used to find the expected counts (which need not be integers).

Here is the rationale, illustrated in terms of an example. Suppose we have the following observed counts, along with marginal totals:

       L     T    Tot
M      6    54     60
W      7    43     50
Tot   13    97    110

From the table we estimate the probability of M as $\hat P(M) = 60/110 = 0.5455.$ and we estimate the probability of L as $\hat P(L) = 13/110 = 0.1182.$ Then, using independence, we have $\hat P(M \cap L) = 0.5455(0.1182) = 0.0645.$ And then the expected count for Left-handed Men is $\hat E(M\cap L) = 0.0645(110) = 7.091.$

If you put it together, that amounts to $\hat E(M\cap L)= \frac{60(13)}{110} = 7.091.$ One says that the expected count for a cell of the table is its "Row total times Column total divided by Grand total."

The remaining three expected counts are found in the same way.

In R, a chi-squared test for my illustrative data looks like this:

OBS = matrix(c(6,54,7,43), nrow=2, byrow=T)
mwlr.out = chisq.test(OBS)
mwlr.out

        Pearson's Chi-squared test 
        with Yates' continuity correction

data:  OBS
X-squared = 0.12285, df = 1, p-value = 0.726

The P-value exceeds 0.05, so my observed counts do not show evidence that the two categorical variables are associated (non-independent). We can retrieve the observed and expected counts as follows:

mwlr.out$obs
     [,1] [,2]
[1,]    6   54
[2,]    7   43
mwlr.out$exp
         [,1]     [,2]
[1,] 7.090909 52.90909
[2,] 5.909091 44.09091

If the four observed counts are denoted as $X_{ij}$ and the expected counts as $E_{ij}.$ for $i = 1,2; j = 1,2,$ then the chi-squared statistic is

$$Q = \sum_{i,j} \frac{(X_{ij}-E_{ij})^2}{E_{ij}},$$

which has approximately a chi-squared distribution with one degree of freedom, provided that all $E_{ij} \ge 5.$

Note: The default chi-squared test in R used the Yates' continuity correction, not shown in the formula above. There is not universal agreement that using this correction is a good idea. If you want the value $Q$ shown above, then use the argument cor=F in chisq.test.

$\endgroup$
2
  • $\begingroup$ Thanks for cleaning it up a bit. So, how would this change if I had multiple observations? Say, I use the whole school to try to estimate a second one? Testing whether we have independence I figured out, but what do I do if I do have dependence? $\endgroup$ Commented Aug 20, 2019 at 7:08
  • $\begingroup$ If you feel comfortable treating the whole school as a large random sample of the population of interest, you could use counts from the whole school for a chi-squared test. If there is a gender effect on handedness, you would have a more powerful test to detect that. For example, using unlikely data, chisq.test(matrix(c(60,540,80,430), nrow=2, byrow=T))$p.val would return P-value 0.0059. Then you'd be using one school to see what is going on in the whole population of students that age. Whether the 2nd school is typical of the population is a separate matter. $\endgroup$
    – BruceET
    Commented Aug 20, 2019 at 18:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.