-
Notifications
You must be signed in to change notification settings - Fork 1
/
Homwork Excercise week 5.R
54 lines (40 loc) · 1.08 KB
/
Homwork Excercise week 5.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
#Statistics One, Exercise Week 5
#Student t test, ANOVA
#load library
library(psych)
#read table
wm = read.table("supplemental_STATS1.EX.07.txt", header = T)
#Create subset of data for control and training conditions
wm.c = subset(wm, wm$train == "0")
wm.t = subset(wm, wm$train == "1")
wm.c.out = describe(wm.c)
wm.c.out
wm.t.out = describe(wm.t)
wm.t.out
#Dependent t tesst
t.test(wm.c$pre,wm.c$post, paired = T)
t.test(wm.t$pre,wm.t$post, paired = T)
#Cohen's d for dependent t-test.
d.c = (wm.c.out[4,3])/(wm.c.out[4,4])
d.c
d.t = (wm.t.out[4,3])/(wm.t.out[4,4])
d.t
#Independent t-tests
t.test(wm$gain ~ wm$train, var.equal = T)
#the number is df/N
pooled.sd = (79/118 * wm.t.out[4,4]) + (39/118 * wm.c.out[4,4])
d.ct= (wm.t.out[4,3]) - mm.c.out[4,3])/ pooled.sd
d.ct
#ANOVA
aov.model = aov(wm.t$gain ~ wm.t$cond)
summary (aov.model)
aov.table = summary(aov.model)
#Effect size for Anova
ss = aov.table[[1]]$"Sum Sq"
eta.sq = ss[1]/ (ss[1] + ss[2])
eta.sq
#post hoc tests
TurkeyHSD(aov.model)
#Levene's test (test assumption)
library(car)
leveneTest(wm.t$gain, wm.t$cond, center= "mean")