[R-sig-ME] Interaction effects with GAMM

Phillip Alday ph||||p@@|d@y @end|ng |rom mp|@n|
Fri Feb 22 11:29:39 CET 2019

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

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.


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