-
Notifications
You must be signed in to change notification settings - Fork 0
/
anova_tests.R
157 lines (114 loc) · 3.97 KB
/
anova_tests.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
rm(list=ls())
source('helpers.R')
library(data.table)
library(ggplot2)
library(plyr)
hr=data.frame(read.table("heartrate.txt",header=T,sep='\t'))
hr$State=factor(hr$State,levels=c("sit","walk","run","bike","max"))
en=data.frame(read.table("energy.txt",header=T,sep='\t'))
en$State=factor(en$State,levels=c("sit","walk","run","bike","max"))
#percent difference from gold standard
hr$percentdiff=hr$Error/hr$GoldStandard
en$percentdiff=en$Error/en$GoldStandard
en$percentdiff[en$percentdiff %in% -Inf]=-1
en$percentdiff[en$percentdiff %in% Inf]=1
#HEART RATE
apple=hr[hr$Device %in% "Apple_HR",]
basis=hr[hr$Device %in% "Basis_HR",]
microsoft=hr[hr$Device %in% "Microsoft_HR",]
fitbit=hr[hr$Device %in% "Fitbit_HR",]
samsung=hr[hr$Device %in% "Samsung_HR",]
mio=hr[hr$Device %in% "Mio_HR",]
pulseon=hr[hr$Device %in% "Pulseon_HR",]
#ANOVA SEX
aov1=aov(percentdiff~Sex,data=apple)
tk1=TukeyHSD(aov1,conf.level=0.95)
aov2=aov(percentdiff~Sex,data=basis)
tk2=TukeyHSD(aov2,conf.level=0.95)
aov3=aov(percentdiff~Sex,data=microsoft)
tk3=TukeyHSD(aov3,conf.level=0.95)
aov4=aov(percentdiff~Sex,data=fitbit)
tk4=TukeyHSD(aov4,conf.level=0.95)
aov5=aov(percentdiff~Sex,data=samsung)
tk5=TukeyHSD(aov5,conf.level=0.95)
aov6=aov(percentdiff~Sex,data=mio)
tk6=TukeyHSD(aov6,conf.level=0.95)
aov7=aov(percentdiff~Sex,data=pulseon)
tk7=TukeyHSD(aov7,conf.level=0.95)
#ANOVA ARM
aov1=aov(percentdiff~Arm,data=apple)
tk1=TukeyHSD(aov1,conf.level=0.95)
aov2=aov(percentdiff~Arm,data=basis)
tk2=TukeyHSD(aov2,conf.level=0.95)
aov3=aov(percentdiff~Arm,data=microsoft)
tk3=TukeyHSD(aov3,conf.level=0.95)
aov4=aov(percentdiff~Arm,data=fitbit)
tk4=TukeyHSD(aov4,conf.level=0.95)
aov5=aov(percentdiff~Arm,data=samsung)
tk5=TukeyHSD(aov5,conf.level=0.95)
aov6=aov(percentdiff~Arm,data=mio)
tk6=TukeyHSD(aov6,conf.level=0.95)
aov7=aov(percentdiff~Arm,data=pulseon)
tk7=TukeyHSD(aov7,conf.level=0.95)
#ANOVA POSITION
aov1=aov(percentdiff~Pos,data=apple)
tk1=TukeyHSD(aov1,conf.level=0.95)
aov2=aov(percentdiff~Pos,data=basis)
tk2=TukeyHSD(aov2,conf.level=0.95)
aov3=aov(percentdiff~Pos,data=microsoft)
tk3=TukeyHSD(aov3,conf.level=0.95)
aov4=aov(percentdiff~Pos,data=fitbit)
tk4=TukeyHSD(aov4,conf.level=0.95)
aov5=aov(percentdiff~Pos,data=samsung)
tk5=TukeyHSD(aov5,conf.level=0.95)
aov6=aov(percentdiff~Pos,data=mio)
tk6=TukeyHSD(aov6,conf.level=0.95)
aov7=aov(percentdiff~Pos,data=pulseon)
tk7=TukeyHSD(aov7,conf.level=0.95)
#ENERGY
apple=en[en$Device %in% "Apple_Energy",]
basis=en[en$Device %in% "Basis_Energy",]
microsoft=en[en$Device %in% "Microsoft_Energy",]
fitbit=en[en$Device %in% "Fitbit_Energy",]
pulseon=en[en$Device %in% "PulseOn_Energy",]
#ANOVA SEX
aov1=aov(percentdiff~Sex,data=apple)
tk1=TukeyHSD(aov1,conf.level=0.95)
aov2=aov(percentdiff~Sex,data=basis)
tk2=TukeyHSD(aov2,conf.level=0.95)
aov3=aov(percentdiff~Sex,data=microsoft)
tk3=TukeyHSD(aov3,conf.level=0.95)
aov4=aov(percentdiff~Sex,data=fitbit)
tk4=TukeyHSD(aov4,conf.level=0.95)
aov5=aov(percentdiff~Sex,data=pulseon)
tk5=TukeyHSD(aov5,conf.level=0.95)
p1<-ggplot(basis,aes(Sex,percentdiff))+
geom_boxplot()+
xlab('Biological Sex')+
ylab('Gold Standard Kcal - Basis Kcal/\nGold Standard Kcal')+
ylim(-1,1)+
ggtitle("Basis Energy Percent Error for Males vs Females")+
theme_bw(20)
browser()
#ANOVA ARM
aov1=aov(percentdiff~Arm,data=apple)
tk1=TukeyHSD(aov1,conf.level=0.95)
aov2=aov(percentdiff~Arm,data=basis)
tk2=TukeyHSD(aov2,conf.level=0.95)
aov3=aov(percentdiff~Arm,data=microsoft)
tk3=TukeyHSD(aov3,conf.level=0.95)
aov4=aov(percentdiff~Arm,data=fitbit)
tk4=TukeyHSD(aov4,conf.level=0.95)
aov5=aov(percentdiff~Arm,data=pulseon)
tk5=TukeyHSD(aov5,conf.level=0.95)
#ANOVA POSITION
aov1=aov(percentdiff~Pos,data=apple)
tk1=TukeyHSD(aov1,conf.level=0.95)
aov2=aov(percentdiff~Pos,data=basis)
tk2=TukeyHSD(aov2,conf.level=0.95)
aov3=aov(percentdiff~Pos,data=microsoft)
tk3=TukeyHSD(aov3,conf.level=0.95)
aov4=aov(percentdiff~Pos,data=fitbit)
tk4=TukeyHSD(aov4,conf.level=0.95)
aov5=aov(percentdiff~Pos,data=pulseon)
tk5=TukeyHSD(aov5,conf.level=0.95)