design repeated measurements model

4 次查看(过去 30 天)
Dominik
Dominik 2015-9-24
回答: Aditya 2025-1-31,5:40
Hi, I've a table t =
Group day1_1 day1_2 day2_1 day2_2
_________ ______ ______ ______ ______
'Placebo' 12.023 12.719 12.11 12.554
'Placebo' 11.806 12.186 12.788 12.164
'Control' 11.763 12.008 11.481 13.325
'Placebo' 11.703 11.678 12.073 12.234
'Control' 11.558 12.696 13.692 12.732
'Placebo' 13.633 13.253 11.347 12.432
'Placebo' 12.374 12.41 11.49 11.457
'Placebo' 11.476 11.564 12.542 11.112
'Control' 12.496 10.661 12.199 12.382
'Placebo' 12.659 12.863 11.844 11.799
'Control' 11.611 11.447 12.838 12.592
'Placebo' 12.524 13.7 11.772 11.387
where each row is a individual. individuals are tested on two following days with the same test (before and after). on the second day group Placebo is treated with a plecabo between measurement 1 and 2. We're seeking for differences placebo vs control that only appear on day two.
here is the rest of my code:
Win = [1 2 1 3];
rm = fitrm(t,'day1_1-day2_2 ~ Group','WithinDesign',Win);
tbl = ranova(rm);
is this correct? Probably not.
Edit: still struggling with that. And we added 'sex' and 'age' to our data. Any comment/help welcome !
Thanks
Dom

回答(1 个)

Aditya
Aditya 2025-1-31,5:40
Hi Dominik,
To analyze the differences between the "Placebo" and "Control" groups on the second day using repeated measures ANOVA, you need to ensure that your within-subjects design and between-subjects factors are correctly specified. With the additional factors like 'sex' and 'age', you can include them as covariates in your model.
% Sample data setup
Group = {'Placebo'; 'Placebo'; 'Control'; 'Placebo'; 'Control'; 'Placebo'; 'Placebo'; 'Placebo'; 'Control'; 'Placebo'; 'Control'; 'Placebo'};
day1_1 = [12.023; 11.806; 11.763; 11.703; 11.558; 13.633; 12.374; 11.476; 12.496; 12.659; 11.611; 12.524];
day1_2 = [12.719; 12.186; 12.008; 11.678; 12.696; 13.253; 12.410; 11.564; 10.661; 12.863; 11.447; 13.700];
day2_1 = [12.110; 12.788; 11.481; 12.073; 13.692; 11.347; 11.490; 12.542; 12.199; 11.844; 12.838; 11.772];
day2_2 = [12.554; 12.164; 13.325; 12.234; 12.732; 12.432; 11.457; 11.112; 12.382; 11.799; 12.592; 11.387];
sex = {'M'; 'F'; 'M'; 'F'; 'M'; 'F'; 'M'; 'F'; 'M'; 'F'; 'M'; 'F'};
age = [30; 32; 28; 35; 40; 29; 31; 33; 37; 34; 36; 38];
% Create a table
t = table(Group, day1_1, day1_2, day2_1, day2_2, sex, age);
% Define the within-subjects design
WithinDesign = table({'day1'; 'day1'; 'day2'; 'day2'}, {'before'; 'after'; 'before'; 'after'}, ...
'VariableNames', {'Day', 'Time'});
% Fit the repeated measures model
rm = fitrm(t, 'day1_1-day2_2 ~ Group + age + sex', 'WithinDesign', WithinDesign);
% Perform repeated measures ANOVA
tbl = ranova(rm);
% Display the results
disp(tbl);
This setup should allow you to investigate the interaction effects and main effects of the treatments, while accounting for covariates like age and sex. Adjust the data and factors as necessary to fit your actual dataset.

类别

Help CenterFile Exchange 中查找有关 Repeated Measures and MANOVA 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by