qunestion about 3dLMEr: Model test failed

AFNI version info (afni -ver):

Hello ! I am trying to write a script to analyze task data using 3dLMEr.
We have a between-subject factor (group: two groups of subjects -- control, patient), and a within-subject factros (condition: 2 levels -- imagery (IMA), working memory (WM)). We are interested in looking at the difference between IMA and WM in two group respectively, and the differences in response between the two groups of people in the same condition. At the same time, we want to explore the differences in IMA and WM response between the two groups. I use the following code.

3dLMEr -prefix ${method}_LME_diff_${interested_period[$x]}_${ROI_all_name[$l]} \
               -jobs 20 \
               -mask /data/fmri/obj_IMA/scripts/searchlight/mask/MNI152_T1_2009c_mask_2mm+tlrc \
               -model 'group*condition+(1|Subj)+(1|Subj:condition)' \
               -SS_type 3 \
               -gltCode general_IMA 'condition : 1*IMA group : 1*general' \
               -gltCode general_WM 'condition : 1*WM group : 1*general' \
               -gltCode patient_IMA 'condition : 1*IMA group : 1*patient' \
               -gltCode patient_WM 'condition : 1*WM group : 1*patient' \
               -gltCode general_diff 'condition : 1*IMA -1*WM group : 1*general' \
               -gltCode patient_diff 'condition : 1*IMA -1*WM group : 1*patient' \
               -gltCode IMA_diff 'group : 1*general -1*patient condition : 1*IMA' \
               -gltCode WM_diff 'group : 1*general -1*patient condition : 1*WM' \
               -gltCode inter1 'group : 1*general -1*patient condition : 1*IMA -1*WM' \
               -dataTable \
               Subj group condition InputFile \
               p02 general IMA /data/fmri/obj_IMA/proc/p02/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index1[$x]}]'' \
               p02 general WM /data/fmri/obj_IMA/proc/p02/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index2[$x]}]'' \
               p03 general IMA /data/fmri/obj_IMA/proc/p03/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index1[$x]}]'' \
               p03 general WM /data/fmri/obj_IMA/proc/p03/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index2[$x]}]'' \
               p04 general IMA /data/fmri/obj_IMA/proc/p04/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index1[$x]}]'' \
               p04 general WM /data/fmri/obj_IMA/proc/p04/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index2[$x]}]'' \
               p05 general IMA /data/fmri/obj_IMA/proc/p05/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index1[$x]}]'' \
               p05 general WM /data/fmri/obj_IMA/proc/p05/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index2[$x]}]'' \
               p06 general IMA /data/fmri/obj_IMA/proc/p06/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index1[$x]}]'' \
               p06 general WM /data/fmri/obj_IMA/proc/p06/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index2[$x]}]'' \
               p08 general IMA /data/fmri/obj_IMA/proc/p08/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index1[$x]}]'' \
               p08 general WM /data/fmri/obj_IMA/proc/p08/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index2[$x]}]'' \
               p09 general IMA /data/fmri/obj_IMA/proc/p09/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index1[$x]}]'' \
               p09 general WM /data/fmri/obj_IMA/proc/p09/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index2[$x]}]'' \
               p10 general IMA /data/fmri/obj_IMA/proc/p10/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index1[$x]}]'' \
               p10 general WM /data/fmri/obj_IMA/proc/p10/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index2[$x]}]'' \
               p11 general IMA /data/fmri/obj_IMA/proc/p11/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index1[$x]}]'' \
               p11 general WM /data/fmri/obj_IMA/proc/p11/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index2[$x]}]'' \
               p12 general IMA /data/fmri/obj_IMA/proc/p12/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index1[$x]}]'' \
               p12 general WM /data/fmri/obj_IMA/proc/p12/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index2[$x]}]'' \
               p13 general IMA /data/fmri/obj_IMA/proc/p13/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index1[$x]}]'' \
               p13 general WM /data/fmri/obj_IMA/proc/p13/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index2[$x]}]'' \
               p14 general IMA /data/fmri/obj_IMA/proc/p14/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index1[$x]}]'' \
               p14 general WM /data/fmri/obj_IMA/proc/p14/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index2[$x]}]'' \
               p15 general IMA /data/fmri/obj_IMA/proc/p15/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index1[$x]}]'' \
               p15 general WM /data/fmri/obj_IMA/proc/p15/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index2[$x]}]'' \
               p17 general IMA /data/fmri/obj_IMA/proc/p17/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index1[$x]}]'' \
               p17 general WM /data/fmri/obj_IMA/proc/p17/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index2[$x]}]'' \
               p18 general IMA /data/fmri/obj_IMA/proc/p18/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index1[$x]}]'' \
               p18 general WM /data/fmri/obj_IMA/proc/p18/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index2[$x]}]'' \
               p19 general IMA /data/fmri/obj_IMA/proc/p19/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index1[$x]}]'' \
               p19 general WM /data/fmri/obj_IMA/proc/p19/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index2[$x]}]'' \
               p20 general IMA /data/fmri/obj_IMA/proc/p20/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index1[$x]}]'' \
               p20 general WM /data/fmri/obj_IMA/proc/p20/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index2[$x]}]'' \
               p21 general IMA /data/fmri/obj_IMA/proc/p21/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index1[$x]}]'' \
               p21 general WM /data/fmri/obj_IMA/proc/p21/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index2[$x]}]'' \
               p22 general IMA /data/fmri/obj_IMA/proc/p22/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index1[$x]}]'' \
               p22 general WM /data/fmri/obj_IMA/proc/p22/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index2[$x]}]'' \
               p23 general IMA /data/fmri/obj_IMA/proc/p23/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index1[$x]}]'' \
               p23 general WM /data/fmri/obj_IMA/proc/p23/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index2[$x]}]'' \
               a01 patient IMA /data/fmri/obj_IMA/proc/a01/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index1[$x]}]'' \
               a01 patient WM /data/fmri/obj_IMA/proc/a01/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index2[$x]}]'' \
               a02 patient IMA /data/fmri/obj_IMA/proc/a02/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index1[$x]}]'' \
               a02 patient WM /data/fmri/obj_IMA/proc/a02/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index2[$x]}]'' \
               a03 patient IMA /data/fmri/obj_IMA/proc/a03/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index1[$x]}]'' \
               a03 patient WM /data/fmri/obj_IMA/proc/a03/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index2[$x]}]'' \
               a04 patient IMA /data/fmri/obj_IMA/proc/a04/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index1[$x]}]'' \
               a04 patient WM /data/fmri/obj_IMA/proc/a04/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index2[$x]}]'' \
               a05 patient IMA /data/fmri/obj_IMA/proc/a05/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index1[$x]}]'' \
               a05 patient WM /data/fmri/obj_IMA/proc/a05/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index2[$x]}]'' \
               a06 patient IMA /data/fmri/obj_IMA/proc/a06/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index1[$x]}]'' \
               a06 patient WM /data/fmri/obj_IMA/proc/a06/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index2[$x]}]'' \
               a07 patient IMA /data/fmri/obj_IMA/proc/a07/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index1[$x]}]'' \
               a07 patient WM /data/fmri/obj_IMA/proc/a07/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index2[$x]}]'' \
               a08 patient IMA /data/fmri/obj_IMA/proc/a08/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index1[$x]}]'' \
               a08 patient WM /data/fmri/obj_IMA/proc/a08/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index2[$x]}]'' \
               a09 patient IMA /data/fmri/obj_IMA/proc/a09/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index1[$x]}]'' \
               a09 patient WM /data/fmri/obj_IMA/proc/a09/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index2[$x]}]'' \
               a10 patient IMA /data/fmri/obj_IMA/proc/a10/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index1[$x]}]'' \
               a10 patient WM /data/fmri/obj_IMA/proc/a10/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index2[$x]}]'' \
               a11 patient IMA /data/fmri/obj_IMA/proc/a11/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index1[$x]}]'' \
               a11 patient WM /data/fmri/obj_IMA/proc/a11/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index2[$x]}]'' \
               a12 patient IMA /data/fmri/obj_IMA/proc/a12/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index1[$x]}]'' \
               a12 patient WM /data/fmri/obj_IMA/proc/a12/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index2[$x]}]'' \
               a13 patient IMA /data/fmri/obj_IMA/proc/a13/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index1[$x]}]'' \
               a13 patient WM /data/fmri/obj_IMA/proc/a13/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index2[$x]}]'' \
               a14 patient IMA /data/fmri/obj_IMA/proc/a14/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index1[$x]}]'' \
               a14 patient WM /data/fmri/obj_IMA/proc/a14/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index2[$x]}]'' \
               a15 patient IMA /data/fmri/obj_IMA/proc/a15/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index1[$x]}]'' \
               a15 patient WM /data/fmri/obj_IMA/proc/a15/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index2[$x]}]'' \
               a16 patient IMA /data/fmri/obj_IMA/proc/a16/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index1[$x]}]'' \
               a16 patient WM /data/fmri/obj_IMA/proc/a16/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index2[$x]}]'' \
               a17 patient IMA /data/fmri/obj_IMA/proc/a17/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index1[$x]}]'' \
               a17 patient WM /data/fmri/obj_IMA/proc/a17/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index2[$x]}]'' \
               a18 patient IMA /data/fmri/obj_IMA/proc/a18/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index1[$x]}]'' \
               a18 patient WM /data/fmri/obj_IMA/proc/a18/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index2[$x]}]'' \
               a19 patient IMA /data/fmri/obj_IMA/proc/a19/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index1[$x]}]'' \
               a19 patient WM /data/fmri/obj_IMA/proc/a19/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index2[$x]}]'' \
               a20 patient IMA /data/fmri/obj_IMA/proc/a20/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index1[$x]}]'' \
               a20 patient WM /data/fmri/obj_IMA/proc/a20/${exp}.results/${method}_${ROI_all_name[$l]}.stats.errts_data+tlrc''[${interested_index2[$x]}]''

The first few lines of output from 3dLMEr:

Dimensions:
rows: 80 | columns: 4

Data summary:
 Variable  Detected_Type Details
 Subj      Subjects      Num Subjects=40
 group     Categorical   Counts: general=40 | patient=40
 condition Categorical   Counts: IMA=40 | WM=40
 InputFile Data          Number of InputFiles=80

++ Good: All InputFiles exist.

++ Good: All InputFiles have exactly 1 volume.

++ Good: All InputFiles are on the same grid.


++++++++++++++++++++++++++++++++++++++++++++++++++++
***** Summary information of data structure *****
80 response values
2 levels for factor condition : IMA WM

Contingency tables of subject distributions among the categorical variables:

***** End of data structure information *****
++++++++++++++++++++++++++++++++++++++++++++++++++++

Reading input files now...

Reading input files for effect estimates: Done!


Range of input data: [-154.087, 91.922]

If the program hangs here for more than, for example, half an hour,
kill the process because the model specification or something else
is likely inappropriate.

Loading required package: lme4
Loading required package: Matrix
Package lme4 loaded successfully!

Loading required package: lmerTest

Attaching package: ‘lmerTest’

The following object is masked from ‘package:lme4’:

    lmer

The following object is masked from ‘package:stats’:

    step

Package lmerTest loaded successfully!

Loading required package: phia
Loading required package: car
Loading required package: carData
Package phia loaded successfully!

~~~~~~~~~~~~~~~~~~~ Model test failed  ~~~~~~~~~~~~~~~~~~~
Possible reasons:

0) Missing R packages lme4, lmerTest, and phia.
1) Inappropriate model specification with options -model, or -qVars.

2) Incorrect specifications with -gltCode.

3) inconsistencies in the data table.
4) Inconsistent variable names (e.g., typos, case sensitive characters).

** Error:
   Quitting due to model test failure...

When I change the model to the following:

-model 'group*condition+(1|Subj)'

3dLMEr will run successfully. I don't understand. Could you give me some help?

Thanks a lot !

1 Like

The following

-model 'group*condition+(1|Subj)'

is the correct model specification. The term (1|Subj:condition) is the same as the residuals; explicitly adding it to the model would cause collinearity.

Gang Chen

1 Like

Dear Gang
Thank you for your relply.
If I have two within-subject factros (eg. condition, method), I can set the model to the following ?

 -model 'group*condition+(1|Subj)+(1|Subj:condition)+(1|Subj:method)'

Now, (1|Subj:condition) or (1|Subj:method) is not equal the residuals of the data. (1|Subj:condition) is just a random-effect for cross-conditions, factor-method is not included.
(1|Subj:method) is just a random-effect for cross-methods, factor-condition is not included. Right ?

Thanks a lot !

1 Like

If I have two within-subject factros (eg. condition, method), I can set the model to the following ?

-model 'group*condition+(1|Subj)+(1|Subj:condition)+(1|Subj:method)'

Yes, that would be a proper specification with two within-individual factors. For more detailed guidance, you can refer to this discussion.

Gang Chen

1 Like

Thank you very much !

Ting

1 Like

Dear Gang
I have two within - subject factors (e.g., hemisphere, region) and a covariate (e.g., mathability). I want to analyze the main effects of these two within - subject factors, their interaction effect, and the interaction effects between the covariate and each of the two within - subject factors.Now I have two models.
1、-model 'Hemisphere * Region+MathAbility+(1|Subj)+(1|Subj:Hemisphere)+(1|Subj:Region)'
2、-model 'Hemisphere * Region*MathAbility+(1|Subj)+(1|Subj:Hemisphere)+(1|Subj:Region)'
Which model should I choose? What are the differences between these two models? If I choose the second model, why can't I run it?

Your model specification involves two key aspects.

First, what is the response (outcome) variable, and how does MathAbility relate to the other variables? For some effects of interest, including MathAbility in the model may require justification, as discussed in this blog post.

Second, the key difference between the two models you mentioned is in their assumptions about MathAbility. In the first model, its effect is assumed to be constant across hemispheres and regions, whereas in the second model, it is allowed to vary across these factors.

Gang Chen

Dear Gang
Thank you for your reply. I’m really sorry for replying late due to some things.

In my study, the response variable is the functional connectivity between ROIs and other voxels across the brain. I've segmented the hippocampus into anterior and posterior parts. For each participant, I obtained the functional connectivity of four ROIs with other voxels across the brain (eg. left anterior hippocampus, left posterior hippocampus, right anterior hippocampus, right posterior hippocampus). This fits a within - subject 2×2 repeated measures ANOVA (hemisphere×region, left/right×anterior/posterior).

I want to analyze the main effects of these two factors and their interaction effect, such as whether the left hippocampus has higher functional connectivity than the right regardless of anterior/posterior position, or whether there are differences in anterior/posterior positions.

Also, each participant has a MathAbility value. I want to analyze the interaction effect between MathAbility and Hemisphere/Region, such as whether participants with higher MathAbility have higher hippocampal functional connectivity, or whether it relates to the position of the hippocampus (e.g., left/right, anterior/posterior).

So how should I set up the model to achieve my analytical objectives?

Since you're interested in the interactions among all the three variables, try the following model:

-model 'Hemisphere*Region*MathAbility+(1|Subj)+(1|Subj:Hemisphere)+(1|Subj:Region)'

Gang Chen