"multcompare" assigns data to non-existing data groups
4 ビュー (過去 30 日間)
古いコメントを表示
I am trying to understand the overall effects of 3 different variables "speed", "pulse" and humidifier" on my dependent variable "Displacement". Similar to the example (https://fr.mathworks.com/help/stats/multcompare.html) given under "Multiple Comparisons for Three-Way ANOVA", I have my response vector "Displacement" and grouping factors: "speed", "pulse" and "humidifier", all of which are 1561x1 doubles. At my four different speeds, I have four different treatment groups (pulse =1, humidifier =1; pulse =1, humidifier =2; pulse =2, humidifier =1; pulse =2, humidifier =2), apart from speed=5 where I only have two (pulse =1, humidifier =1; pulse =1, humidifier =2). In this way, I am dealing with 14 different treatment groups.
However, as evident from the figure, the multcomp creates 16 different groups, including "speed=5,pulse=2,humidifier=1 & speed=5,pulse=2,humidifier=2", both which do not exist and can not reasonable be made up from the values which I provide in the grouping factors. In the N-Way ANOVA, each row of the response vector "Displacement" is associated with the value provided in the same row number in each grouping factor. Indeed, when I horizontally concatenate the 3 grouping factors, I see that there are no rows with the combinations "speed=5,pulse=2,humidifier=1 & speed=5,pulse=2,humidifier=2", yet this group is created and is assigned data. What data of mine is assigned to these non-existing groups and how should I go about solving these issues?
% % Test for overall effects of speed, pulse and humidifier.
varnames = {'speed'; 'pulse' ; 'humidifier'}
[p,table,stats] = anovan(Displacement,{speed pulse humidifier},1,3,varnames);
[results,~,~,gnames] = multcompare(stats,"Dimension",[1 2 3]);% multiple pairwise comparisons with tukey's HSD

0 件のコメント
回答 (1 件)
Garmit Pant
2023 年 9 月 20 日
Hello Roy
It is my understanding that you are trying to perform 3 way ANOVA and then compare the results between the treatment groups. The data that you are working with only has 14 treatment groups but the output of the function ‘multcompare’ has results for 16 different groups.
You are using the function 'anovan' to perform the 3 way ANOVA test. By default, the function 'anovan' uses the linear model for performing the test. The default 'linear' model computes only the p-values for the null hypotheses on the N main effects individually. Thus, p-values for all the independent variables are available and the function 'multcompare' performs the Tukey Multiple Comparison test which compares the difference between each pair of means with appropriate adjustment for the multiple testing.
To test and compare the results for the effects of interactions at all the levels, you need to set the 'model' name-value argument of the 'anovan' function as 'full'. You can refer to following code snippet to see the output when the argument ‘model is set as ‘full’:
y = [52.7 57.5 45.9 44.5 53.0 57.0 45.9 44.0]';
g1 = [1 2 1 2 1 2 1 2];
g2 = ["hi" "hi" "lo" "hi" "hi" "hi" "lo" "hi"];
g3 = ["may" "may" "may" "may" "june" "june" "june" "june"];
[~,tbl,stats] = anovan(y,{g1 g2 g3},"model","full","Varnames",["g1","g2","g3"]);
[results,~,~,gnames] = multcompare(stats,"Dimension",[1 2 3]);
In the code snippet above, the treatment groups (g1=1,g2='lo',g3='may') and (g1=1,g2='lo',g3='june') do not exist and thus they do not appear in the output of the function 'multcompare'.
For further understanding, you can refer the following MathWorks Documentation:
https://www.mathworks.com/help/stats/anovan.html - Refer to the 'Name-Value Arguments' in the 'Input Arguments' section.
I hope this helps!
Best Regards,
Garmit
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Analysis of Variance and Covariance についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

