Hi Laura
In the wiki https://surfer.nmr.mgh.harvard.edu/fswiki/LinearMixedEffectsModels we recommended to order the columns of the design matrix in the following way:

Column 1: the intercept term (which is a column of ones)

Colum 2: the time covariate if it varies across subjects (eg. time from baseline)

Column 3-q: any time-varying covariates (eg. training: 0 before training, 1 after training)

Column q+1-r: the group covariates of interest (eg. a binary variable indicating whether or not the subject is a patient), for n groups you will have n-1 binary covariates

Column r+1-s: interactions between group covariates with the time-varying covariates (only the interesting interactions)

Column s+1-p: any other nuisance time-invariant covariates (eg. age-at-baseline, gender, etc...)


LME is a type of linear regression model that integrates both a model for the mean and a model for the covariance into a single statistical model. So if you want to compare different models for the mean (with different covariates) then you need to start with a “maximal model for the mean” that includes all the possible covariates of interest. Then you select the random effects for that "maximal model" using the model selection procedure with lme_mass_LR. Random effects can only be time-varying covariates (i.e a subset of the columns from 1 to q above, those comprise the Zcols parameter in lme_mass_fit_vw)

After you choose which time-varying covariates are going to be considered as random effects then you can test if any single fixed effects covariate in your design matrix has a significant contribution to the model in the same way you would for a traditional GLM. You will use F-tests for that. Covariates that do not significantly contribute to the model can be ruled out of the model and a new model with less covariates but the same random effects can then be fitted.

Keep in mind that fitting lme models is computationally expensive and the computation overhead quickly increases with the number of random effects and fixed effects in your model. Also considering one or two random effects including the intercept term (or at most three) is usually enough but this really depends on the nature of the data.


Best
-Jorge



De: Laura Rueda Delgado <laura.ruedadelgado@kuleuven.be>
Para: Freesurfer support list <freesurfer@nmr.mgh.harvard.edu>
Enviado: Lunes 11 de abril de 2016 13:05
Asunto: Re: [Freesurfer] LME for functional data, 3 factors

Dear Martin,
 
Thank you for your quick response.
 
My research question is focused on the group and day effect, so I could simplify the model. From your response, I thought of including in the design matrix the binary code for Condition 2, and for Condition 3 in two columns, like you suggested; however, adding only the interaction effect of group and day. This way, the model takes into account the repeated measures of Condition while remaining relatively simple.
 
Now, to add more complexity and be more specific, I'm interested on neural correlates of learning, which is (un)fortunately tangled with performance. Therefore, I was thinking to add the learning gains (e.g. [performance_day_2 - performance_day_1]/performance_day_1) as a fixed effect. Checking the example datasets that come with the LME toolbox, I see that other measures (e.g. age, gender) are repeated for all the measures at different days of the same subject. And, when the age of participants at the first measurement is used as a fixed effect, "baseline age", the value is repeated for the baseline day and the other days. I was wondering if this could be applied for the Learning Gain as well (which is a measure of change of performance over the training days). I have my doubts because I would understand that this type of coding would describe two mixed aspects: a “prediction” of Gain from the brain data at Day 1, along with the appropriate relationship of Gain with brain data at Day 2. I would think that adding 0s for Day 1 in the variable Gain would be more appropriate, and this way the fixed effect of Day would be coded in the variable Gain. But of course, I recur to the experts to settle this issue.
 
Additionally, I see that I could compare two models with different number of random effects with lme_mass_LR. However, I would like to compare models with different covariates (other covariates of no interest, like gender and years of education). Is this possible within this toolbox?
 
 
Best regards,
 
Laura Rueda
 
From: freesurfer-bounces@nmr.mgh.harvard.edu [mailto:freesurfer-bounces@nmr.mgh.harvard.edu] On Behalf Of Martin Reuter
Sent: donderdag 7 april 2016 18:20
To: freesurfer@nmr.mgh.harvard.edu
Subject: Re: [Freesurfer] LME for functional data, 3 factors
 
Hi Laura,

1)
you would need to model the 3 level variable differently, as 1,2,3 will be understood as continuous and that is not what you want. Instead you have two columns: one column for group 2, where all instances are binary (1 if group is 2, else 0), and one for group 3. Then the intercept and slope will be for group 1 and these columns contain the offsets for group 2 and 3 respectively.
About interactions, make sure you really want to model all interactions. Some may be not very meaningful and keeping the model simple is usually a good idea. But if you want them all, add them all.

2) Zcols: Vector with the indices of the colums of X that will be considered  as random effects. Usually the intercept is a random effect and maybe other variables (e.g. the time, if you want to allow slopes to be different across subjects). For just the intercept column use [ 1]
ni should be correct

3) yes, but with the design above, since you model a global intercept and then the offset of each group (or whatever that three condition variable is) you need to make sure you interpret things correctly. E.g. a 1 in such a column for group 2 or three indicates that there is a difference from the first group. This is not the group 2 effect.

4) Sorry, I don't know. Maybe someone else has a suggest.

Since you have all interactions, you should be able to specify contrast according to your test in this model and don't need to create a new one. Your setup is a little complicated, so it would be wise to involve a local statistician to make sure you are interpreting things correctly.

Best, Martin


On 04/07/2016 10:57 AM, Laura Rueda Delgado wrote:
Dear FreeSurfers and LME experts,
 
I've just started using the LME toolbox by Bernal-Rusiel et al (2012, 2013) in Matlab, apart from FreeSurfer. My experimental design includes one between-subjects factor (group with two levels, 24 vs 22 subjects), and two within-subjects (WS) factors (day with two levels, and condition with three levels). As far as I understand, the LME toolbox can be used for longitudinal data and for investigating modulations of neural activity with behavioral measures. However, it's been difficult for me to set up both the design matrix and the input of the LME functions given three fixed factors in my design (I haven't included behavior yet). So I have a few questions that I hope you can help me answer. I follow these steps:
 
1) Following the wiki, I've created a pre-design matrix, M, with:
First column: Day factor coded as 0 (first day) and 7 (7 days later, as during acquisition).
Second column: Group factor binary coded.
Third column: Condition factor coded with dummy variables 1 to 3 (three conditions in total). I don’t know if this is correct; I have failed to find in the mailing list any reference to an additional repeated measure besides time in LME models.
From here, I've created the design matrix X adding a column of 1's for the intercept, adding the pre design matrix M, and adding columns for every possible interaction by multiplying element-wise the columns of M (including two-way and three-way interactions).
 
2) I then use lme_mass_fit_vw, but I have doubts about some inputs
Zcols: column 1 in X
ni: created a vector with 6 for all subjects (in total there are 6 repeated measures, 2 of day and 3 of condition)
I kept the others as default.
 
3) lme_mass_F for statistics of fixed effects. I check main effects and interactions with contrasts based on the design matrix X: placing a 1 in the column position corresponding to each effect of interest.
 
4) lme_mass_FDR2 for correcting the F stats for multiple comparisons. I would like to compare the results using AlphaSim's Monte-Carlo simulations, however I'm not sure what image to use to estimate the smoothness. Would you have a suggestion?
 
Could you please let me know if this procedure is sound? Also, if I’m interested in specific comparisons or post-hoc tests, e.g. Group 1$Day 1$Condition 3 vs. Group 1$Day 2$Condition 3, would I need a separate model for that? And lastly, for the analysis including the behavioral measures, should I just include them as a forth column in the pre-design matrix M and add the relevant effects in X?
 
I hope I haven’t overwhelmed you with so many questions. I would greatly appreciate any suggestion you can provide.
 
 
Best regards,
 
 
Laura Rueda
 



_______________________________________________
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu
https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer


-- 
Martin Reuter, PhD
Assistant Professor of Radiology, Harvard Medical School
Assistant Professor of Neurology, Harvard Medical School
A.A.Martinos Center for Biomedical Imaging
Massachusetts General Hospital
Research Affiliate, CSAIL, MIT
Phone: +1-617-724-5652
Web  : http://reuter.mit.edu 

_______________________________________________
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu
https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer


The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.