Skip to content

Instantly share code, notes, and snippets.

@jepusto

jepusto/RVE-hierarchical.R

Last active Aug 29, 2015
Embed
What would you like to do?
Hierarchical effects example from Tanner-Smith & Tipton (2013)
# 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
You can’t perform that action at this time.