# Re: [Freesurfer] Linear Mixed Effects model

```Hi Kasper,

your design matrix X should have as many rows as there are measurements. Say if
you have m subjects with n measurements each, it will be m*n rows. If different
subjects have different numbers of measurements, that's also OK; in such cases
the number of rows per subject in X will also differ.```
```
Then, X should contain the following columns:

1. intercept
this column should be all ones

2. time from baseline
if you have two time-points for each subject, this column should look as
follows:
0 follow-up-time_subj1 0 follow-up-time_subj2 0 follow-up-time_subj3 etc.
here, follow-up-time is the difference in time between time-point 1 and 2, i.e.
(time-point 2 minus time-point 1).

3. group indicator
0 for controls, 1 for patients

4. time x group interaction
multiply the values of columns 2 and 3

Further, it is important that the rows of X are ordered according to time for
each subject. In your case with two measurements for each subject (if I
understood correctly), this means that for the rows of X, time should be the
faster changing index, and subject the slower changing index. This results in a
sequence like subj1_time1 subj1_time2 subj2_time1 subj2_time2 subj3_time1 etc.
Needless to say, this must be the same in the ordering of your data variable Y.

Hope this helps,

Kersten

Am 08.08.2017 um 14:52 schrieb Kasper Jessen <kas...@brejes.com>:

> Dear FreeSurfer,
>
> I have a longitudinal study (patients and controls) with two time points
> (i.e., baseline and six-weeks follow-up). I would like to use the LME model
> as it can handle unequal timing and different number of time points across
> subjects due to missing data.
>
> I would like to test if there is an effect of (a) time (b) group and (c)
> group x time interaction.
>
> However, i am trouble with my design matrix X:
>
> (1) How would i write X?
>
> Thanks in advance
> Best regards
> Kasper
> _______________________________________________
> 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.

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