[R-meta] nesting an inner | outer formula

Viechtbauer, Wolfgang (NP) wo||g@ng@v|echtb@uer @end|ng |rom m@@@tr|chtun|ver@|ty@n|
Mon Feb 24 15:51:04 CET 2025


Hi Ross,

rma.mv() does not have something like the 'group' option, but one should be able to accomplish the same thing with a bit of trickery. In essence, the two levels of Treatment and the three types of informats can be combined into a single variable with 6 levels:

dat$Treatment.Informant <- paste0(dat$Treatment, ".", dat$Informant)

which we then use in 'random' with an unstructured var-cov matrix:

random = ~ Treatment.Informant | StudyID, struct="UN"

This yields a 6x6 var-cov matrix of the random effects. But the model assumes that any covariances/correlations for non-identical informants are zero. So you need to use 'rho = c()' to set these correlations to zero (and use NA to indicate that a correlation should be estimated). See:

https://wviechtb.github.io/metafor/reference/rma.mv.html#fixing-variance-correlation-components

I *think* this should be 'rho = c(NA,0,0,0,0, 0,0,0,0, NA,0,0, 0,0, NA)' but you should double-check this.

This makes the estimation process more complicated, so it might require some pushing and prodding (via different optimizers, optimizer settings, initial values) to get things to converge.

Best,
Wolfgang

> -----Original Message-----
> From: Ross Neville <ross.neville using ucd.ie>
> Sent: Monday, February 24, 2025 11:54
> To: Viechtbauer, Wolfgang (NP) <wolfgang.viechtbauer using maastrichtuniversity.nl>;
> r-sig-meta-analysis using r-project.org
> Subject: nesting an inner | outer formula
>
> Hi Wolfgang
>
> Thanks so much for this detailed response, and for clarifying the current
> position of the metafor package as far as negative variances are concerned.
>
> In the meantime, I have settled on the set of random effects highlighted yellow
> in the proc mixed programme below. I would very much like to be able to
> reproduce this set of random effects and model (as far as possible) in rma.mv.
>
> Here's the full proc mixed programme:
>
> proc mixed covtest data=dat2 cl;
> class StudyID EstimateID Treatment Informant;
> weight InvErr;
> model PostInterventionMean = TreatmentGroup*Informant/noint s cl ddfm=sat
> residual;
> random Treatment/subject=StudyID type=un group=Informant s;
> parms 1 1 1 1 1 1 1 1 1 1/hold=10;
>
> The resulting variance components output provides a variance for each treatment
> group within each study along with their covariance, grouped by informant.
>
> How would such a random effect be programmed in rma.mv?
>
> Appreciate your continued correspondence and support.
>
> Regards
> Ross
>
> On Wed, 19 Feb 2025 at 08:34, Viechtbauer, Wolfgang (NP)
> <mailto:wolfgang.viechtbauer using maastrichtuniversity.nl> wrote:
> Standard errors for variance components are typically not all that useful, since
> the sampling distribution of a variance component estimate is typically not
> normal. One can still obtain them with rma.mv() using cvvc=TRUE (this estimates
> the entire var-cov matrix of the variance/correlation components).
>
> Variance component estimates (and corresponding CIs) are indeed forced to be
> non-negative by rma.mv(). One can get around this to some extent by using an '~
> inner | outer' random effect instead of '~ 1 | outer/inner', since in the former
> the correlation can be negative, which corresponds to a negative variance for
> the outer term in '~ 1 | outer/inner'. See:
>
> https://www.metafor-project.org/doku.php/analyses:konstantopoulos2011
>
> But if you really want negative variances (for all variance components), then
> you will have to use something different than rma.mv(). Allowing for negative
> variances causes so many coding headaches that I decided not to implementing
> this (I do allow for negative tau^2 estimates in rma.uni() but this is a much
> more restricted model space, so handling all the special circumstances around
> negative variances is much easier there).
>
> And yes, I see no inherent problem when a variance component is estimated to be
> essentially zero.
>
> Best,
> Wolfgang


More information about the R-sig-meta-analysis mailing list