Sie sind auf Seite 1von 8

9/1/2019 Linear Regression and the Mixed-Effects Meta-Regression Model [The metafor Package]

The metafor Package


A Meta-Analysis Package for R

Linear Regression and the Mixed-Effects Meta-Regression Model


The standard linear regression model is given by

yi = β0 + β1 xi1 + β2 xi2 + … + βp xip + ei ,

where ei ∼ N (0, σ )
2
. Models of this sort can be fitted with the R function lm(). The mixed-effects meta-regression model is
given by

yi = β0 + β1 xi1 + β2 xi2 + … + βp xip + ui + ei ,

where ui ∼ N (0, τ 2 ) and ei ∼ N (0, vi ), where vi are the (approximately) known sampling variances of the observed outcomes
or effect size estimates (e.g., standardized mean differences, log odds ratios). Models of this sort can be fitted with the function rma()
from the metafor package.

Consequently, if one were to set vi = 0 for all outcomes, then the standard linear regression model and the mixed-effects meta-
regression model are actually identical (with σ 2 denoting the same parameter as τ 2 ). This equivalence can be demonstrated with an
arbitrary dataset:

library(metafor)
stackloss

Air.Flow Water.Temp Acid.Conc. stack.loss


1 80 27 89 42
2 80 27 88 37
3 75 25 90 37
4 62 24 87 28
5 62 22 87 18
6 62 23 87 18
7 62 24 93 19
8 62 24 93 20
9 58 23 87 15
10 58 18 80 14
11 58 18 89 14
12 58 17 88 13
13 58 18 82 11
14 58 19 93 12
15 50 18 89 8
16 50 18 86 7
17 50 19 72 8
18 50 19 79 8
19 50 20 80 9
20 56 20 82 15
21 70 20 91 15

See help(stackloss) for more details on this dataset. Most importantly, variable stack.loss is the dependent variable with
Air.Flow, Water.Temp, and Acid.Conc serving as potentially relevant predictors.

Now let's fit the standard linear regression model to these data with both the lm() and the rma() functions with:

res.lm <- lm(stack.loss ~ Air.Flow + Water.Temp + Acid.Conc., data=stackloss)

and

http://www.metafor-project.org/doku.php/tips:regression_with_rma 1/3
9/1/2019 Linear Regression and the Mixed-Effects Meta-Regression Model [The metafor Package]
stackloss$vi <- 0
res.rma <- rma(stack.loss, vi, mods = ~ Air.Flow + Water.Temp + Acid.Conc., data=stackloss)

Note that all sampling variances are set to 0 for rma() (the function will actually issue a warning that the dataset includes outcomes
with non-positive sampling variances – which would be rather strange in the meta-analytic context – but this can be safely ignored
here).

We can now compare the output from the two models with:

summary(res.lm)

Call:
lm(formula = stack.loss ~ Air.Flow + Water.Temp + Acid.Conc.,
data = stackloss)

Residuals:
Min 1Q Median 3Q Max
-7.2377 -1.7117 -0.4551 2.3614 5.6978

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -39.9197 11.8960 -3.356 0.00375 **
Air.Flow 0.7156 0.1349 5.307 5.8e-05 ***
Water.Temp 1.2953 0.3680 3.520 0.00263 **
Acid.Conc. -0.1521 0.1563 -0.973 0.34405
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 3.243 on 17 degrees of freedom


Multiple R-squared: 0.9136, Adjusted R-squared: 0.8983
F-statistic: 59.9 on 3 and 17 DF, p-value: 3.016e-09

and

res.rma

Mixed-Effects Model (k = 21; tau^2 estimator: REML)

tau^2 (estimated amount of residual heterogeneity): 10.5194 (SE = 3.6081)


tau (square root of estimated tau^2 value): 3.2434
R^2 (amount of heterogeneity accounted for): 89.83%

Test of Moderators (coefficient(s) 2:4):


QM(df = 3) = 179.7067, p-val < .0001

Model Results:

estimate se zval pval ci.lb ci.ub


intrcpt -39.9197 11.8960 -3.3557 0.0008 -63.2354 -16.6039 ***
Air.Flow 0.7156 0.1349 5.3066 <.0001 0.4513 0.9800 ***
Water.Temp 1.2953 0.3680 3.5196 0.0004 0.5740 2.0166 ***
Acid.Conc. -0.1521 0.1563 -0.9733 0.3304 -0.4585 0.1542

---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

A few things are worth noting:

The estimated model coefficients, corresponding standard errors, and the test statistics are exactly the same. However, lm()
computes the p-values based on the t-distribution, while rma() uses (by default) the standard normal distribution.

The omnibus test of the model coefficients conducted by lm() is an F-test (F-statistic: 59.9 on 3 and 17 DF, p-value:
3.016e-09), while rma() uses by default a chi-square test (QM(df = 3) = 179.7067, p-val < .0001).

The estimated Residual standard error: 3.243 is the same as the estimate of tau: 3.2434.

http://www.metafor-project.org/doku.php/tips:regression_with_rma 2/3
9/1/2019 Linear Regression and the Mixed-Effects Meta-Regression Model [The metafor Package]

The (pseudo) R-squared value reported by rma() (89.83%) actually corresponds to the adjusted R-squared value provided by
lm() (0.8983).

The I 2 and H 2 statistics typically reported by the rma() function are missing, since these statistics cannot be computed
when the dataset includes outcomes with non-positive sampling variances. Similarly, the usually reported results from the Q-
test for heterogeneity are omitted for the same reason.

To get full correspondence between the two models, we can use the 'Knapp & Hartung' method when fitting the model with the
rma() function:

res.rma <- rma(stack.loss, vi, mods = ~ Air.Flow + Water.Temp + Acid.Conc., data=stackloss, test="knha")
res.rma

Mixed-Effects Model (k = 21; tau^2 estimator: REML)

tau^2 (estimated amount of residual heterogeneity): 10.5194 (SE = 3.6081)


tau (square root of estimated tau^2 value): 3.2434
R^2 (amount of heterogeneity accounted for): 89.83%

Test of Moderators (coefficient(s) 2:4):


F(df1 = 3, df2 = 17) = 59.9022, p-val < .0001

Model Results:

estimate se tval pval ci.lb ci.ub


intrcpt -39.9197 11.8960 -3.3557 0.0038 -65.0180 -14.8213 **
Air.Flow 0.7156 0.1349 5.3066 <.0001 0.4311 1.0002 ***
Water.Temp 1.2953 0.3680 3.5196 0.0026 0.5188 2.0717 **
Acid.Conc. -0.1521 0.1563 -0.9733 0.3440 -0.4819 0.1776

---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Now the p-values and the results from the omnibus test of the moderators also match up completely with the output from the lm()
function.

tips/regression_with_rma.txt · Last modified: 2018/11/23 08:58 by Wolfgang Viechtbauer

http://www.metafor-project.org/doku.php/tips:regression_with_rma 3/3
9/1/2019 Regresión lineal y el modelo de metarregresión de efectos mixtos [El paquete metafor]

El paquete metafor
Un paquete de metanálisis para R

Regresión lineal y el modelo de metarregresión de efectos mixtos


El modelo de regresión lineal estándar viene dado por
y

http://www.metafor-project.org/doku.php/tips:regression_with_rma 1/5
9/1/2019 Regresión lineal y el modelo de metarregresión de efectos mixtos [El paquete metafor]

donde e i ∼ N ( 0 , σ
2
) . Los modelos de este tipo pueden ser equipados con la función R lm(). El modelo de
metarregresión de efectos mixtos viene dado por

donde u i ∼ N ( 0 , τ
2
) yei ∼ N ( 0 , v i ) , donde v i son las (aproximadamente) variaciones de muestreo
conocidas de los resultados observados o las estimaciones del tamaño del efecto (por ejemplo, diferencias de medias estandarizadas,
odds ratios de registro). Los modelos de este tipo pueden equiparse con la función rma()del paquete metafor.
http://www.metafor-project.org/doku.php/tips:regression_with_rma 2/5
9/1/2019 Regresión lineal y el modelo de metarregresión de efectos mixtos [El paquete metafor]

En consecuencia, si se tuviera que configurar v i = 0 para todos los resultados, entonces el modelo de regresión lineal estándar y
el modelo de metarregresión de efectos mixtos son en realidad idénticos (con σ 2 que denota el mismo parámetro que τ 2 ). Esta
equivalencia se puede demostrar con un conjunto de datos arbitrario:

biblioteca ( metafor )
stackloss

Aire.Flow Water.Temp Acid.Conc. stack.loss


1 80 27 89 42
2 80 27 88 37
3 75 25 90 37
4 62 24 87 28
5 62 22 87 18
6 62 23 87 18
7 62 24 93 19
8 62 24 93 20
9 58 23 87 15
10 58 18 80 14
11 58 18 89 14
12 58 17 88 13
13 58 18 82 11
14 58 19 93 12
15 50 18 89 8
16 50 18 86 7
17 50 19 72 8
18 50 19 79 8
19 50 20 80 9
20 56 20 82 15
21 70 20 91 15

Ver help(stackloss)para más detalles sobre este conjunto de datos. Lo más importante, la variable stack.losses la variable
dependiente con Air.Flow, Water.Tempy Acid.Concque sirve como predictores potencialmente relevantes.

Ahora vamos a ajustar el modelo de regresión lineal estándar de estos datos, tanto con el lm()y las rma()funciones con:

res.lm <- lm ( stack.loss ~ Air.Flow + Water.Temp + Acid.Conc., data = stackloss )

stackloss $ vi <- 0
res.rma <- rma ( stack.loss, vi, mods = ~ Air.Flow + Water.Temp + Acid.Conc., data = stackloss )

Tenga en cuenta que todas las variaciones de muestreo se establecen en 0 para rma()(la función emitirá en realidad una advertencia de
que el conjunto de datos incluye resultados con variaciones de muestreo no positivas, lo que sería bastante extraño en el contexto
meta-analítico, pero aquí puede ignorarse con seguridad) .

Ahora podemos comparar la salida de los dos modelos con:

resumen ( res.lm )

Llamada:
lm (formula = stack.loss ~ Air.Flow + Water.Temp + Acid.Conc.,
datos = stackloss)

Derechos residuales de autor:


Min 1Q Mediana 3Q Max
-7.2377 -1.7117 -0.4551 2.3614 5.6978

Coeficientes
Estimar Std. Error t valor Pr (> | t |)
(Intercepción) -39.9197 11.8960 -3.356 0.00375 **
Flujo de aire 0.7156 0.1349 5.307 5.8e-05 ***
Water.Temp 1.2953 0.3680 3.520 0.00263 **
Acid.Conc. -0.1521 0.1563 -0.973 0.34405
---
Signif. códigos: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 '' 1

http://www.metafor-project.org/doku.php/tips:regression_with_rma 3/5
9/1/2019 Regresión lineal y el modelo de metarregresión de efectos mixtos [El paquete metafor]

Error estándar residual: 3.243 en 17 grados de libertad


R cuadrado múltiple: 0.9136, R cuadrado ajustado: 0.8983
Estadística F: 59.9 en 3 y 17 DF, valor p: 3.016e-09

res.rma

Modelo de efectos mixtos (k = 21; estimador tau ^ 2: REML)

tau ^ 2 (cantidad estimada de heterogeneidad residual): 10.5194 (SE = 3.6081)


tau (raíz cuadrada del valor tau ^ 2 estimado): 3.2434
R ^ 2 (cantidad de heterogeneidad explicada): 89.83%

Prueba de Moderadores (coeficiente (s) 2: 4):


QM (df = 3) = 179.7067, p-val <.0001

Resultados del modelo:

estimar se zval pval ci.lb ci.ub


intrcpt -39.9197 11.8960 -3.3557 0.0008 -63.2354 -16.6039 ***
Flujo de aire 0.7156 0.1349 5.3066 <.0001 0.4513 0.9800 ***
Water.Temp 1.2953 0.3680 3.5196 0.0004 0.5740 2.0166 ***
Acid.Conc. -0.1521 0.1563 -0.9733 0.3304 -0.4585 0.1542

---
Signif. códigos: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 '' 1

Algunas cosas son dignas de mención:

Los coeficientes del modelo estimado, los errores estándar correspondientes y las estadísticas de prueba son exactamente
iguales. Sin embargo, lm()calcula los valores de p en función de la distribución de t, mientras que rma()utiliza (por defecto) la
distribución normal estándar.

La prueba de ómnibus de los coeficientes del modelo realizada por lm()es una prueba F ( F-statistic: 59.9 on 3 and 17
DF, p-value: 3.016e-09), mientras que rma()utiliza por defecto una prueba de chi-cuadrado ( QM(df = 3) = 179.7067, p-
val < .0001).

El estimado Residual standard error: 3.243es el mismo que el estimado de tau: 3.2434.

El (pseudo) valor de R cuadrado informado por rma()( 89.83%) corresponde en realidad al valor de R cuadrado ajustado
proporcionado por lm()( 0.8983).

El yo 2 y H 2 rma()faltan las estadísticas que normalmente informa la función, ya que estas estadísticas no se pueden
calcular cuando el conjunto de datos incluye resultados con variaciones de muestreo no positivas. Del mismo modo, los
resultados generalmente reportados de la Q-las pruebas de heterogeneidad se omiten por la misma razón.

Para obtener la correspondencia completa entre los dos modelos, podemos utilizar el método 'Knapp & Hartung' cuando ajustamos
el modelo con la rma()función:

res.rma <- rma ( stack.loss, vi, mods = ~ Air.Flow + Water.Temp + Acid.Conc., data = stackloss, test = "knha" )
res.rma

Modelo de efectos mixtos (k = 21; estimador tau ^ 2: REML)

tau ^ 2 (cantidad estimada de heterogeneidad residual): 10.5194 (SE = 3.6081)


tau (raíz cuadrada del valor tau ^ 2 estimado): 3.2434
R ^ 2 (cantidad de heterogeneidad explicada): 89.83%

Prueba de Moderadores (coeficiente (s) 2: 4):


F (df1 = 3, df2 = 17) = 59.9022, p-val <.0001

Resultados del modelo:

http://www.metafor-project.org/doku.php/tips:regression_with_rma 4/5
9/1/2019 Regresión lineal y el modelo de metarregresión de efectos mixtos [El paquete metafor]
estimar se tval pval ci.lb ci.ub
intrcpt -39.9197 11.8960 -3.3557 0.0038 -65.0180 -14.8213 **
Flujo de aire 0.7156 0.1349 5.3066 <.0001 0.4311 1.0002 ***
Water.Temp 1.2953 0.3680 3.5196 0.0026 0.5188 2.0717 **
Acid.Conc. -0.1521 0.1563 -0.9733 0.3440 -0.4819 0.1776

---
Signif. códigos: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 '' 1

Ahora, los valores de p y los resultados de la prueba de ómnibus de los moderadores también coinciden completamente con la salida
de la lm()función.

tips / regression_with_rma.txt · Última modificación: 2018/11/23 08:58 por Wolfgang Viechtbauer

http://www.metafor-project.org/doku.php/tips:regression_with_rma 5/5

Das könnte Ihnen auch gefallen