# [R-meta] Difference between "GEN" and "UN" in metafor

Viechtbauer, Wolfgang (SP) wo||g@ng@v|echtb@uer @end|ng |rom m@@@tr|chtun|ver@|ty@n|
Fri Aug 20 19:18:05 CEST 2021

```Dear Fred,

See my responses below.

Best,
Wolfgang

>-----Original Message-----
>From: R-sig-meta-analysis [mailto:r-sig-meta-analysis-bounces using r-project.org] On
>Sent: Friday, 20 August, 2021 17:55
>To: R meta
>Subject: [R-meta] Difference between "GEN" and "UN" in metafor
>
>Hello All,
>
>I guess my own question was misplaced when I was answering this question:
>https://stat.ethz.ch/pipermail/r-sig-meta-analysis/2021-August/003079.html.
>
>So, here is my own question for Wolfgang, I understand that for say
>`outcome` with K levels, random = ~ outcome | study, struct="UN" creates
>correlated random effects with K variances and K*(K-1)/2 covariances in
>each `study`.
>
>Also, for struct="UN", `outcome` has to be a factor.

This is likely no longer going to be a requirement in the next version of metafor, that is, variable 'outcome' will automatically be treated as a factor.

>But apparently struct="GEN" can also be used with both numeric and
>non-numeric variables and apparently with multiple variables on the left of
>the vertical bar `|` e.g., `outcome + var2 | id` (not sure if `||` or `
>outcome * var2  | study` are also handled?).

Correct. || and interactions are also possible.

>First, for the same factor variable (say `outcome` a binary one), what is
>the difference in the interpretation of random effects and the correlation
>estimates in:
>
>random = ~  outcome | study, struct="UN"
>
>VERSUS
>
>random = ~  outcome | study, struct="GEN"

The former does something slightly non-standard in that it adds correlated random effects for each outcome level within study, that is, it is really doing:

random = ~  outcome - 1 | study, struct="GEN"

The latter uses standard formula syntax, so it will add a random intercept for studies and a random slope for the outcome level that is not the reference level (and allows the intercept and slope to be correlated).

The fit of these two specifications is the same, but the interpretation of the variances components and correlation differs.

>Second, for a numeric variable (say `AGE`), what is the interpretation of
>random effects and the correlation estimates in:
>
>random = ~ AGE | study, struct="GEN"

Same as in lme(), lmer(), and other packages for multilevel/mixed-effects modelling.

In other words: struct="UN" is really just a special case where (a) one can only specify a single categorical variable on the left of | and (b) the formula gets automatically changed to 'factor(inner) - 1 | outer'. The rest is just completely standard syntax / random-effects modelling.

I added struct="UN" (and some of the simpler structures such as "HCS" and "CS") because they are quite commonly used in the usual 'advanced' meta-analytic models (e.g., as used in a 'standard' multivariate or multilevel model or in network meta-analysis). But you can do everything with struct="GEN" (and more) that struct="UN" gives you - although you cannot adopt a simplified var-cov structure when you use struct="GEN" (like "HCS" or "CS"), except if you use ||, which then is like struct="DIAG".

>Thank you,
>Fred

```