-
Notifications
You must be signed in to change notification settings - Fork 0
/
redundancy_analysis.R
97 lines (78 loc) · 3.57 KB
/
redundancy_analysis.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
library(lsmeans)
library(emmeans)
library(ARTool)
library(phia)
library(lme4)
library(lmerTest)
library(car)
library(multcomp)
library(reshape2)
library(rstatix)
library(plyr)
library(ez)
library(dplyr)
library(xtable)
library(ggpubr)
######### Load data: Non redun, individual #########
df = read.csv("data/redundancy.csv")
View(df)
df$condition = factor(df$condition) # convert to nominal factor
df$roundID = factor(df$roundID) # convert to nominal factor
summary(df)
# correlation test
x=df$ego_ego_overlap
y=df$Non_redun
cor.test(x, y, method=c("pearson", "kendall", "spearman"))
x=df$ego_ego_overlap
y=df$CQ
cor.test(x, y, method=c("pearson", "kendall", "spearman"))
x=df$ego_alter_overlap
y=df$Non_redun
cor.test(x, y, method=c("pearson", "kendall", "spearman"))
x=df$ego_alter_overlap
y=df$CQ
cor.test(x, y, method=c("pearson", "kendall", "spearman"))
# Kruskal-Wallis test
kruskal_test(ego_ego_overlap ~ condition, data=df, distribution="asymptotic") # can't do exact with 3 levels
nrow(df) # for reporting Kruskal-Wallis as chi-square, we can get N with nrow(ide3)
# manual post hoc Mann-Whitney U pairwise comparisons
# note: wilcox_test we used above doesn't take two data vectors, so use wilcox.test
b.s = wilcox.test(df[df$condition == "control",]$ego_ego_overlap, df[df$condition == "real",]$ego_ego_overlap, exact=FALSE)
b.p = wilcox.test(df[df$condition == "control",]$ego_ego_overlap, df[df$condition == "mid",]$ego_ego_overlap, exact=FALSE)
b.n = wilcox.test(df[df$condition == "control",]$ego_ego_overlap, df[df$condition == "reverse",]$ego_ego_overlap, exact=FALSE)
s.p = wilcox.test(df[df$condition == "real",]$ego_ego_overlap, df[df$condition == "mid",]$ego_ego_overlap, exact=FALSE)
s.n = wilcox.test(df[df$condition == "real",]$ego_ego_overlap, df[df$condition == "reverse",]$ego_ego_overlap, exact=FALSE)
p.n = wilcox.test(df[df$condition == "mid",]$ego_ego_overlap, df[df$condition == "reverse",]$ego_ego_overlap, exact=FALSE)
p.adjust(c(b.s$p.value, b.p$p.value, b.n$p.value, s.p$p.value, s.n$p.value, p.n$p.value), method="holm")
b.s
b.p
b.n
s.p
s.n
p.n
summary(df[df$condition == "control",])
summary(df[df$condition == "real",])
summary(df[df$condition == "mid",])
summary(df[df$condition == "reverse",])
# Kruskal-Wallis test
kruskal_test(ego_alter_overlap ~ condition, data=df, distribution="asymptotic") # can't do exact with 3 levels
nrow(df) # for reporting Kruskal-Wallis as chi-square, we can get N with nrow(ide3)
# manual post hoc Mann-Whitney U pairwise comparisons
# note: wilcox_test we used above doesn't take two data vectors, so use wilcox.test
b.s = wilcox.test(df[df$condition == "control",]$ego_alter_overlap, df[df$condition == "real",]$ego_alter_overlap, exact=FALSE)
b.p = wilcox.test(df[df$condition == "control",]$ego_alter_overlap, df[df$condition == "mid",]$ego_alter_overlap, exact=FALSE)
b.n = wilcox.test(df[df$condition == "control",]$ego_alter_overlap, df[df$condition == "reverse",]$ego_alter_overlap, exact=FALSE)
s.p = wilcox.test(df[df$condition == "real",]$ego_alter_overlap, df[df$condition == "mid",]$ego_alter_overlap, exact=FALSE)
s.n = wilcox.test(df[df$condition == "real",]$ego_alter_overlap, df[df$condition == "reverse",]$ego_alter_overlap, exact=FALSE)
p.n = wilcox.test(df[df$condition == "mid",]$ego_alter_overlap, df[df$condition == "reverse",]$ego_alter_overlap, exact=FALSE)
p.adjust(c(b.s$p.value, b.p$p.value, b.n$p.value, s.p$p.value, s.n$p.value, p.n$p.value), method="holm")
b.s
b.p
b.n
s.p
s.n
p.n
summary(df[df$condition == "control",])
summary(df[df$condition == "real",])
summary(df[df$condition == "mid",])
summary(df[df$condition == "reverse",])