-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path12_Forest.R
More file actions
68 lines (61 loc) · 2.27 KB
/
12_Forest.R
File metadata and controls
68 lines (61 loc) · 2.27 KB
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
library(metafor)
library(xlsx)
#############################################
# McLeod 2007 is a dataset I worked with on
# earlier videos. Effect sizes represent
# correlations between
# parenting and child depression
#############################################
McLeodDat <- read.xlsx(file.choose(), sheetName = "Data")
McLeodDat
str(McLeodDat)
McLeodRes1 <- rma(ni = N, ri = r, method = "DL",
measure = "ZCOR", data = McLeodDat)
McLeodRes1
#############################################
# Unsorted forest
#############################################
forest(McLeodRes1)
#############################################
# Sorted by effect size.
# To refer to a variable within a dataset,
# name the dataset, use a dollar sign, then
# name the variable (see below).
##############################################
McLeod.ES <- McLeodDat[order(McLeodDat$r), ]
McLeod.ES
McLeodRes2 <- rma(ni=N, ri=r, method="DL", measure="ZCOR", data=McLeod.ES)
McLeodRes2
forest(McLeodRes2)
##############################################
# Sort by precision
##############################################
McLeod.V <- McLeodDat[order(McLeodDat$v), ]
McLeod.V
McLeodRes3 <- rma(ni = N, ri = r, method = "DL",
measure = "ZCOR", data = McLeod.V)
forest(McLeodRes3)
###############################################
# Sort by moderator, then ES, test for moderator
# forest by moderator and ES with test results
################################################
McLeod.Dx.ES <- McLeodDat[order(McLeodDat$Dx, McLeodDat$r), ]
McLeodRes4 <- rma(ni = N, ri = r, method = "DL",
measure = "ZCOR", mods = ~factor(Dx),
data = McLeod.Dx.ES)
McLeodRes4
forest(McLeodRes4)
################################################
# Rockstuhl data
################################################
RocksDat <- read.xlsx(file.choose(), sheetName="Data")
################################################
# sorted by date
################################################
RocksDat.Yr <- RocksDat[order(RocksDat$Year), ]
RocksRes1 <- rma(ni = N, ri = r, method = "DL",
measure = "ZCOR", data = RocksDat.Yr)
RocksRes1
forest(RocksRes1)
RocksCU <- cumul(RocksRes1, order = order(RocksDat.Yr$Year))
forest(RocksCU)