PennLINC / ModelArray

ModelArray: an R package for statistical analysis of fixel-wise data and beyond
https://pennlinc.github.io/ModelArray
BSD 3-Clause "New" or "Revised" License
5 stars 2 forks source link

Repeated measures data #81

Open araikes opened 11 months ago

araikes commented 11 months ago

Hi @zhao-cy,

How feasible is it to analyze repeated measures data with GAMs in ModelArray. Specifically, I have a dataset with 2 groups x 2 time point MRIs and I'm doing deformation-based voxel-wise analyses.

I was thinking of a formula that is specified as: ~ group*time + s(subject, bs = 're')

where group, time, and subject are all factors ala https://fromthebottomoftheheap.net/2021/02/02/random-effects-in-gams/

Given how you've formulated ModelArray, would this work?

zhao-cy commented 11 months ago

Hi @araikes! Thank you so much for your interest in ModelArray!

My understanding is that you have some longitudinal data and in theory, it's best to directly use some mixed-effect models. As you probably know, unfortunately, ModelArray does not support mixed-effect models right now, but only lm() and mgcv:gam(). I saw the blog you posted here that tries to use gam() to model random effects, however I am not familiar with mixed-effect models or random effects, so I would recommend consulting a statistician to see if your formula is appropriate for your case.

On the other hand, please note that in our CircleCI tests, we only test regular gam formulas, but not others. Therefore your formula may not be covered in the tests. The ones we test are listed in the doc for ModelArray.gam() - see "Regarding formula: So far these kinds of formula are tested:". For a full list of what exactly are tested in the CircleCI tests, please refer to the source code of testing.

Finally, if you are willing to contribute to ModelArray and implement mixed effect models such as ModelArray.gamm(), you are very welcome to do so, e.g., make a PR for that! The general workflow of the function should be similar to ModelArray.gam(). Happy to talk more if you'd like to do so. But definitely no pressure here.

Thank you, Chenying