[R-sig-ME] Interaction effects with GAMM

Louise Baruël Johansen |ou|@ebj @end|ng |rom drcmr@dk
Tue Feb 26 13:57:58 CET 2019

Dear Phillip,

Thank you for taking your time to look at my question.

Our data consists of up to 12 MRI scans per subject with interscan-intervals of 6 months, and the subjects were between the age of 7-13 years at baseline, which gives us a reasonable overlap between subjects. The brain data is extracted from regions of interest, and the behavioural data could be RT.

My question was more regarding how to incorporate the interaction effects in the most appropriate way statistically; by using te(), ti(), or in a completely different way?

All the best,


> On 22 Feb 2019, at 11.29, Phillip Alday <phillip.alday using mpi.nl> wrote:
> Hi Louise,
> I'm somewhat curious what brain imaging data you have that can be so
> neatly summed up as a single univariate value. While you can do e.g. the
> EEG voltage at a given timepoint in a given channel or the BOLD signal
> in a given voxel or some overall structural score derived from DTI,
> these are generally very poor indices of the structural and activity
> variation within and between brains. I ask because knowing more about
> your data helps when giving advice about a model. I'm guessing behavior
> is something like RT or maybe d-prime/sensitivity index and *not* simple
> accuracy, where a Gaussian model would not be appropriate.
> All that said, I do already have one comment/question ...
> Your data are longitudinal, but how much so? What's the range in age
> within subjects vs. between subjects? If the range within subjects is
> just a few months to a year or two and the range between subjects is
> several years, as is common in many studies, then having a by-subject
> slope for age doesn't really make much sense. The overall by-subjects
> variation (the intercept, i.e. ~1) and residual variation will probably
> dominate.
> And some general advice: use the various plotting functions (plot(),
> vis.gam()), etc. to get an idea about what your model "thinks" the world
> looks like and whether that matches your own expectations and
> matches/fits the picture presented by the data.
> Best,
> Phillip
> On 20/2/19 10:01 am, Louise Baruël Johansen wrote:
>> I have a question on how to model interaction terms including smooths in a GAMM model (using the mgcv and nlme packages in R).
>> We have collected longitudinal behavioral and brain imaging data from ~100 subjects across ~6 time points, and I would like to model main effects of age, sex, brain as well as to-way interaction terms (and maybe three-way interaction terms), while correcting for education level and taking random effects into account.
>> Is using the ti() setup the way to do this:
>> M = gamm(behav ~ ti(age) + sex + education + ti(age, by = sex) + brain + ti(brain, by = age), random = list(subjectID = ~1+age), data = data)
>> All help will be appreciated. 
>> Thanks, Louise
>> _______________________________________________
>> R-sig-mixed-models using r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models

More information about the R-sig-mixed-models mailing list