# [R-meta] Calculating the covariance structure for multilevel meta-analysis using the raw mean

Viechtbauer Wolfgang (SP) wolfgang.viechtbauer at maastrichtuniversity.nl
Mon Feb 26 15:17:20 CET 2018

```Dear Aki,

For the first case, are the 28 people in row 1 a different group of people than the 30 people in row 2? Then the sampling errors for the two means are independent and you do not have to worry about the covariance.

For the second case (with multiple measurements), I would have assumed that the same group of people was involved in 'measurement1' and 'measurement2' but (assuming no missing data) then the group sizes should be the same, which they are not in your illustrative data. So, then I would have the same question: Are the 28 people involved in 'measurement1' a different group of people than the 30 people involved in 'measurement2'?

Best,
Wolfgang

>-----Original Message-----
>From: R-sig-meta-analysis [mailto:r-sig-meta-analysis-bounces at r-
>project.org] On Behalf Of Akifumi Yanagisawa
>Sent: Monday, 19 February, 2018 14:57
>To: r-sig-meta-analysis at r-project.org
>Subject: [R-meta] Calculating the covariance structure for multilevel
>meta-analysis using the raw mean
>
>Dear all,
>
>I am currently conducting a multilevel meta-analysis with the metafor
>package using the raw mean.
>The following is sample data which describes the characteristics of my
>data. Please note the actual data set includes more studies.
>
>## data structure ##
>dat <- data.frame(
>  id = c(1,2,3,4,5, 6, 7),
>  study = c("study1","study1", "study2", "study2", "study3", "study3",
>"study4"),
>  treatment = c("treatment1","treatment1", "treatment2", "treatment3",
>"treatment3", "treatment4", "treatment4"),
>  mi = c(5.3, 5.1, 2.2, 3.4, 2.5, 5.1, 3.3),
>  sdi = c(1.2, 1.3, 0.5, 3.1, 0.7, 2.1, 0.8),
>  ni = c(28, 30, 20, 20, 42, 43, 120))
>require(metafor)
>dat <- escalc(data = dat, measure = "MN", mi = mi, sdi = sdi, ni = ni)
>dat
>
>As you can see in the above data, some studies examined only one type of
>treatment. I am trying to specify the model using the the following code.
>
>res <- rma.mv (yi, vi, mods = ~ treatment - 1, random = ~treatment |
>study, struct = "DIAG", data = dat)
>
>However, I cannot figure out how to calculate the covariance structure
>for this case, i.e., some studies include only one treatment. I am
>thinking that I probably cannot use the same approach as network meta-
>analysis. I would appreciate it if I could learn how to calculate the
>covariance matrix for this case.
>
>Also, some of the studies measured the outcome using two types of
>measurements. None of these studies reported a correlation between
>measurement 1 and measurement 2. Would it be possible for me to include
>this type of measurement as a factor while somehow specifying the
>covariance matrix for this as well? Or, should I just analyze the data
>separately for each type of measurement?
>
>## data structure 2 ##
>dat <- data.frame(
>  id = c(1,2,3,4,5, 6, 7),
>  study = c("study1","study1", "study2", "study2", "study3", "study3",
>"study4"),
>  treatment = c("treatment1","treatment1", "treatment2", "treatment3",
>"treatment3", "treatment4", "treatment4"),
>  measurement = c("measurement1","measurement2", "measurement1",
>"measurement1", "measurement2", "measurement2", "measurement1"),
>  mi = c(5.3, 5.1, 2.2, 3.4, 2.5, 5.1, 3.3),
>  sdi = c(1.2, 1.3, 0.5, 3.1, 0.7, 2.1, 0.8),
>  ni = c(28, 30, 20, 20, 42, 43, 120))
>dat <- escalc(data = dat, measure = "MN", mi = mi, sdi = sdi, ni = ni)
>res <- rma.mv(data = dat ,yi, vi, mods = ~ treatment + measurement -1,
>random = ~treatment|study, struct = "DIAG”)
>
>Thank you very much for your help,
>Aki
```