Debian Codegraph @

inst/doc/meta-analysis-with-CRVE.R

raw
1 ## ----echo = FALSE, results = "asis", message = FALSE, warning = FALSE---------
2 robu_available <- requireNamespace("robumeta", quietly = TRUE)
3 meta_available <- requireNamespace("metafor", quietly = TRUE)
4
5 knitr::opts_chunk$set(eval = robu_available & meta_available)
6
7 if (!robu_available) cat("## Building this vignette requires the robumeta package. Please install it. {-} \n")
8 if (!meta_available) cat("## Building this vignette requires the metafor package. Please install it. {-} \n")
9
10 ## ----include=FALSE--------------------------------------------------------------------------------
11 options(width = 100)
12
13 ## ----message = FALSE------------------------------------------------------------------------------
14 library(clubSandwich)
15 library(robumeta)
16 data(dropoutPrevention)
17
18 # clean formatting
19 names(dropoutPrevention)[7:8] <- c("eval","implement")
20 levels(dropoutPrevention$eval) <- c("independent","indirect","planning","delivery")
21 levels(dropoutPrevention$implement) <- c("low","medium","high")
22 levels(dropoutPrevention$program_site) <- c("community","mixed","classroom","school")
23 levels(dropoutPrevention$study_design) <- c("matched","unmatched","RCT")
24 levels(dropoutPrevention$adjusted) <- c("no","yes")
25
26 m3_robu <- robu(LOR1 ~ study_design + attrition + group_equivalence + adjusted
27 + outcome + eval + male_pct + white_pct + average_age
28 + implement + program_site + duration + service_hrs,
29 data = dropoutPrevention, studynum = studyID, var.eff.size = varLOR,
30 modelweights = "HIER")
31 print(m3_robu)
32
33 ## -------------------------------------------------------------------------------------------------
34 Wald_test(m3_robu, constraints = constrain_zero(10:12), vcov = "CR2")
35
36 ## -------------------------------------------------------------------------------------------------
37 table(dropoutPrevention$eval)
38
39 ## ----message = FALSE------------------------------------------------------------------------------
40 library(metafor)
41 m3_metafor <- rma.mv(LOR1 ~ study_design + attrition + group_equivalence + adjusted
42 + outcome + eval
43 + male_pct + white_pct + average_age
44 + implement + program_site + duration + service_hrs,
45 V = varLOR, random = list(~ 1 | studyID, ~ 1 | studySample),
46 data = dropoutPrevention)
47 summary(m3_metafor)
48
49 ## -------------------------------------------------------------------------------------------------
50 coef_test(m3_metafor, vcov = "CR2")
51
52 ## -------------------------------------------------------------------------------------------------
53 Wald_test(m3_metafor, constraints = constrain_zero(10:12), vcov = "CR2")
54