2022년 11월 12일 토요일

ch.21 Repeated-Measures ANOVA and Friedman test

easier R than SPSS with Rcmdr : Contents 

ch.21 Repeated-Measures ANOVA and Friedman test


Let’s load the data called ‘depression’ that is contained in the ‘datarium’.


This is a measure of the degree of depression in both groups of ‘ctr’ and ‘treated’, from t0 to t3 as time goes.


Select ‘Repeated-m easures ANOVA’.


Select t0 through t3 (red square) and do not yet specify a group. Test to see if there is a difference over time. It is explained that setting the graph unfortunately does not produce a result (a blue square), and that the graph is not drawn if more than 3 variables are selected. How to create a graph will be explained in a different way later. I choose the Holm method for post-hoc test (pink square).


Since p = 1.965e-12 for Time, along Time values is not the same.


Mauchly Tests for Sphericity is similar to examining equal variance assumptions in ANOPA. Just as ANOVA assumes equal variance, so RMANOVA assumes Sphericity. Since p = 0.0028209<0.05, the Sphericity assumptione is not satisfied, so we will use Greenhouse-Geisser or Huynh-Feldt Corrections. These are respectively p = 7.678e-10, p = 1.027478e-10, so in the end the mean for each point along time is not the same. Therefore, we need to find out by a post-hoc test which pairs are not the same.


Use the paired t-test to compare two groups. t1-t2, t2-t3, t1-t3 are not significant respectively, and t0 is significant to all others.


The nonparametric test for RMANOVA that I just did is the Friedman test.


Enter the same from t0 to t3.



The value of median for each t is presented, which is certainly the highest value at t0 and the rest low. The ‘Friedman (rank sum) test’ results tell us that 4 results are not the same.


Therefore, a post-hoc test is performed using the Wilcoxon signed rank test, a nonparametric test of paired t-test. The interpretation is the same.


Let’s draw a graph that corresponds to this research design. Select the ‘Numerical summaries’ menu as shown above.


Select the variables the same and select all the options.

 

 

They were all well drawn, but the range of axes is different and we can’t compare them.


It also shows the summarized values for each group.


On the other hand, after clicking on the Line graph (repeated measures)


Select the variables and write down the names of the axes.


This will show how the values change over time, and you can clearly see the trend of decreasing and increasing. This is a graph suitable for Friedman test, Repeated Measures ANOVA and paired t-test.


Now let’s go to Repeated-Measures ANOVA and specify the treatment variable as a group.


Not only for time, but also for treatment have achieved significant results. You can see that ‘Factor1.treatment:Time’, that is, the interaction between treatment and time.



I tried a Sphericity test and the p value is small, so I use Greenhouse-Geisser or Huynh-Feldt Corrections as shown earlier. The post-hoc test does a paired t-test. There is no nonparametric test that corresponds to this study design (2 way Repeated-Measures ANOVA).

 

Let’s summarize the data again.


Now let’s sum it up by specifying a group.

 

 

 

Again, the range of the axes is different, so the distribution is difficult to know, but it is clear that the treated is reduced more compared to the ctr.

 

You can also see the summarized data values.

 

Click the Line graph (repeated measures) again.

 

This time, we assign treatment to grouping.

 

The two groups were marked separately, making the situation clearer. You can see that the treated group, marked in red, is clearly located at the bottom, which lowers the score. The red lines are represented by thicker and dotted lines.

 

 Looking at the script, the 2 of col = 1:2 means red. At lty = 1:2 , lty is the line type, 2 represents the dotted line, and at lwd = 1:2 , lwd means that the line width increments the line thickness to 2.

 

So let’s copy the script, and then modify the red part only. where pch = 2 means that the shape is determined by a triangle.

 

You can select the entire script and click ‘submit’ to run it.

 

The thickness and type of the line have changed. In this way, you can modify in the script what you cannot set in the menu.

If you decide to separate the graph from the options,

 

 

You can create a separate plot like this. The difference between the two groups can be clearly observed.

 

Overall, RM ANOVA is somewhat complex, so I introduced it at the back. Unless the research topic is intended to show differences over time, I donot recommend RM ANOVA whenever possible. In other words, it is recommended that the primary outcome should be one point in time, such as the 3rd or 6th month. But even in that case, drawing a graph is a good idea to be prepared to draw as we have now introduced.

I’ve practiced a script method in graph drawing. If you misspell even one of them, you may not be able to write it, which can make scripting very difficult for beginners. However, if you make small changes to the script that is created as it is now, and you can implement it, it will be easy and fun to learn. That’s also an advantage of Rcmdr, which allows you to learn how to script naturally while using Rcmdr.

easier R than SPSS with Rcmdr : Contents

=================================================

  • R data visualization book 2
https://tinyurl.com/R-plot-II-2  simple variables
https://tinyurl.com/R-plot-II-3-4   many variables / map
https://tinyurl.com/R-plot-II-5-6   time related / statistics related
https://tinyurl.com/R-plot-II-7-8   others / reactive chart 
 

 

댓글 없음:

댓글 쓰기