-
Notifications
You must be signed in to change notification settings - Fork 0
/
powerSection.R
74 lines (52 loc) · 1.96 KB
/
powerSection.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
# Nezlek, J., Mrozinski, B., (2019). Applications of multilevel modeling in psychological science: Intensive repeated measures designs. L'année psychologique. Special Issue (in print).
#
# Supplementary Materials:
# Nezlek, J. B., & Mrozinski, B. (2019, April 7). Applications of multilevel modeling in psychological science: Intensive repeated measures designs. Retrieved from osf.io/74m5r
# Install required libraries
pkgs <- c("lme4", "simr")
install.packages(pkgs, dependencies = T, clean = T)
# Load libraries
library(simr)
# Load data from OSF repository
dataf <- read.csv("Rdataframe.csv", stringsAsFactors = F)
# Model 1
m1 <- lmer(scc ~ naC + (naC|subj), dataf)
summary(m1)
fixef(m1)["naC"] <- -0.15
set.seed(2019)
p1 <- powerCurve(m1, along="subj", nsim=1000, breaks = seq(20, 100, 5))
save(p1, file = "p1.sim")
set.seed(2019)
p2<-powerCurve(m1, along="day", nsim=1000, breaks = seq(3, 14, 1))
save(p2, file = "p2.sim")
# Model 2
m2 <- lmer(scc ~ anxC + (1|subj), dataf)
summary(m2)
fixef(m2)["anxC"] <- 0.05
set.seed(2019)
p3 <- powerCurve(m2, along="subj", nsim=1000, breaks = seq(20, 100, 5))
save(p3, file = "p3.sim")
set.seed(2019)
p4<-powerCurve(m2, along="day", nsim=1000, breaks = seq(3, 14, 1))
save(p4, file = "p4.sim")
# Model 3
m3 <- lmer(tri ~ anxC * negC + (negC|subj), dataf)
summary(m3)
fixef(m3)["anxC:negC"] <- 0.01
set.seed(2019)
p5 <- powerCurve(m3, along="subj", nsim=1000, breaks = seq(20, 100, 5),
test=fixed("anxC:negC"))
save(p5, file = "p5.sim")
set.seed(2019)
p6<-powerCurve(m3, along="day", nsim=1000, breaks = seq(3, 14, 1),
test=fixed("anxC:negC"))
save(p6, file = "p6.sim")
fixef(m3)["anxC:negC"] <- 0.02
set.seed(2019)
p7 <- powerCurve(m3, along="subj", nsim=1000, breaks = seq(20, 100, 5),
test=fixed("anxC:negC"))
save(p7, file = "p7.sim")
set.seed(2019)
p8<-powerCurve(m3, along="day", nsim=1000, breaks = seq(3, 14, 1),
test=fixed("anxC:negC"))
save(p8, file = "p8.sim")