The metafor Package

A Meta-Analysis Package for R

User Tools

Site Tools


tips:rma_vs_lm_lme_lmer

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
tips:rma_vs_lm_lme_lmer [2021/11/08 13:31] Wolfgang Viechtbauertips:rma_vs_lm_lme_lmer [2022/08/03 11:37] Wolfgang Viechtbauer
Line 42: Line 42:
 I^2 (total heterogeneity / total variability):   60.69% I^2 (total heterogeneity / total variability):   60.69%
 H^2 (total variability / sampling variability):  2.54 H^2 (total variability / sampling variability):  2.54
-                                                                                                                          + 
-Test for Heterogeneity:                                                                                                  +Test for Heterogeneity:
 Q(df = 15) = 38.1595, p-val = 0.0009 Q(df = 15) = 38.1595, p-val = 0.0009
  
 Model Results: Model Results:
  
-estimate      se    zval    pval   ci.lb   ci.ub  +estimate      se    zval    pval   ci.lb   ci.ub 
-  0.1252  0.0170  7.3642  <.0001  0.0919  0.1585  *** +  0.1252  0.0170  7.3642  <.0001  0.0919  0.1585  ***
  
 --- ---
Line 65: Line 65:
  
 Weighted Residuals: Weighted Residuals:
-    Min      1Q  Median      3Q     Max  +    Min      1Q  Median      3Q     Max 
--3.1919 -1.0719  0.6674  1.3173  2.4695 +-3.1919 -1.0719  0.6674  1.3173  2.4695
  
 Coefficients: Coefficients:
-            Estimate Std. Error t value Pr(>|t|)    +            Estimate Std. Error t value Pr(>|t|)
 (Intercept)  0.12518    0.02711   4.617 0.000335 *** (Intercept)  0.12518    0.02711   4.617 0.000335 ***
 --- ---
Line 84: Line 84:
 This can be demonstrated by extracting the estimated error variance from the ''lm'' object, multiplying the sampling variances by that value, and re-fitting the model with the ''rma()'' function: This can be demonstrated by extracting the estimated error variance from the ''lm'' object, multiplying the sampling variances by that value, and re-fitting the model with the ''rma()'' function:
 <code rsplus> <code rsplus>
-rma(yi, vi*summary(res.lm)$sigma^2, data=dat, method="EE")+rma(yi, vi*sigma(res.lm)^2, data=dat, method="EE")
 </code> </code>
 <code output> <code output>
Line 135: Line 135:
 H^2 (total variability / sampling variability):  2.61 H^2 (total variability / sampling variability):  2.61
  
-Test for Heterogeneity: +Test for Heterogeneity:
 Q(df = 15) = 38.1595, p-val = 0.0009 Q(df = 15) = 38.1595, p-val = 0.0009
  
 Model Results: Model Results:
  
-estimate       se     zval     pval    ci.lb    ci.ub           +estimate       se     zval     pval    ci.lb    ci.ub 
-  0.1499   0.0316   4.7501   <.0001   0.0881   0.2118      *** +  0.1499   0.0316   4.7501   <.0001   0.0881   0.2118      ***
  
 --- ---
Line 156: Line 156:
 <code output> <code output>
 Linear mixed-effects model fit by REML Linear mixed-effects model fit by REML
- Data: dat + Data: dat
         AIC       BIC   logLik         AIC       BIC   logLik
   -8.781569 -6.657418 7.390784   -8.781569 -6.657418 7.390784
Line 167: Line 167:
 Variance function: Variance function:
  Structure: fixed weights  Structure: fixed weights
- Formula: ~vi  + Formula: ~vi 
-Fixed effects: yi ~ 1 +Fixed effects: yi ~ 1
                 Value  Std.Error DF  t-value p-value                 Value  Std.Error DF  t-value p-value
 (Intercept) 0.1415557 0.03071906 16 4.608073   3e-04 (Intercept) 0.1415557 0.03071906 16 4.608073   3e-04
  
 Standardized Within-Group Residuals: Standardized Within-Group Residuals:
-       Min         Q1        Med         Q3        Max  +       Min         Q1        Med         Q3        Max 
--1.1596768 -0.6903414  0.1964221  0.7117538  1.4616798 +-1.1596768 -0.6903414  0.1964221  0.7117538  1.4616798
  
 Number of Observations: 16 Number of Observations: 16
Line 183: Line 183:
 <code rsplus> <code rsplus>
 library(lme4) library(lme4)
-res.lmer <- lmer(yi ~ 1 + (1 | study), weights = 1/vi, data=dat, +res.lmer <- lmer(yi ~ 1 + (1 | study), weights = 1/vi, data=dat,
                  control=lmerControl(check.nobs.vs.nlev="ignore", check.nobs.vs.nRE="ignore"))                  control=lmerControl(check.nobs.vs.nlev="ignore", check.nobs.vs.nRE="ignore"))
 summary(res.lmer) summary(res.lmer)
Line 192: Line 192:
    Data: dat    Data: dat
 Weights: 1/vi Weights: 1/vi
-Control: +Control:
 lmerControl(check.nobs.vs.nlev = "ignore", check.nobs.vs.nRE = "ignore") lmerControl(check.nobs.vs.nlev = "ignore", check.nobs.vs.nRE = "ignore")
  
 REML criterion at convergence: -14.8 REML criterion at convergence: -14.8
  
-Scaled residuals:  +Scaled residuals: 
-    Min      1Q  Median      3Q     Max  +    Min      1Q  Median      3Q     Max 
--1.1597 -0.6903  0.1964  0.7117  1.4617 +-1.1597 -0.6903  0.1964  0.7117  1.4617
  
 Random effects: Random effects:
  Groups   Name        Variance Std.Dev.  Groups   Name        Variance Std.Dev.
- study    (Intercept) 0.004649 0.06818  + study    (Intercept) 0.004649 0.06818 
- Residual             1.586461 1.25955 + Residual             1.586461 1.25955
 Number of obs: 16, groups:  study, 16 Number of obs: 16, groups:  study, 16
  
Line 232: Line 232:
 H^2 (total variability / sampling variability):  1.58 H^2 (total variability / sampling variability):  1.58
  
-Test for Heterogeneity: +Test for Heterogeneity:
 Q(df = 15) = 24.0532, p-val = 0.0642 Q(df = 15) = 24.0532, p-val = 0.0642
  
 Model Results: Model Results:
  
-estimate       se     zval     pval    ci.lb    ci.ub           +estimate       se     zval     pval    ci.lb    ci.ub 
-  0.1416   0.0307   4.6081   <.0001   0.0813   0.2018      *** +  0.1416   0.0307   4.6081   <.0001   0.0813   0.2018      ***
  
 --- ---
Line 266: Line 266:
 <code output> <code output>
 Linear mixed-effects model fit by REML Linear mixed-effects model fit by REML
- Data: dat  + Data: dat 
-        AIC      BIC   logLik +        AIC      BIC   logLik
   -10.44653 -9.03043 7.223265   -10.44653 -9.03043 7.223265
  
 Random effects: Random effects:
  Formula:  ~ 1 | study  Formula:  ~ 1 | study
-        (Intercept) Residual +        (Intercept) Residual
 StdDev:  0.09005302        1 StdDev:  0.09005302        1
  
 Variance function: Variance function:
  Structure: fixed weights  Structure: fixed weights
- Formula:  ~ vi  + Formula:  ~ vi 
-Fixed effects: yi ~ 1  +Fixed effects: yi ~ 1 
-                Value  Std.Error DF  t-value p-value +                Value  Std.Error DF  t-value p-value
 (Intercept) 0.1499171 0.03155994 16 4.750234  0.0002 (Intercept) 0.1499171 0.03155994 16 4.750234  0.0002
  
 Standardized Within-Group Residuals: Standardized Within-Group Residuals:
-       Min         Q1        Med        Q3      Max +       Min         Q1        Med        Q3      Max
  -1.222824 -0.5462851 0.09989517 0.6159687 1.305632  -1.222824 -0.5462851 0.09989517 0.6159687 1.305632
  
tips/rma_vs_lm_lme_lmer.txt · Last modified: 2023/11/14 08:00 by Wolfgang Viechtbauer