<div dir="ltr"><div><div><div>Dear Michael,<br></div><br></div>That shouldn't be the issue, because I re-compute V after I sorted the rows and before I fitted the model (not showed in my previous email). Please find attached a minimal data-set and reproducible R script illustrating what is going on...<br></div><div><br></div><div>
Thank you very much,<br></div><div>Gabri.<br><br></div><div>PS: yi and vi_Bracken are the 
effect size and sampling variance of log-transformed response ratios obtained via escalc(), respectively.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 22 Aug 2019 at 13:07, Michael Dewey <<a href="mailto:lists@dewey.myzen.co.uk" target="_blank">lists@dewey.myzen.co.uk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Dear Gabriele<br>
<br>
In the code you supply it appears you re-ordered the data but not the V <br>
matrix. Is that the issue? If not can you post a reproducible example <br>
with a minimal data-set and, ideally, using just plain R to manipulate <br>
the data-set so we can see more clearly what the code does.<br>
<br>
Michael<br>
<br>
On 22/08/2019 10:29, Gabriele Midolo wrote:<br>
> Dear all,<br>
> <br>
> I noticed that the results of my <a href="http://rma.mv" rel="noreferrer" target="_blank">rma.mv</a>() model strongly changes when the<br>
> dataframe rows are arranged in a different order. This is new to me and I<br>
> can’t really understand why. I thought it was an issue related to how the V<br>
> matrix get computed (?), but they are actually identical independently from<br>
> rows order in the dataframe… how is a dataframe supposed to be arranged<br>
> before you can trust <a href="http://rma.mv" rel="noreferrer" target="_blank">rma.mv</a>() results then? Thanks.<br>
> <br>
> <br>
> EXAMPLE:<br>
> <br>
> calc.v <- function(x) {<br>
> <br>
>    v <- matrix((x$sdC_imputed[1]^2 / (x$nC[1] * x$C[1]^2)) , nrow=nrow(x),<br>
> ncol=nrow(x))<br>
> <br>
>    diag(v) <- x$vi_Bracken<br>
> <br>
>    v<br>
> <br>
> }<br>
> <br>
> random = ~ 1 | study/ID<br>
> <br>
> <br>
> If I run the following:<br>
> <br>
> <br>
> <br>
> a<-df%>%filter(TRAIT=="LA")<br>
> <br>
> dat<-a%>%mutate(sdC_imputed=sdC)%>%ungroup()<br>
> <br>
> dat<-metagear::impute_SD(dat, "sdC_imputed", "C", method = "Bracken1992")<br>
> <br>
> V <- metafor::bldiag(lapply(split(dat, dat$ctrl_id), calc.v))<br>
> <br>
> m<-<a href="http://rma.mv" rel="noreferrer" target="_blank">rma.mv</a>(yi~dTf,V,data=dat,random = random)<br>
> <br>
> m<br>
> <br>
> <br>
> <br>
> Multivariate Meta-Analysis Model (k = 34; method: REML)<br>
> <br>
> <br>
> <br>
> Variance Components:<br>
> <br>
> <br>
> <br>
>              estim    sqrt  nlvls  fixed    factor<br>
> <br>
> sigma^2.1  0.0000  0.0000      7     no     study<br>
> <br>
> sigma^2.2  0.0607  0.2464     34     no  study/ID<br>
> <br>
> <br>
> <br>
> Test for Residual Heterogeneity:<br>
> <br>
> QE(df = 32) = 1024.8720, p-val < .0001<br>
> <br>
> <br>
> <br>
> Test of Moderators (coefficient 2):<br>
> <br>
> QM(df = 1) = 1.6018, p-val = 0.2056<br>
> <br>
> <br>
> <br>
> Model Results:<br>
> <br>
> <br>
> <br>
>           estimate      se     zval    pval    <a href="http://ci.lb" rel="noreferrer" target="_blank">ci.lb</a>   ci.ub<br>
> <br>
> intrcpt   -0.0786  0.0538  -1.4617  0.1438  -0.1841  0.0268<br>
> <br>
> dTf       -0.0233  0.0184  -1.2656  0.2056  -0.0593  0.0128<br>
> <br>
> <br>
> <br>
> If I run the same code but arrange the dataframe by e.g. the ID of the<br>
> observation via dplyr::arrange(),<br>
> <br>
> a<-df%>%filter(TRAIT=="LA")%>%arrange(ID)<br>
> <br>
> <br>
> Then I get the following output… i.e. a completely different result:<br>
> <br>
> Multivariate Meta-Analysis Model (k = 34; method: REML)<br>
> <br>
> <br>
> <br>
> Variance Components:<br>
> <br>
> <br>
> <br>
>              estim    sqrt  nlvls  fixed    factor<br>
> <br>
> sigma^2.1  0.0000  0.0000      7     no     study<br>
> <br>
> sigma^2.2  0.0336  0.1834     34     no  study/ID<br>
> <br>
> <br>
> <br>
> Test for Residual Heterogeneity:<br>
> <br>
> QE(df = 32) = 334.3701, p-val < .0001<br>
> <br>
> <br>
> <br>
> Test of Moderators (coefficient 2):<br>
> <br>
> QM(df = 1) = 13.9681, p-val = 0.0002<br>
> <br>
> <br>
> <br>
> Model Results:<br>
> <br>
> <br>
> <br>
>           estimate      se     zval    pval    <a href="http://ci.lb" rel="noreferrer" target="_blank">ci.lb</a>    ci.ub<br>
> <br>
> intrcpt   -0.0740  0.0416  -1.7808  0.0749  -0.1554   0.0074    .<br>
> <br>
> dTf       -0.0668  0.0179  -3.7374  0.0002  -0.1019  -0.0318  ***<br>
> <br>
>       [[alternative HTML version deleted]]<br>
> <br>
> _______________________________________________<br>
> R-sig-meta-analysis mailing list<br>
> <a href="mailto:R-sig-meta-analysis@r-project.org" target="_blank">R-sig-meta-analysis@r-project.org</a><br>
> <a href="https://stat.ethz.ch/mailman/listinfo/r-sig-meta-analysis" rel="noreferrer" target="_blank">https://stat.ethz.ch/mailman/listinfo/r-sig-meta-analysis</a><br>
> <br>
> ---<br>
> This email has been checked for viruses by AVG.<br>
> <a href="https://www.avg.com" rel="noreferrer" target="_blank">https://www.avg.com</a><br>
> <br>
> <br>
<br>
-- <br>
Michael<br>
<a href="http://www.dewey.myzen.co.uk/home.html" rel="noreferrer" target="_blank">http://www.dewey.myzen.co.uk/home.html</a><br>
</blockquote></div>