Backward chi square contingency table generation

36 Views Asked by At

Usually you have a contingency table from which you derive a $\chi^2$ Value. I want to reaarange this. I want to have the sums and a p-Value (or $\chi^2$ Value) given and derive from that randomly generated values valid for that contingecy table and that p-Value. Also I called this "backward" chi-square. Maybe this already exists and I just don't know the name of it? If so please let me know the real name of this concept. So to sum it up:

Predefined: bold numbers in contingency table, p-Value

Solve for: italic letters in contingency table

A B $\sum$
X a b 50
Y c d 50
$\sum$ 50 50 100
1

There are 1 best solutions below

1
On BEST ANSWER

Once $a,$ for $a = 0, 1, \dots, 50$ is chosen the rest of your $2\times 2$ table is uniquely defined. (That's roughly what it means to have degrees of freedom $1.)$

So, correspondingly, there are $51$ possible values of the chi-squared statistic $H.$ Of these only $26$ are unique. [So, once you know a legal value of $H,$ you know which of two tables must have been used.] in R, we have:

h = numeric(51)
for(i in 1:51){
 TBL = cbind(c(i-1, 51-i), c(51-i, i-1))
 h[i] = chisq.test(TBL)$stat
 }
h
 [1] 96.04 88.36 81.00 73.96 67.24 60.84 54.76 49.00 43.56
[10] 38.44 33.64 29.16 25.00 21.16 17.64 14.44 11.56  9.00
[19]  6.76  4.84  3.24  1.96  1.00  0.36  0.04  0.00  0.04
[28]  0.36  1.00  1.96  3.24  4.84  6.76  9.00 11.56 14.44
[37] 17.64 21.16 25.00 29.16 33.64 38.44 43.56 49.00 54.76
[46] 60.84 67.24 73.96 81.00 88.36 96.04