0
$\begingroup$

I have a dataframe such as :

enter image description here

In that dataframe I have 4 groups (G1,G2,G3 & G4), and within each group I have 3 modalities (A,B & C).

As you can see these are proportion values, for instance I observed 10% (of whatever the value means) in G1-A, and I expected to indeed see 10% here.

  • The question :

Here I wanted to do a test in order to point out with statistics the fact that only modalities B and C within the G1 group show over-representation and under-representation respectively. The other modalities in the other groups showing no significant differences compared to expected proportions.

So I first thought to do a chi2 test here, but I was not really sure if we can use it on proportions and how could I do it in such data (since here it is a kind of hierarchical data).

Reproductibility :

Here is the dput formated data if it can helps:

    Groups Modalities Observed Expected Observed. Expected.
1      G1          A    200.0      200        10        10
2      G1          B   1000.0        0        50        20
3      G1          C    800.0     1400        40        70
4      G2          A     14.0       20         7        10
5      G2          B     48.0       40        24        20
6      G2          C    138.0      140        69        70
7      G2          A     40.0       40        10        10
8      G3          B     88.0       80        22        20
9      G3          C    272.0      280        68        70
10     G4          A      2.4        3         8        10
11     G4          B      5.7        6        19        20
12     G4          C     21.9       21        73        70

    structure(list(Groups = c("G1", "G1", "G1", "G2", "G2", "G2", 
"G2", "G3", "G3", "G4", "G4", "G4"), Modalities = c("A", "B", 
"C", "A", "B", "C", "A", "B", "C", "A", "B", "C"), Observed = c(200, 
1000, 800, 14, 48, 138, 40, 88, 272, 2.4, 5.7, 21.9), Expected = c(200L, 
0L, 1400L, 20L, 40L, 140L, 40L, 80L, 280L, 3L, 6L, 21L), Observed. = c(10L, 
50L, 40L, 7L, 24L, 69L, 10L, 22L, 68L, 8L, 19L, 73L), Expected. = c(10L, 
20L, 70L, 10L, 20L, 70L, 10L, 20L, 70L, 10L, 20L, 70L)), class = "data.frame", row.names = c(NA, 
-12L))
$\endgroup$
6
  • $\begingroup$ call G1 A by G1A , G2 A by G2A and so on, then test they all $\endgroup$ Oct 13 at 8:48
  • $\begingroup$ Do you known a r function for that ? $\endgroup$ Oct 13 at 8:55
  • 1
    $\begingroup$ You (usually) can't test the percentages without the totals. How do these expected values arise? $\endgroup$
    – Glen_b
    Oct 13 at 9:43
  • $\begingroup$ I edited the post by adding the observed and the expected values $\endgroup$ Oct 13 at 10:04
  • 1
    $\begingroup$ G4 seems to have fractional observed events $\endgroup$
    – Henry
    Oct 13 at 12:21