Clarifying Contrast and Alternative calls on NBS()

30 views
Skip to first unread message

Justin Tanner

unread,
Jul 23, 2024, 11:36:09 AM7/23/24
to brainGraph-help
Chris,

I could use some help understanding the T.mat and p.mat structures in terms of "alternative" hypothesis and contrasts.

I am looking to compare two cohorts and adjust for age and sex. My contrast matrix is

con.mat <- cbind(0, 0, 0, c(-1, 1))
rownames(con.mat) <- c('HC > PA', 'PA  > HC')


I want to find
  1. what edges are different between PA and HC
  2. what edges are stronger in PA than HC
  3. what edges are weaker in PA than HC
So my questions are:
  1. Would it be best to alter the contrast which sets direction of comparison or alter the "alternative" call?
  2. Can I call "greater" or "less" with the same contrast matrix?
    1. this works for "greater" but "less" causes an error
      1. Error in factor(contrast, labels = tmp$con.name) : invalid 'labels'; length 2 should be 1 or 0
  3. The "two.sided" T.mat structure is NxNx2  and is just a sign difference (T.mat[,,1]=-T.mat[,,2]). This suggests it would be easy to threshold at T[,,1]>=2 or T[,,2]<=-2 and for edge indices that are "different" between the two groups, correct?
    1. In "greater", T.mat[,,1] is not equal to =T.mat[,,2].
      1. For "Greater", is T.mat[,,1] giving the t-test statistics for edges where PA>HC, and T.mat[,,2] giving the t-test statistics for edges where HC>PA?
      2. Would this be flipped for "less" (if it was not producing an error?)
Thank you for any help,

Justin Tanner

unread,
Jul 31, 2024, 6:49:06 PM7/31/24
to brainGraph-help
Following up on this.

I have read the links on contrast coding attempting to apply it to NBS() to find edges that are (1) different (2) stronger in impaired or (3) stronger in unimpaired. I have shifted from using "effects" to "dummy" for simplicity. Also, if I use "dummy" I sometimes get the error " Error in factor(contrast, labels = tmp$con.name) : invalid 'labels'; length 2 should be 1 or 0 " for some comparisons depending on "alternative" choice. I  think this is happening when one dimension of the contrast does not have significant results. I am unsure but based on using the dummy coding, it seems to align.

My covar table looks like
data_i_table 
Study.ID    Age      Sex    Impairment 
<num>    <num>  <fctr>       <fctr>

Relevant Code
con.mat<-cbind(0,0,0,1)
rownames(con.mat) <- c('Impaired vs Unimpaired')
X_spec <- brainGraph_GLM_design(data_i_table, coding='dummy',binarize=c('Sex'))
res.nbs.two <- NBS(A=cm_Use, covars=data_i_table, contrasts=con.mat,con.type="t", X=X_spec,p.init=0.001, N=5000, alternative="two.sided")

For the most part, I think this is working but there are some checks that didnt make sense.
e.g. For a "two.sided" comparison here, shouldn't contrast of [0 0 0 1] and [0 0 0 -1] be the same? If not, what is the difference here, because NBS() returns different results? It should basically mean either u1-u2!=0 or u2-u1!=0
e.g. Shouldnt a [0 0 0 1] of a "greater" comparison be the same as a [ 0 0 0 -1] of a "less" comparison?  Similarly, u1-u2>0 should convert to u2-u1<0?

Thank you,
Reply all
Reply to author
Forward
0 new messages