簡體   English   中英

縱向研究中的重復測量方差分析

[英]repeated measure anova in longitudinal study

我有一個類似以下的數據集:

Groups  Score1  Score2  Score3
G1      12      19      11
G1      8       2       12
G1      5       4       17
G1      20      17      5
G1      15      3       18
G1      5       9       6
G1      14      13      16
G1      2       7       2
G1      14      1       0
G1      9       19      11
G2      8       11      9
G2      14      7       17
G2      16      10      18
G2      13      9       14
G2      10      15      15
G2      5       1       11
G2      4       16      19
G2      17      14      16
G2      14      13      16
G2      2       0       13
G3      16      13      19
G3      3       12      10
G3      9       4       16
G3      17      3       12
G3      18      4       6
G3      20      1       18
G3      15      17      7
G3      10      16      12
G3      3       12      2
G3      8       2       2

我的目標是比較每個組中的三個分數,並查看第1組的Score1平均值是否與Score2和Score3顯着不同。 並比較各組之間的score1平均值。 並在漂亮的圖表上將所有三個得分(三行)映射到分組因子的水平軸上。 我受制於應該使用哪個R包。 有人可以讓我知道哪個軟件包和功能最好嗎? 謝謝

像這樣嗎

library(reshape2)    # for melt(...)
library(ggplot2)
df.melt <- melt(df, id="Groups", variable.name="Score")
ggplot(df.melt, aes(x=Groups, y=value, color=Score))+
  stat_summary(geom="point", fun.y=mean, position=position_dodge(width=0.5))+
  stat_summary(geom="errorbar", fun.data=mean_cl_normal, width=0.1, position=position_dodge(width=0.5))+
  labs(x="", y="Score")

因此,在這里,我們首先將您的數據集從“寬”格式(不同列中的分數)轉換為“長”格式(一列中的所有得分,第二列Score ,指示每一行屬於哪個集合)。 我們使用ggplot繪制平均得分(使用stat_summary(fun.y=mean,...)和+/- 95%CL(使用stat_summary(fun.data=mean_cl_normal,...) 。格式。

您可能會認為,由於每個組和每個分數的95%CL重疊,因此沒有一個分數/組與任何其他分數/組有所不同。 但這是誤導。 例如,如果我們進行t檢驗比較第2組的得分2和3,

with(df[df$Groups=="G2",],t.test(Score2,Score3))
#   Welch Two Sample t-test
# 
# data:  Score2 and Score3
# t = -2.5857, df = 14.184, p-value = 0.0214
# alternative hypothesis: true difference in means is not equal to 0
# 95 percent confidence interval:
#  -9.5080934 -0.8919066
# sample estimates:
# mean of x mean of y 
#       9.6      14.8 

我們可以看到這兩個分數在大約98%的水平上有所不同。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM