3dLME random effects and nesting

Hi AFNI crew,

I am trying to implement an analysis in 3dLME and I would like some guidance setting up the model and random effects, and nesting.

With limited numbers of subjects, we run multiple sessions / subject. I want to nest session within subject.

I want to assess the interaction between Taste and Hydration.

I have:

5 sessions (the random effect)
3 subjects
taste: 3 levels
hydration: 2 levels

The lines I’ve drafted are as follows:

-model	'Subj*Taste*Hydration'																	\
-num_glt 5																					\
-gltLabel 1 'pre-post' -gltCode 1 'Hydration : 1*pre -1*post'												\
-gltLabel 2 'water_pre-post' -gltCode 2 'Hydration : 1*pre -1*post Taste : 1*H2O'								\
-gltLabel 3 'sucrose_pre-post' -gltCode 3 'Hydration : 1*pre -1*post Taste : 1*Sucr'							\
-gltLabel 4 'citricacid_pre-post' -gltCode 4 'Hydration : 1*pre -1*post Taste : 1*CitA'							\
-gltLabel 5 'Taste_by_Hydration' -gltCode 5 'Taste : 1*H2O -1*Sucr & 1*H2O -1*CitA Hydration : 1*pre & 1*post'		\
-ranEff '~1+Subj|Ssn'																			\
-SS_type 3																					\
     Ssn     Subj     Taste     Hydration     InputFile
  1. Does the column order matter? Should the random effect be in the first column?

  2. Is the correct model: ‘SubjTasteHydration’ ?

  3. Is this how to write the random effects with nesting: -ranEff ‘~1+Subj|Ssn’ ?




The -model is for specifying fixed effects, so you probably want the following

-model ‘Taste*Hydration’ \

Subject should be the first column, and a more appropriate random-effects structure is probably something like -ranEff ‘~1+Ssn|Subj’. However, with only 3 subjects, I’m not so sure whether the data would work out in this case.

Thanks Gang,

This is going to get confusing in terms of what you and I are really talking about. We only have 3 subjects (monkeys), that’s why we need to run multiple sessions / subject. I think I have to turn the scripting upside down a little to get it to work for this scenario, follow me through…

My columns are really:

Session Monkey Taste Hydration InputFile

Session is the random factor. But in your terminology, it sounds like I must put it in the first column and call it ‘Subj’, correct? Fine.

So now I have:

Subj Monkey Taste Hydration InputFile

First, in this terminology, I want to specify Session (but remember here we’re calling it ‘Subj’) nested in Monkey.

Is that Monkey|Session or Session|Monkey?

Second, I think I should include Monkey as a fixed effect (since monkey is really not the same as your ‘Subj’ (your ‘Subj’ is my session)):


I think you dropped Subj (i.e.session) from the fixed effects line because you thought it was in fact subject (but it’s really session).

So in the end we have:

fixed effects: monkey, taste, and hydration
random effects: session (which we’ll name ‘Subj’ in your terminology) nested in monkey

Any less confused?!

Thanks, Peter


Yes 3dLME is hard coded with “Subj” as the default random-effects factor. So you may have to pretend that your ‘Session’ is your ‘Subj’ if you want to only model the random effects of “Session”.

When you say that you want to model “monkey” as a fixed-effects factor, are you really interested in the differences among the three monkeys? If not, you don’t have to explicitly put “monkey” in the model; that way the data from the three monkeys would be treated as three samples.

Thanks Gang, this is coming together…

We model monkey to account for differences (and to see if there is an outlier); but the flip-side if this is that this factor hopefully “soaks up” variance attributable to monkey.

I still want to confirm my nesting argument is correct.

I want Session nested in Monkey (but note session must be called ‘Subj’):

I think this is how to write that, correct?

-ranEff ‘~1+Monk|Subj’

Peter, it’s better to start with a simple model first and see if it works, especially in this case with minimum amount of data.

We model monkey to account for differences (and to see if there is an outlier); but the
flip-side if this is that this factor hopefully “soaks up” variance attributable to monkey.

When “monkey” is not directly specified in the model as a fixed- or random-effects factor, it does not mean that the variability among the monkeys is not accounted for. Instead the variability is explained in the residuals. Directly modeling it as a fixed-effects factor requires more model parameters, leading to unstable estimation in the process, and you don’t have enough data to play with.

-ranEff ‘~1+Monk|Subj’

Just try

-ranEff ‘~1’ \

and you should feel blessed if you get something interesting in the end.

Thanks Gang,

I’ve run a couple models and they “work” but that doesn’t mean they are correct, or correctly implemented. We can discuss why or why not Monkey must be included as a fixed effect, but this is the standard in the field (of monkey work, with limited numbers of monkeys).

What is the correct syntax for Session nested in Monkey? I’ve run it both ways, one way was complete in about 20 seconds, the other took about 20 hours. The taste by hydration interaction effect was nill in both models (as expected). However the df’s are odd, and the same, in both Session|Monkey and Monkey|Session implementations. (The fixed effects are " MonkeyTasteHydration").

How can I get:

monkey 2, 68
taste 2, 68
hydration 1, 68

Why 68? I have 15 sessions pre (hydration) and 15 sessions post (hydration).

There are 90 lines in my datatable.

90 - ( ( 3Monkey x 3Taste x 2Hydration ) + 5Sessions ) - 1 = 68