help > T-test: 2 Groups but several scans per subject on each group
Showing 1-4 of 4 posts
Display:
Results per page:
Oct 23, 2023  11:10 AM | Javier Gonzalez Castillo
T-test: 2 Groups but several scans per subject on each group

Dear Dr. Zalesky,


I am working on a project involving hundreds of scans that I subdivide into two groups (A & B) based on some external, non-imaging metric. To simplify the discussion, let’s assume I only have 10 scans, 4 in group A and 6 in group B. As I am interested in differences between groups, I am planning to use a T-test with the following design matrix:


Group A | 1 0


Group A | 1 0


Group A | 1 0


Group A | 1 0


Group B | 1 1


Group B | 1 1


Group B | 1 1


Group B | 1 1


Group B | 1 1


Group B | 1 1  


And for the contrasts, I would be looking at [0, 1] and [0,-1] . When I do this, I get very nice and interpretable results.


Unfortunately, by doing things this way I am obviating the fact that within each group there are sometimes more than one scan per subject. Here is an example of how the data looks constrained to the 10 subject hypothetical scenario:


Group A Sbj 1


Group A Sbj 1


Group A Sbj 2


Group A Sbj 3


Group B Sbj 4


Group B Sbj 5


Group B Sbj 5


Group B Sbj 6


Group B Sbj 6


Group B Sbj 6


As you can see the number of scans per subject can vary (subject 1 has two scans, subject 2 has one, subject 6 has 3, etc..). Although the scans happen at different moments in time, "time" is not a variable of interest. All I am interested is whether a scan is classified as being in group A or B, and to explore differneces across the two groups. My questions are:


1) What would be the design matrix to account for this scenario where there are more than one scan per subject within each group of interest?


2) What would be the contrast for "A > B" and "B > A"?


3) Do I need to also define an Exchange Block? For scenario above, would that be [1,1,2,3,4,5,5,6,6,6]?


Thanks so much for taking the time to look into this and for making NBS so readily available to all of us,


Best,


Javier.

Oct 24, 2023  12:10 AM | Andrew Zalesky
RE: T-test: 2 Groups but several scans per subject on each group

Hi Javier, 


A simple strategy would be to average all matrices collected across the same individual and input the averaged matrix into NBS. This will ensure that each subject will only ever feature in one row of the design matrix. 


An alternative approach is to use a repeated measures design in which a new column is added to the design matrix for each individual. The new column would have 1's positioned at any rows corresponding to the individual and 0's elsewhere. Each subject would have such a column. An example of such a design matrix is provided under the help section button. Exchange blocks can be helpful for this approach but exchange blocks require the exact same number of scans per subject. Exchange blocks won't work if the number of scans differ between subjects. Your example of an exchange block won't work for this reason. 


For your current design matrix, the contrasts would be [0 -1] and [0 1]. 


 


Andrew


 


Originally posted by Javier Gonzalez Castillo:



Dear Dr. Zalesky,


I am working on a project involving hundreds of scans that I subdivide into two groups (A & B) based on some external, non-imaging metric. To simplify the discussion, let’s assume I only have 10 scans, 4 in group A and 6 in group B. As I am interested in differences between groups, I am planning to use a T-test with the following design matrix:


Group A | 1 0


Group A | 1 0


Group A | 1 0


Group A | 1 0


Group B | 1 1


Group B | 1 1


Group B | 1 1


Group B | 1 1


Group B | 1 1


Group B | 1 1  


And for the contrasts, I would be looking at [0, 1] and [0,-1] . When I do this, I get very nice and interpretable results.


Unfortunately, by doing things this way I am obviating the fact that within each group there are sometimes more than one scan per subject. Here is an example of how the data looks constrained to the 10 subject hypothetical scenario:


Group A Sbj 1


Group A Sbj 1


Group A Sbj 2


Group A Sbj 3


Group B Sbj 4


Group B Sbj 5


Group B Sbj 5


Group B Sbj 6


Group B Sbj 6


Group B Sbj 6


As you can see the number of scans per subject can vary (subject 1 has two scans, subject 2 has one, subject 6 has 3, etc..). Although the scans happen at different moments in time, "time" is not a variable of interest. All I am interested is whether a scan is classified as being in group A or B, and to explore differneces across the two groups. My questions are:


1) What would be the design matrix to account for this scenario where there are more than one scan per subject within each group of interest?


2) What would be the contrast for "A > B" and "B > A"?


3) Do I need to also define an Exchange Block? For scenario above, would that be [1,1,2,3,4,5,5,6,6,6]?


Thanks so much for taking the time to look into this and for making NBS so readily available to all of us,


Best,


Javier.



 

Oct 26, 2023  03:10 PM | Javier Gonzalez Castillo
RE: T-test: 2 Groups but several scans per subject on each group

Dear Andrew,


Thanks so much for your answer. Following your answer I tried the following things:


1) Averaging matrices --> results in a much smaller sample and nothing is significant. Not what I was hoping for :), so I moved to the second suggestion.


2) Add one column per subject with 1s signaling scans for that subject. In my hypothetical example from the post, the resulting matrix would be:


                           Intercept    Group     Sbj1      Sbj2      Sbj3     Sbj4     Sbj5      Sbj6 


Group A Sbj 1 |         1               0           1             0           0           0          0           0


Group A Sbj 1 |         1               0           1             0           0           0          0           0       


Group A Sbj 2 |         1               0          0             1            0           0          0           0


Group A Sbj 3 |         1               0          0             0           1            0          0           0


Group B Sbj 4 |         1               1          0             0           0            1          0           0


Group B Sbj 5 |         1               1          0             0           0            0          1           0


Group B Sbj 5 |         1               1          0             0           0            0          1           0


Group B Sbj 6 |         1               1          0             0           0            0          0           1


Group B Sbj 6 |         1               1         0             0           0            0          0           1


Group B Sbj 6 |         1               1         0             0           0            0          0           1


No Exachnge Blocks given your comment in the answer


Contrast "Group A > Group B": [0, -1, 0, 0, 0, 0, 0, 0]


Contrast "Group B > Group A": [0, 1, 0, 0, 0, 0, 0, 0]


If I do this, I get many errors of the form:


Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =  8.397229e-19. 
In NBSglm (line 157)
In NBSrun (line 296)
In NBS>get_ui (line 174)
 
Warning: Rank deficient, rank = 84, tol =  4.451803e-13. 


which I imagine it means this is not necessarily the best way to proceed.


3) You mentioned looking at the example of repeated measures, and after doing that, I came with this alternative matrix/contrasts:


                         Group     Sbj1      Sbj2      Sbj3     Sbj4     Sbj5      Sbj6 


Group A Sbj 1 |    1           1             0           0           0          0           0


Group A Sbj 1 |    1           1             0           0           0          0           0       


Group A Sbj 2 |    1          0             1            0           0          0           0


Group A Sbj 3 |    1          0             0           1            0          0           0


Group B Sbj 4 |   -1          0             0           0            1          0           0


Group B Sbj 5 |   -1          0             0           0            0          1           0


Group B Sbj 5 |   -1          0             0           0            0          1           0


Group B Sbj 6 |   -1          0             0           0            0          0           1


Group B Sbj 6 |   -1         0             0           0            0          0           1


Group B Sbj 6 |   -1         0             0           0            0          0           1


No Exachnge Blocks given your comment in the answer


Contrast "Group A > Group B": [1, 0, 0, 0, 0, 0, 0]


Contrast "Group B > Group A": [-1, 0, 0, 0, 0, 0, 0]


If I do this, then for one directionality of the contrast results do not reach significance, but for the other I get very similar results to my original approach that did not account for subject identity.


My questions are:



  • Is this third formulation correct?

  • My understanding of repeated measures is that such a design traditionally applies when you have the same subjects in both groups (e.g., same people scaned under two different conditions). That is definitely not the case here. Is it still correct to do things this way despite this not being a "conventional" repeated measures design?

  • As per your advice, I am not using Exchange Blocks. Is this something to be worried about given my design?


Thanks again for your time and insights,


Javier.

Oct 26, 2023  09:10 PM | Andrew Zalesky
RE: T-test: 2 Groups but several scans per subject on each group

Hi Javier,


the column of 1's needs to be removed if you are modelling within-subject means. 



  • The third formulation looks correct to me. 

  • A repeated measures design remains feasible in cases where the number of repeats scans differs. Ideally, they would be roughly the same.  

  • Exchange blocks are important because they constrain permutations among repeated measurements. NBS only allows for exhange blocks in cases where the same number of repeats scans are available for all subjects. This is a limitation and would need to be noted.


andrew


Originally posted by Javier Gonzalez Castillo:



Dear Andrew,


Thanks so much for your answer. Following your answer I tried the following things:


1) Averaging matrices --> results in a much smaller sample and nothing is significant. Not what I was hoping for :), so I moved to the second suggestion.


2) Add one column per subject with 1s signaling scans for that subject. In my hypothetical example from the post, the resulting matrix would be:


                           Intercept    Group     Sbj1      Sbj2      Sbj3     Sbj4     Sbj5      Sbj6 


Group A Sbj 1 |         1               0           1             0           0           0          0           0


Group A Sbj 1 |         1               0           1             0           0           0          0           0       


Group A Sbj 2 |         1               0          0             1            0           0          0           0


Group A Sbj 3 |         1               0          0             0           1            0          0           0


Group B Sbj 4 |         1               1          0             0           0            1          0           0


Group B Sbj 5 |         1               1          0             0           0            0          1           0


Group B Sbj 5 |         1               1          0             0           0            0          1           0


Group B Sbj 6 |         1               1          0             0           0            0          0           1


Group B Sbj 6 |         1               1         0             0           0            0          0           1


Group B Sbj 6 |         1               1         0             0           0            0          0           1


No Exachnge Blocks given your comment in the answer


Contrast "Group A > Group B": [0, -1, 0, 0, 0, 0, 0, 0]


Contrast "Group B > Group A": [0, 1, 0, 0, 0, 0, 0, 0]


If I do this, I get many errors of the form:


Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =  8.397229e-19. 
In NBSglm (line 157)
In NBSrun (line 296)
In NBS>get_ui (line 174)
 
Warning: Rank deficient, rank = 84, tol =  4.451803e-13. 


which I imagine it means this is not necessarily the best way to proceed.


3) You mentioned looking at the example of repeated measures, and after doing that, I came with this alternative matrix/contrasts:


                         Group     Sbj1      Sbj2      Sbj3     Sbj4     Sbj5      Sbj6 


Group A Sbj 1 |    1           1             0           0           0          0           0


Group A Sbj 1 |    1           1             0           0           0          0           0       


Group A Sbj 2 |    1          0             1            0           0          0           0


Group A Sbj 3 |    1          0             0           1            0          0           0


Group B Sbj 4 |   -1          0             0           0            1          0           0


Group B Sbj 5 |   -1          0             0           0            0          1           0


Group B Sbj 5 |   -1          0             0           0            0          1           0


Group B Sbj 6 |   -1          0             0           0            0          0           1


Group B Sbj 6 |   -1         0             0           0            0          0           1


Group B Sbj 6 |   -1         0             0           0            0          0           1


No Exachnge Blocks given your comment in the answer


Contrast "Group A > Group B": [1, 0, 0, 0, 0, 0, 0]


Contrast "Group B > Group A": [-1, 0, 0, 0, 0, 0, 0]


If I do this, then for one directionality of the contrast results do not reach significance, but for the other I get very similar results to my original approach that did not account for subject identity.


My questions are:



  • Is this third formulation correct?

  • My understanding of repeated measures is that such a design traditionally applies when you have the same subjects in both groups (e.g., same people scaned under two different conditions). That is definitely not the case here. Is it still correct to do things this way despite this not being a "conventional" repeated measures design?

  • As per your advice, I am not using Exchange Blocks. Is this something to be worried about given my design?


Thanks again for your time and insights,


Javier.