Contrasts for longitudinal 3dLMEr

G’day everyone,

I was wondering if someone could check if the contrasts that I’ve written for 3dLMEr are correct?
Our study is different than the examples put foreward in the help file, therefore I’m not 100% certain and would really appreciate some confirmation :slight_smile:

The following model is for a longitudinal study with two groups and measurements after 0,2,4,… months.
We unfortunately have missing data, therefore using 3dLMEr :slight_smile:


-prefix outputfile \
-jobs 12 \
-model  "Time*Group+Age+Gender+(1|Subj)" \
-qVars "Time,Age,outcome1,outcome2,outcome3" \
-resid residuals \
-mask mask.nii.gz \

(I specified more variables as qVars than I put into the model, because I might model them later on. That way I just need to change one line of code :wink: )

The contrast I’ve specified for the effect of time on Group 1 vs Group 2:


-gltCode Group1-Group2_TimeEff 'Group : 1*Group1 -1*Group2 Time :' 			\

The effect of time for both groups separately:


-gltCode Group1_TimeEff 'Group : 1*Group1 Time :' 			\
-gltCode Group2_TimeEff 'Group : 1*Group2 Time :' 			\

The effect of Group at Time 0 (?):


-gltCode Group1-Group2 'Group : 1*Group1 -1*Group2' 			\

And last but not least: The effects of age and gender:


-gltCode Age 'Age :' 			\
-gltCode F-M 'Gender : 1*f -1*m' 			\

The data table looks like this:


Subj Group Time outcome1 outcome2 outcome3 outcome4 outcome5 InputFile
1 Group1 0 1.44 2.33 235 255 5 path/to/file.nii.gz

I’d be happy about some feedback :slight_smile:

–Agent 007 :wink:

Welcome Agent 007!

-model “Time*Group+Age+Gender+(1|Subj)” \

With a longitudinal study, you may try to account for varying slope effect:

-model “Time*Group+Age+Gender+(Time|Subj)” \

The effect of Group at Time 0 (?):
-gltCode Group1-Group2 ‘Group : 1Group1 -1Group2’ \

By default, 3dLMEr centers a quantitative variable around its overall average across all subjects. So, the above specification makes inference about group difference at the average time. For Time 0, try

-gltCode Group1-Group2 ‘Group : 1Group1 -1Group2 Time : 0’ \

Your current model assumes a linear relationship of Time. In case nonlinearity is of interest, consider 3dMSS.

Thank you very much for your reply and the warm welcome, Gang!

With a longitudinal study, you may try to account for varying slope effect:
-model “Time*Group+Age+Gender+(Time|Subj)” \

That is a good idea, thank you! Btw, in lme4 (Time|Subj) is the same as (1+Time|Subj), if I am not mistaken? (Random intercept and random slope)

By default, 3dLMEr centers a quantitative variable around its overall average across all subjects.

Thanks, I forgot about that.

Your current model assumes a linear relationship of Time. In case nonlinearity is of interest, consider 3dMSS.

That looks like a promising tool. While I whink I can justify using a linear approach for now, as the variable “Time” is actually only 0 to 6, which can probably be considered to be"confined within a narrow range", to quote your post about 3dMSS, it definitely is interesting for future use!
For 3dLMEr so far, my next steps are input the residuals into 3dFWHMx and then use 3dClustsim for cluster correction

  • is there a way to do this with 3dMSS?

Would my model translate to the following in 3dMSS?:


 -mrr 's(Time)+s(Time,by=Group)+(Age)+(Gender)'             \
 -qVars 'Time,Group,Age'                            \

  • Does this compare the trend along Time between the two groups while correcting for the effects of Age and Gender?

Also, another question, if I may ask:

Is it possible to test for correlation of test outcome scores in 3dLMEr (and/or 3dMSS) without correcting for them?
I’m thinking that if I changed the model to Time*Group+Age+Gender+outcome1+outcome2+outcome3+(Time|Subj) , in order to be able to look at the effects of those outcome scores, I am basically correcting for them, am I not?

Kind regards,
AFNIuser007/ Agent 007 :wink:

in lme4 (Time|Subj) is the same as (1+Time|Subj), if I am not mistaken?

Yes, they share exactly the same notation.

For 3dLMEr so far, my next steps are input the residuals into 3dFWHMx and then use 3dClustsim for cluster correction

  • is there a way to do this with 3dMSS?

No, but you don’t have to adopt a harsh thresholding approach, and instead show the results in a gradation fashion.

-mrr ‘s(Time)+s(Time,by=Group)+(Age)+(Gender)’
-qVars ‘Time,Group,Age’ \

The above specification assumes that there are 10 or more time points. With 7 time points, try

-mrr ‘s(Time,k=7)+s(Time,by=Group,k=7)+Age+Gender’

if I changed the model to Time*Group+Age+Gender+outcome1+outcome2+outcome3+(Time|Subj) , in order to
be able to look at the effects of those outcome scores, I am basically correcting for them, am I not?

With this specification, you would be able to assess the association of each outcome with your outcome variable. However, I’m confused with your word “correcting”: What do you mean by “correcting for them”?

Thanks for your reply, very helpful!

-mrr ‘s(Time,k=7)+s(Time,by=Group,k=7)+Age+Gender’
According to the 3dMSS, I would create a pred.txt that include label, Time and Group (binarized).
Are Age and Gender okay to only be in the dataTable (not the pred.txt), and would Gender have to binarized for 3dMSS?

With this specification, you would be able to assess the association of each outcome with your outcome variable.
However, I’m confused with your word “correcting”: What do you mean “correcting for them”?

Maybe it is due to my superficial knowledge of statistics, but I was under the impression that if I include a (confounding) variable as covariate, like Age,
I am correcting my model for the effect of this variable. Basically taking out the effect of Age out of the Group*Time effect.
(Like the questions asked here: https://stats.stackexchange.com/questions/78816/how-do-you-control-for-a-factor-variable or https://stats.stackexchange.com/questions/17336/how-exactly-does-one-control-for-other-variables)

For example, in R, a model with var1~GroupTime+ReactionTime+(1|Subj) produces different fixed effects estimates for Time and Group and Group:Time than a model with only var1~GroupTime+(1|Subj). Therefore, I am assuming it has removed the effect from the Group*Time effect.

So if I changed
TimeGroup+Age+Gender+(Time|Subj)
to
Time
Group+Age+Gender+outcome1+outcome2+outcome3+(Time|Subj)
, my guess is that the Group*Time effect would look differently.

Similarily, I think adding them all into one 3dLMEr model would probably produce a different result than assessing the association of outcome1, 2 and 3 each in a separate 3dLMEr model (like TimeGroup+Age+Gender+outcome1+(Time|Subj), and another model being TimeGroup+Age+Gender+outcome2 +(Time|Subj), …etc.)

Do these thoughts make any sense?

-Agent007

According to the 3dMSS, I would create a pred.txt that include label, Time and Group (binarized).
Are Age and Gender okay to only be in the dataTable (not the pred.txt), and would Gender have to binarized for 3dMSS?

All predictors are required to be specified for prediction (in the file pred.txt). Dummy coding is needed when you want to account for the interaction with nonlinearity (e.g., Group in your case). However, Gender does not have to be dummy-coded.

I am assuming it has removed the effect from the Group*Time effect.

It does make sense, but it is a little too strong to describe the modeling approach as “correcting” or “removing”. I would say “adjusting” or “controlling”.

Thanks heaps!

–Agent007

Hi Gang, could I just ask a follow up question on including the outcome measures as covariates?

if I changed the model to Time*Group+Age+Gender+outcome1+outcome2+outcome3+(Time|Subj) , in order to be able to look at the effects of those outcome scores, I am basically correcting for them, am I not?
With this specification, you would be able to assess the association of each outcome with your outcome variable. (…)

Would -gltCode Outcome_1 'outcome1 : ’
be the correct contrast for assessing the correlation/ association of one of the parameters overall with the fmri input (which are betas of one IC from an ICA btw.)
And -gltCode Outcome_1 'Group: 1*Group1 outcome1 : ’
for only looking at one group?

I also tried the following contrasts to assess the effect of one of the outcome variables at a specific time point/ over time:
-gltCode outcome1_T4 ‘outcome1 : Time :4’
-gltCode outcome1_G1_T4 ‘Group: 1Group1 outcome1 : Time :4’
-gltCode outcome1_over_time ‘outcome1 : Time :’
-gltCode outcome1_G1_over_time 'Group: 1
Group1 outcome1 : Time :’
-gltCode outcome1_GroupDiff_over_time ‘Group: 1Group1 -1Group2 outcome1 : Time :’
For that, I changed the model to TimeGroupoutcome1+Age+Gender+outcome2+(Time|Subj).
But these contrasts only produced a 0 output. Not sure if the last three even make any sense (probably not?)

-007

Hi Agent 007 -

Would -gltCode Outcome_1 'outcome1 : ’
be the correct contrast for assessing the correlation/ association of one of the parameters overall
with the fmri input (which are betas of one IC from an ICA btw.)

That seems right.

And -gltCode Outcome_1 'Group: 1*Group1 outcome1 : ’
for only looking at one group?

In this case, it makes sense if your model contains the interaction term between Group and outcome1.

-gltCode outcome1_T4 ‘outcome1 : Time :4’ \

You’re not modeling the interaction between Time and outcome1. So, if I interpret what you want correctly, just do

-gltCode outcome1_T4 ‘outcome1 :’ \

-gltCode outcome1_G1_T4 ‘Group: 1*Group1 outcome1 : Time :4’ \

Same as above

-gltCode outcome1_over_time ‘outcome1 : Time :’
-gltCode outcome1_G1_over_time ‘Group: 1Group1 outcome1 : Time :’
-gltCode outcome1_GroupDiff_over_time 'Group: 1
Group1 -1*Group2 outcome1 : Time :’ \

These three lines don’t make sense to me. Could you explain what are you exactly looking for?

Hi Gang, thank you for your answer!

That seems right.
Thanks!

In this case, it makes sense if your model contains the interaction term between Group and outcome1.
That makes sense.
Do you know why it produces a result even without the interaction effect being in the model? Would you expect the result to be different?

So, if I interpret what you want correctly, just do -gltCode outcome1 ‘outcome1 :’ \
Thanks, then I’ll just stick with that.

-gltCode outcome1_over_time ‘outcome1 : Time :’
-gltCode outcome1_G1_over_time ‘Group: 1Group1 outcome1 : Time :’
-gltCode outcome1_GroupDiff_over_time 'Group: 1
Group1 -1*Group2 outcome1 : Time :’
These three lines don’t make sense to me. Could you explain what are you exactly looking for?

Basically, after checking the association between covariate and imaging overall, I was trying to find out if this association changes over time (1).
Then, if this is true when looking at only Group1 (2). And then, if the change is differently for both groups (3).
But I think it is not possible/ does not make sense to model all of this at once, as it would basically be a three step question:

  1. Is there an association between imaging and Outcome1?
  2. If yes, does this association get stronger or weaker over time?
  3. If it changes, is the magnitude of change different between the groups?

=> But now that I read this, it doesn’t sound like it makes a lot of sense to try to extract all this from one model. Also, our sample size is most likely to small for questions beyond Question 1, to be answered meaningfully. So I guess I’ll stick to question 1…

Do you know why it produces a result even without the interaction effect being in the model? Would you expect the result to be different?

3dLMEr would not parse the specification properly even though it didn’t throw an error in this case. To make sure you get the intended results, rerun the script with corrected coding.

  1. Is there an association between imaging and Outcome1?
  2. If yes, does this association get stronger or weaker over time?
  3. If it changes, is the magnitude of change different between the groups?

In your model specification “Time*Group+Age+Gender+outcome1+outcome2+outcome3+(Time|Subj)”, no interaction is assumed between Time and outcome1. Thus, to answer the three questions above, you don’t need to get Time involved. For example, for the question “does this association get stronger or weaker over time?”, the answer is that the association does not change because you already assumed so in your model.

If you really want to address these three questions, account for the interaction between Time and outcome1 by creating a regressor of their product after proper centering.

Thank you very much for your answer!

3dLMEr would not parse the specification properly even though it didn’t throw an error in this case. To make sure you get the intended results, rerun the script with corrected coding.

Thanks for pointing that out!

If you really want to address these three questions, account for the interaction between Time and outcome1 by creating a regressor of their product after proper centering.

Could you maybe explain what you mean with that? I am afraid I don’t quite understand.

Cheers!
-007

007,

Re: the interaction between Time and outcome1

Since both variable are quantitative, try this -

  1. Properly center both variables (https://afni.nimh.nih.gov/pub/dist/doc/htmldoc/statistics/center.html)
  2. Create a new variable (e.g., call it Z) which is the product of those two variables (after centering)
  3. Add the interaction variable Z into your data table and model specification
  4. Explore the interaction effect Z through -gltCode

Is this clear to you?

Is this clear to you?

Yep, got it now - thanks!
I’ll try it out this way.