################################################### # # # Amlodipine Example # # # # Effect size: standardized mean difference # # # # Use of R packages: meta and metafor # ################################################### # # Data in the first group (sample size, mean, and variance n1 <- c( 46, 30, 75, 12, 32, 31, 27, 46) x1 <- c(0.2316, 0.2811, 0.1894, 0.0930, 0.1622, 0.1837, 0.6612, 0.1366) vari1 <- c(0.2254, 0.1441, 0.1981, 0.1389, 0.0961, 0.1246, 0.7060, 0.1211) # # Data in the second group (sample size, mean, and variance n2 <- c( 48, 26, 72, 12, 34, 31, 27, 47) x2 <- c(-0.0027, 0.0270, 0.0443, 0.2277, 0.0056, 0.0943, -0.0057, -0.0057) vari2 <- c( 0.0007, 0.1139, 0.4972, 0.0488, 0.0955, 0.1734, 0.9891, 0.1291) # # Total sample size n <- n1 + n2 # # Standardized mean difference and estimate of the variance s.xi <- ( (n1-1) * vari1 + (n2-1) * vari2) / (n1 + n2 -2) # pooled variance theta.bias <- (x1 - x2) / sqrt(s.xi) # biased estimate theta <- (1 - 3/(4 * n - 9)) * theta.bias # nearly unbiased estimate xi <- n / (n1 * n2) + theta^2 /(2*n) # variance estimate # #################### # # # R package: meta # # # #################### library(meta) meta.smd.1 <- metagen(theta, sqrt(xi)) meta.smd.2 <- metacont(n1, x1, sqrt(vari1), n2, x2, sqrt(vari2), sm="SMD") # ###################################################### # # # R package: metafor # # # # Choice between "LS"=large sample and "UB"=unbiased # # # ###################################################### library(metafor) metafor.smd.1 <- rma.uni(yi=theta, sei=sqrt(xi)) metafor.smd.2 <- rma.uni(n1i=n1, n2i=n2, m1i=x1, m2i=x2, sd1i=sqrt(vari1), sd2i=sqrt(vari2), measure="SMD", vtype="LS") metafor.smd.3 <- rma.uni(n1i=n1, n2i=n2, m1i=x1, m2i=x2, sd1i=sqrt(vari1), sd2i=sqrt(vari2), measure="SMD", vtype="UB") # ################################# # # # Comparison of results # # # ################################# # # Using standardized mean difference plus estimated standard error summary(meta.smd.1) summary(metafor.smd.1) # # Using sample means, sample variance, and sample size summary(meta.smd.2) summary(metafor.smd.2) summary(metafor.smd.3)