-
-
Save Yefeng0920/17145b41838da47954a22b489ff87d84 to your computer and use it in GitHub Desktop.
Hierarchical effects example from Tanner-Smith & Tipton (2013)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# robumeta calculations | |
library(grid) | |
library(robumeta) | |
data(hierdat) | |
HTJ <- robu(effectsize ~ males + binge, | |
data = hierdat, modelweights = "HIER", | |
studynum = studyid, | |
var.eff.size = var, small = FALSE) | |
HTJ | |
# reproduce using metafor | |
source("R/metafor-sandwich.R") # See https://gist.github.com/jepusto/11144005 | |
hierdat$var_HTJ <- hierdat$var + HTJ$omega.sq + HTJ$tau.sq | |
meta1 <- rma.mv(yi = effectsize ~ males + binge, | |
V = var_HTJ, | |
data = hierdat, method = "FE") | |
meta1$cluster <- hierdat$studyid | |
RobustResults(meta1) | |
# difference in weighting in the metafor model | |
meta2 <- rma.mv(yi = effectsize ~ males + binge, | |
V = var, random = list(~ 1 | esid, ~ 1 | studyid), | |
sigma2 = c(HTJ$omega.sq, HTJ$tau.sq), | |
data = hierdat) | |
RobustResults(meta2) | |
# estimate the variance components in metafor | |
meta3 <- rma.mv(yi = effectsize ~ males + binge, | |
V = var, random = list(~ 1 | esid, ~ 1 | studyid), | |
data = hierdat, | |
method = "REML") | |
meta3 | |
RobustResults(meta3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment