Skip to content

Instantly share code, notes, and snippets.

@jepusto
Last active August 29, 2015 14:00
Show Gist options
  • Save jepusto/11143798 to your computer and use it in GitHub Desktop.
Save jepusto/11143798 to your computer and use it in GitHub Desktop.
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