Closed Abonacolta closed 1 year ago
Hi @Abonacolta,
For a categorical variable of 5 levels (A,B,C,D,E
), we are actually estimating 4 contrasts, which are (B-A, C-A, D-A, E-A
), in R.
So for testing the trend of A < B < C < D < E
, it is equivalent to test 0 < B - A < C - A < D - A < E - A
, so we can specify the contrast matrix as follows:
# B-A C-A D-A E-A
1 0 0 0
-1 1 0 0
0 -1 1 0
0 0 -1 1
In R, it should be
matrix(c(1, 0, 0, 0,
-1, 1, 0, 0,
0, -1, 1, 0,
0, 0, -1, 1),
nrow = 4,
byrow = TRUE)
Hope that helps!
Best, Huang
Yes, that's exactly what I needed. Thanks!!
Thank you very much for the detailed tutorial you put together for ANCOMBC2. I have a quick question regarding the trend test with 5 ordered categories (A,B,C,D,E). I would like to test for a monotonically increasing trend from A -> E (i.e. which microbes are increasing in abundance along this trend). I however, do not know how to adjust the contrast matrix to account for these 5 variables.
Also, I'm assuming I will use
node = 4
for this (judging based off the example in the tutorial). Any advice on how to build this?An example of the starting script I'm using is below:
Thank you for any help!