knitr::opts_chunk$set(echo = TRUE)
###install.packages("meta")
library(meta)
## Le chargement a nécessité le package : metabook
## Loading 'meta' package (version 8.5-0).
## Type 'help(meta)' for a brief overview.
data1=read.csv("https://www.uniklinik-freiburg.de/fileadmin/mediapool/08_institute/biometrie-statistik/Dateien/Englisch/Studies_and_Teaching/Educational_Books/Meta-Analysis_with_R/Datasets/dataset01.csv")
data1
## author year Ne Me Se Nc Mc Sc
## 1 Boner 1988 13 13.54 13.85 13 20.77 21.46
## 2 Boner 1989 20 15.70 13.10 20 22.70 16.47
## 3 Chudry 1987 12 21.30 13.10 12 39.70 12.90
## 4 Comis 1993 12 14.50 12.20 12 31.30 15.10
## 5 DeBenedictis 1994a 17 14.40 11.10 17 27.40 17.30
## 6 DeBenedictis 1994b 8 14.80 18.60 8 31.40 20.60
## 7 DeBenedictis 1995 13 15.70 16.80 13 29.60 18.90
## 8 Debelic 1986 12 29.83 15.95 12 48.08 15.08
## 9 Henriksen 1988 12 17.50 13.10 12 47.20 16.47
## 10 Konig 1987 12 12.00 14.60 12 26.20 12.30
## 11 Morton 1992 16 15.83 13.43 16 38.36 18.01
## 12 Novembre 1994f 24 15.42 8.35 24 28.46 13.84
## 13 Novembre 1994s 19 11.00 12.40 19 26.10 14.90
## 14 Oseid 1995 20 14.10 9.50 20 28.90 18.00
## 15 Roberts 1985 9 18.90 17.70 9 38.90 18.90
## 16 Shaw 1985 8 10.27 7.02 8 34.43 10.96
## 17 Todaro 1993 13 10.10 8.90 13 23.50 4.00
m<-metacont(Ne,Me,Se,Nc,Mc,Sc,studlab=paste(author,year),data=data1)
m
## Number of studies: k = 17
## Number of observations: o = 480 (o.e = 240, o.c = 240)
##
## MD 95% CI z p-value
## Common effect model -15.5140 [-17.8435; -13.1845] -13.05 < 0.0001
## Random effects model -15.6470 [-18.1452; -13.1488] -12.28 < 0.0001
##
## Quantifying heterogeneity (with 95% CIs):
## tau^2 = 2.5162 [0.0000; 42.5899]; tau = 1.5862 [0.0000; 6.5261]
## I^2 = 8.9% [0.0%; 45.3%]; H = 1.05 [1.00; 1.35]
##
## Test of heterogeneity:
## Q d.f. p-value
## 17.57 16 0.3496
##
## Details of meta-analysis methods:
## - Inverse variance method
## - Restricted maximum-likelihood estimator for tau^2
## - Q-Profile method for confidence interval of tau^2 and tau
## - Calculation of I^2 based on Q
forest(m,com.random=FALSE,com.fixed=TRUE)

##compute mean of mean effectsize continuous variance mean diff summary (diamond symbolic on forest)
#only with 2 study
data1
## author year Ne Me Se Nc Mc Sc
## 1 Boner 1988 13 13.54 13.85 13 20.77 21.46
## 2 Boner 1989 20 15.70 13.10 20 22.70 16.47
## 3 Chudry 1987 12 21.30 13.10 12 39.70 12.90
## 4 Comis 1993 12 14.50 12.20 12 31.30 15.10
## 5 DeBenedictis 1994a 17 14.40 11.10 17 27.40 17.30
## 6 DeBenedictis 1994b 8 14.80 18.60 8 31.40 20.60
## 7 DeBenedictis 1995 13 15.70 16.80 13 29.60 18.90
## 8 Debelic 1986 12 29.83 15.95 12 48.08 15.08
## 9 Henriksen 1988 12 17.50 13.10 12 47.20 16.47
## 10 Konig 1987 12 12.00 14.60 12 26.20 12.30
## 11 Morton 1992 16 15.83 13.43 16 38.36 18.01
## 12 Novembre 1994f 24 15.42 8.35 24 28.46 13.84
## 13 Novembre 1994s 19 11.00 12.40 19 26.10 14.90
## 14 Oseid 1995 20 14.10 9.50 20 28.90 18.00
## 15 Roberts 1985 9 18.90 17.70 9 38.90 18.90
## 16 Shaw 1985 8 10.27 7.02 8 34.43 10.96
## 17 Todaro 1993 13 10.10 8.90 13 23.50 4.00
data11=subset(data1, year==1988)
#2 study
m11<-metacont(Ne,Me,Se,Nc,Mc,Sc,studlab=paste(author,year),data=data11)
forest(m11,showweights=TRUE, fig.width=10, fig.height=8,com.random=FALSE,com.fixed=TRUE)

#finding EFFECT SIZE diff mean trt effect -20.18 by inverse variance weighting/SIZE OF SQUARE mm^2 SYMBOL
##some check for your hand calculations EFFECT SIZE and SE of MEAN Diff=
m11$TE.fixed
## [1] -20.17762
m11$seTE.fixed
## [1] 4.611491
##BY HAND
v1=13.85^2/13+21.46^2/13
v1
## [1] 50.18108
v2=13.10^2/12+16.47^2/12
v2
## [1] 36.90591
### EFFSIZE GLOBAL IS WEIGHTED SUM OF MEAN DIFF *1/VARi (thes are weights) / SUM (1/VARis ...=of weights)
(13.54-20.77)*1/v1+(17.5-47.20)*1/v2
## [1] -0.9488274
-0.9488274/(1/v1+1/v2)## about 20.18 minus
## [1] -20.17762
#confint for GLOBAL EFFET SIZE OF MEAN DIFF INTERVENTION MINUS CONTROL
-20.17762+c(-1,1)*qnorm(0.975)*sqrt(1/(1/v1+1/v2))#Backfrom invers weighting variance
## [1] -29.21598 -11.13926