0todd0000 / spm1d

One-Dimensional Statistical Parametric Mapping in Python
GNU General Public License v3.0
61 stars 21 forks source link

Mixed model SPM #255

Closed basvanhooren closed 10 months ago

basvanhooren commented 1 year ago

For one of my research projects, people ran in the lab and we obtained time-normalized kinematics at four different running speeds. They were then assigned to two groups and re-performed the measurements after 6 months. Now I would like to know whether the kinematics changed 'overall' within each group from pre to post 6 months, and I would like to know whether the change differed between the (independent) groups.

Mark suggested to take a look at the anova2onerm script for the data analysis.

If I understand this script correctly, it assumes I have two independent groups (defined by variable A) For each group, I can specify up to three repeated measures by variable B

Now my questions are as follows: I have four repeated measures (i.e., time-series for four speeds) per measurement. Can I simply change "dataset = spm1d.data.uv1d.anova2onerm.SPM1D_ANOVA2ONERM_2x3()" to "dataset = spm1d.data.uv1d.anova2onerm.SPM1D_ANOVA2ONERM_2x4()" to make sure the script works for 4 repeated measures?

My next question relates to the time effect. In my design I have measured two groups on two time points (pre & post a 6 month intervention), at four speeds per time point. If I understand the script correctly, it allows me to specify up to 4 different groups (defined by variable A). However I'm just interested in comparing two groups, so the 2x.. design would be sufficient. But I'm not sure how I would need to specify the different time points as I would use variable B to define the four different speeds, but then I would need another variable to specify the time point right? Is this script therefore appropriate for my analysis or would I need to use another script?

Or alternatively, would I need to compute a change score between the pre- and post measurement and use the change score as input to the script?

0todd0000 commented 1 year ago

For each group, I can specify up to three repeated measures by variable B

You are not limited to three levels, you can specify an arbitrary large number of levels for both A and B.



Can I simply change "dataset = spm1d.data.uv1d.anova2onerm.SPM1D_ANOVA2ONERM_2x3()" to "dataset = spm1d.data.uv1d.anova2onerm.SPM1D_ANOVA2ONERM_2x4()" to make sure the script works for 4 repeated measures?

"SPM1D_ANOVA2ONERM_2x3" is a built-in dataset. To use your own data it is best to avoid spm1d.data, which contains only built-in datasets.

Incidentally, there is no built-in dataset called "SPM1D_ANOVA2ONERM_2x4", so the suggested change will yield an error. All data files associated with the built-in datasets can be seen here: https://github.com/0todd0000/spm1d/tree/master/spm1d/data/datafiles



I'm just interested in comparing two groups, so the 2x.. design would be sufficient.

If you are comparing two groups then the first factor A should contain two unique integers specifying the two groups. The function signature is:

spm = anova2onerm(Y, A, B, SUBJ)

where the variables are:



But I'm not sure how I would need to specify the different time points as I would use variable B to define the four different speeds, but then I would need another variable to specify the time point right?

It sounds like you may have a three-way design. The three factors are GROUP (levels: 1, 2), SPEED (levels: 1, 2, 3, 4), TIME (levels: 1, 2) where the two levels of time specify something like "baseline" and "6-months later". If this interpretation is correct, then you probably need spm1d.stats.anova3tworm, which is a three-way design with two repeated-measures factors (SPEED and TIME). For this function you'd need an extra variable C containing integer labels for the third factor:

spm = anova3tworm(Y, A, B, C, SUBJ)



Or alternatively, would I need to compute a change score between the pre- and post measurement and use the change score as input to the script?

Yes, you could do this and reduce the design back to two-way ANOVA.

basvanhooren commented 1 year ago

Thanks for the reply, I think all is clear now!