<html><body><div>Thanks Wolfgang,</div><div><br data-mce-bogus="1"></div><div>I have tried your code:</div><div><br></div><div>dat$Site.exp <- as.factor(paste0(dat$Site,".",dat$exp))<br>dat <- dat[order(dat$Site, dat$exp),]<br>calc.v <- function(x) {<br> v <- matrix(x$NPSD^2[1] / (x$NPN[1] * x$NP[1]^2), nrow=nrow(x), ncol=nrow(x))<br> diag(v) <- x$var<br> v<br>}<br>V <- bldiag(lapply(split(dat, dat$Site.exp), calc.v))<br>res <-rma.mv(yi=lnR, V, random=~1|Site/exp/obs, mods=~Predator, data=dat)<br></div><div><br data-mce-bogus="1"></div><div>But I get an error: "'V' must be a symmetric matrix."</div><div><br data-mce-bogus="1"></div><div>The dataset has 297 rows, so V is "num [1:297, 1:297]", which seems symmetric to me. The blocks in V seem to be correct. What do you think is the source of the error?</div><div>Cheers,</div><div>Cesar</div><div><br data-mce-bogus="1"></div><div><br>On March 25, 2020 at 10:25 AM, "Viechtbauer, Wolfgang (SP)" <wolfgang.viechtbauer@maastrichtuniversity.nl> wrote:<br><br></div><div><blockquote type="cite"><div class="msg-quote"><div class="_stretch"><span class="body-text-content">The Berkey code doesn't quite apply here. This is more relevant:<br><br><a href="http://www.metafor-project.org/doku.php/analyses:gleser2009#multiple-treatment_studies" data-mce-href="http://www.metafor-project.org/doku.php/analyses:gleser2009#multiple-treatment_studies">http://www.metafor-project.org/doku.php/analyses:gleser2009#multiple-treatment_studies</a><br><br>But your splitting variable is 'exp' within 'Site', so you need to first create a variable that is the combination of the two. This should do it:<br><br>dat$Site.exp <- paste0(dat$Site, ".", dat$exp)<br><br>Also make sure that the data are sorted accordingly:<br><br>dat <- dat[order(dat$Site, dat$exp),]<br><br>Then:<br><br>calc.v <- function(x) {<br> v <- matrix(x$NPSD^2[1] / (x$NPN[1] * dat$NP[1]^2), nrow=nrow(x), ncol=nrow(x))<br> diag(v) <- x$var<br> v<br>}<br>V <- bldiag(lapply(split(dat, dat$Site.exp), calc.v))<br><br>You should double-check that the blocks in V are correct (with 'var' along the diagonal and the correct covariances along the off-diagonal) before trying to fit the model.<br><br>Best,<br>Wolfgang<br><br>-----Original Message-----<br>From: César Terrer [mailto:cesar.terrer@me.com] <br>Sent: Wednesday, 25 March, 2020 16:21<br>To: Viechtbauer, Wolfgang (SP)<br>Cc: <a href="mailto:r-sig-meta-analysis@r-project.org" data-mce-href="mailto:r-sig-meta-analysis@r-project.org">r-sig-meta-analysis@r-project.org</a><br>Subject: Re: [R-meta] Random effects structure<br><br>Hi Wolfgang,<br><br>Thank you for your quick response.<br><br>I have never constructed a V matrix. Based on the Berkey tutorial, I have tried to apply the following<br><br>dat$v2i <- dat$NPSD^2 / (dat$NPN*dat$NP^2)<br>V <- bldiag(lapply(split(dat[,c("var", "v2i")], dat$exp), as.matrix))<br>res <-rma.mv(yi=lnR, V=V, random=~1|Site/exp/obs, mods=~Predator, data=dat)<br><br>But it gives me an error that 'V' must be a square matrix. Is this because the split in V has to be done at the "obs" level? I used "exp" because that indicates the level at which all effect sizes use the same control.<br><br>Thank you<br>Cesar<br><br>On March 25, 2020 at 7:44 AM, "Viechtbauer, Wolfgang (SP)" <wolfgang.viechtbauer@maastrichtuniversity.nl> wrote:<br>Hi Cesar,<br><br>When the same group is used to compute multiple estimates (i.e., a common control), then this also induces dependency on the sampling errors. For the log response ratio, the covariance is then:<br><br>SD_C^2 / (n_C*M_C^2)<br><br>where M_C and SD_C are the mean and SD of the common control group and n_C the control group size.<br><br>So, you ideally should construct a proper V matrix that includes these covariances and that you can then pass to rma.mv().<br><br>But yes, random=~1|Site/exp/obs would be sensible.<br><br>Best,<br>Wolfgang<br><br>-----Original Message-----<br>From: R-sig-meta-analysis [mailto:r-sig-meta-analysis-bounces@r-project.org] On Behalf Of César Terrer<br>Sent: Wednesday, 25 March, 2020 15:34<br>To: <a href="mailto:r-sig-meta-analysis@r-project.org" data-mce-href="mailto:r-sig-meta-analysis@r-project.org">r-sig-meta-analysis@r-project.org</a><br>Subject: [R-meta] Random effects structure<br><br>Dear community,<br><br>I am conducting a meta-analysis to study the growth rate of bacterial predators as compared to their prey, using the log response ratio. Furthermore, I want to study if this effect varies across different predators. The dataset has the following structure, here showing a subset:<br><br>Site CommonControl exp obs Predator lnR var<br>A Alaska 155 1 1 Bdello -0.6713152 0.03785708<br>A Alaska 155 1 2 Cytoph -0.0702467 0.05763364<br>A Alaska 155 1 3 Myxo -0.148982 0.00748768<br>A Alaska 1510 2 4 Bdello -0.4926361 0.01691187<br>A Alaska 1510 2 5 Cytoph -0.213787 0.01045785<br>B Andesite1controlWeek1 9 6 Bdello 0.27873598 0.14129722<br>B Andesite1controlWeek1 9 7 Cytoph -0.3243682 0.01466085<br>B Andesite1controlWeek1 9 8 Lyso 1.18302506 0.11663149<br>B Andesite1controlWeek6 11 9 Bdello -0.8465128 0.03701618<br>B Andesite1controlWeek6 11 10 Cytoph -0.1559056 0.0283173<br>B Andesite1controlWeek6 11 11 Lyso -0.8039415 0.04926915<br><br>1. There are different sites, thus a potential source of non-independency<br>2. Within each site, we use the value for preys in the denominator multiple times. I guess rows of data using the same denominator (CommonControl) are also potentially correlated and should be also added as a random-effect.<br><br>Based on 1., 2., and what I have understood from the Konstantopoulos (2011) tutorial, I think I should use the following model:<br><br>res <-rma.mv(yi=lnR, V=var, random=~1|Site/exp/obs, mods=~Predator, data=data)<br><br>Could you please let me know if the structure of random effects seems appropriate, and help me understand why I need to include "obs"?<br>Thank you.<br>Cesar<br></span></div></div></blockquote></div></body></html>