# The metafor Package

A Meta-Analysis Package for R

### Site Tools

tips:multiple_factors_interactions

# Differences

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

 tips:multiple_factors_interactions [2020/06/26 06:49]Wolfgang Viechtbauer tips:multiple_factors_interactions [2022/08/03 11:35] (current)Wolfgang Viechtbauer Both sides previous revision Previous revision 2022/08/03 11:35 Wolfgang Viechtbauer 2021/11/10 20:20 Wolfgang Viechtbauer 2021/10/22 14:44 Wolfgang Viechtbauer 2020/06/26 06:49 Wolfgang Viechtbauer 2018/12/08 13:22 external edit Next revision Previous revision 2022/08/03 11:35 Wolfgang Viechtbauer 2021/11/10 20:20 Wolfgang Viechtbauer 2021/10/22 14:44 Wolfgang Viechtbauer 2020/06/26 06:49 Wolfgang Viechtbauer 2018/12/08 13:22 external edit Line 10: Line 10: dat <- dat.raudenbush1985 dat <- dat.raudenbush1985 - I copy the dataset into 'dat', which is a bit shorter and therefore easier to type further below. + I copy the dataset into ''dat'', which is a bit shorter and therefore easier to type further below. For illustration purposes, we will categorize the ''weeks'' variable (i.e., the number of weeks of contact prior to the expectancy induction) into three levels (0 weeks = "none", 1-9 weeks = "some", and 10+ weeks = "high"): For illustration purposes, we will categorize the ''weeks'' variable (i.e., the number of weeks of contact prior to the expectancy induction) into three levels (0 weeks = "none", 1-9 weeks = "some", and 10+ weeks = "high"): Line 75: Line 75: R^2 (amount of heterogeneity accounted for):            49.85% R^2 (amount of heterogeneity accounted for):            49.85% - Test for Residual Heterogeneity: + Test for Residual Heterogeneity: QE(df = 15) = 24.1362, p-val = 0.0628 QE(df = 15) = 24.1362, p-val = 0.0628 - Test of Moderators (coefficient(s) 2,3,4): + Test of Moderators (coefficient(s) 2,3,4): QM(df = 3) = 9.9698, p-val = 0.0188 QM(df = 3) = 9.9698, p-val = 0.0188 Model Results: Model Results: - estimate      se     zval    pval    ci.lb    ci.ub + estimate      se     zval    pval    ci.lb    ci.ub intrcpt        0.4020  0.1300   3.0924  0.0020   0.1472   0.6567  ** intrcpt        0.4020  0.1300   3.0924  0.0020   0.1472   0.6567  ** weekssome     -0.2893  0.1360  -2.1271  0.0334  -0.5558  -0.0227   * weekssome     -0.2893  0.1360  -2.1271  0.0334  -0.5558  -0.0227   * weekshigh     -0.4422  0.1464  -3.0205  0.0025  -0.7291  -0.1552  ** weekshigh     -0.4422  0.1464  -3.0205  0.0025  -0.7291  -0.1552  ** - testeraware   -0.0511  0.0927  -0.5512  0.5815  -0.2327   0.1305 + testeraware   -0.0511  0.0927  -0.5512  0.5815  -0.2327   0.1305 --- --- Line 109: Line 109: We have also not yet tested whether there is a difference between levels ''some'' and ''high'' of this factor. One could change the reference level of the ''weeks'' factor and refit the model to obtain this test. Alternatively, and more elegantly, we can just test the difference between these two coefficients directly. We can do this with: We have also not yet tested whether there is a difference between levels ''some'' and ''high'' of this factor. One could change the reference level of the ''weeks'' factor and refit the model to obtain this test. Alternatively, and more elegantly, we can just test the difference between these two coefficients directly. We can do this with: - anova(res.a1, L=c(0,1,-1,0)) + anova(res.a1, X=c(0,1,-1,0)) - Hypothesis: + Hypothesis: 1: weekssome - weekshigh = 0 1: weekssome - weekshigh = 0 Line 202: Line 202: H^2 (unaccounted variability / sampling variability):   1.33 H^2 (unaccounted variability / sampling variability):   1.33 - Test for Residual Heterogeneity: + Test for Residual Heterogeneity: QE(df = 15) = 24.1362, p-val = 0.0628 QE(df = 15) = 24.1362, p-val = 0.0628 - Test of Moderators (coefficient(s) 1,2,3,4): + Test of Moderators (coefficient(s) 1,2,3,4): QM(df = 4) = 12.6719, p-val = 0.0130 QM(df = 4) = 12.6719, p-val = 0.0130 Model Results: Model Results: - estimate      se     zval    pval    ci.lb   ci.ub + estimate      se     zval    pval    ci.lb   ci.ub weeksnone      0.4020  0.1300   3.0924  0.0020   0.1472  0.6567  ** weeksnone      0.4020  0.1300   3.0924  0.0020   0.1472  0.6567  ** - weekssome      0.1127  0.0804   1.4021  0.1609  -0.0448  0.2702 + weekssome      0.1127  0.0804   1.4021  0.1609  -0.0448  0.2702 - weekshigh     -0.0402  0.1020  -0.3941  0.6935  -0.2401  0.1597 + weekshigh     -0.0402  0.1020  -0.3941  0.6935  -0.2401  0.1597 - testeraware   -0.0511  0.0927  -0.5512  0.5815  -0.2327  0.1305 + testeraware   -0.0511  0.0927  -0.5512  0.5815  -0.2327  0.1305 --- --- Line 250: Line 250: R^2 (amount of heterogeneity accounted for):            0.00% R^2 (amount of heterogeneity accounted for):            0.00% - Test for Residual Heterogeneity: + Test for Residual Heterogeneity: QE(df = 13) = 23.4646, p-val = 0.0364 QE(df = 13) = 23.4646, p-val = 0.0364 - Test of Moderators (coefficient(s) 2,3,4,5,6): + Test of Moderators (coefficient(s) 2,3,4,5,6): QM(df = 5) = 9.3154, p-val = 0.0971 QM(df = 5) = 9.3154, p-val = 0.0971 Model Results: Model Results: - estimate      se     zval    pval    ci.lb   ci.ub + estimate      se     zval    pval    ci.lb   ci.ub intrcpt                  0.3067  0.1857   1.6518  0.0986  -0.0572  0.6707  . intrcpt                  0.3067  0.1857   1.6518  0.0986  -0.0572  0.6707  . - weekssome               -0.1566  0.2159  -0.7255  0.4682  -0.5797  0.2665 + weekssome               -0.1566  0.2159  -0.7255  0.4682  -0.5797  0.2665 - weekshigh               -0.3267  0.2597  -1.2584  0.2082  -0.8357  0.1822 + weekshigh               -0.3267  0.2597  -1.2584  0.2082  -0.8357  0.1822 - testeraware              0.1759  0.2687   0.6547  0.5127  -0.3508  0.7026 + testeraware              0.1759  0.2687   0.6547  0.5127  -0.3508  0.7026 - weekssome:testeraware   -0.2775  0.3072  -0.9034  0.3663  -0.8795  0.3245 + weekssome:testeraware   -0.2775  0.3072  -0.9034  0.3663  -0.8795  0.3245 - weekshigh:testeraware   -0.2634  0.3435  -0.7667  0.4433  -0.9366  0.4099 + weekshigh:testeraware   -0.2634  0.3435  -0.7667  0.4433  -0.9366  0.4099 --- --- Line 277: Line 277: - Test of Moderators (coefficient(s) 5,6): + Test of Moderators (coefficient(s) 5,6): QM(df = 2) = 0.8576, p-val = 0.6513 QM(df = 2) = 0.8576, p-val = 0.6513 Line 317: Line 317: H^2 (unaccounted variability / sampling variability):   1.73 H^2 (unaccounted variability / sampling variability):   1.73 - Test for Residual Heterogeneity: + Test for Residual Heterogeneity: QE(df = 13) = 23.4646, p-val = 0.0364 QE(df = 13) = 23.4646, p-val = 0.0364 - Test of Moderators (coefficient(s) 1,2,3,4,5,6): + Test of Moderators (coefficient(s) 1,2,3,4,5,6): QM(df = 6) = 11.9111, p-val = 0.0640 QM(df = 6) = 11.9111, p-val = 0.0640 Model Results: Model Results: - estimate      se     zval    pval    ci.lb   ci.ub + estimate      se     zval    pval    ci.lb   ci.ub weeksnone:testerblind    0.3067  0.1857   1.6518  0.0986  -0.0572  0.6707  . weeksnone:testerblind    0.3067  0.1857   1.6518  0.0986  -0.0572  0.6707  . - weekssome:testerblind    0.1502  0.1100   1.3646  0.1724  -0.0655  0.3658 + weekssome:testerblind    0.1502  0.1100   1.3646  0.1724  -0.0655  0.3658 - weekshigh:testerblind   -0.0200  0.1815  -0.1102  0.9122  -0.3757  0.3357 + weekshigh:testerblind   -0.0200  0.1815  -0.1102  0.9122  -0.3757  0.3357 weeksnone:testeraware    0.4827  0.1942   2.4850  0.0130   0.1020  0.8634  * weeksnone:testeraware    0.4827  0.1942   2.4850  0.0130   0.1020  0.8634  * - weekssome:testeraware    0.0486  0.1001   0.4851  0.6276  -0.1477  0.2448 + weekssome:testeraware    0.0486  0.1001   0.4851  0.6276  -0.1477  0.2448 - weekshigh:testeraware   -0.1074  0.1134  -0.9476  0.3433  -0.3296  0.1148 + weekshigh:testeraware   -0.1074  0.1134  -0.9476  0.3433  -0.3296  0.1148 --- --- Line 339: Line 339: Now, the table with the model results directly provides the estimated average effect for each factor level combination. It is now also quite easy to test particular factor level combinations against each other. For example, to test the difference between levels ''some'' and ''high'' of the ''weeks'' factor within the ''blind'' level of the ''tester'' factor, we could use: Now, the table with the model results directly provides the estimated average effect for each factor level combination. It is now also quite easy to test particular factor level combinations against each other. For example, to test the difference between levels ''some'' and ''high'' of the ''weeks'' factor within the ''blind'' level of the ''tester'' factor, we could use: - anova(res.i2, L=c(0,1,-1,0,0,0)) + anova(res.i2, X=c(0,1,-1,0,0,0)) - Hypothesis: + Hypothesis: 1: weekssome:testerblind - weekshigh:testerblind = 0 1: weekssome:testerblind - weekshigh:testerblind = 0 Line 365: Line 365: To test the same contrast within the ''aware'' level of the ''tester'' factor, we would use: To test the same contrast within the ''aware'' level of the ''tester'' factor, we would use: - anova(res.i2, L=c(0,0,0,0,1,-1)) + anova(res.i2, X=c(0,0,0,0,1,-1)) - Hypothesis: + Hypothesis: 1: weekssome:testeraware - weekshigh:testeraware = 0 1: weekssome:testeraware - weekshigh:testeraware = 0 Line 400: Line 400: Linear Hypotheses: Linear Hypotheses: - Estimate Std. Error z value Pr(>|z|) + Estimate Std. Error z value Pr(>|z|) - some:blind - none:blind == 0 -0.15660    0.21585  -0.725  0.46816 + some:blind - none:blind == 0 -0.15660    0.21585  -0.725  0.46816 - high:blind - none:blind == 0 -0.32675    0.25965  -1.258  0.20824 + high:blind - none:blind == 0 -0.32675    0.25965  -1.258  0.20824 - none:aware - none:blind == 0  0.17592    0.26872   0.655  0.51269 + none:aware - none:blind == 0  0.17592    0.26872   0.655  0.51269 - some:aware - none:blind == 0 -0.25818    0.21098  -1.224  0.22105 + some:aware - none:blind == 0 -0.25818    0.21098  -1.224  0.22105 - high:aware - none:blind == 0 -0.41418    0.21757  -1.904  0.05696 . + high:aware - none:blind == 0 -0.41418    0.21757  -1.904  0.05696 . - high:blind - some:blind == 0 -0.17015    0.21223  -0.802  0.42271 + high:blind - some:blind == 0 -0.17015    0.21223  -0.802  0.42271 - none:aware - some:blind == 0  0.33252    0.22324   1.490  0.13635 + none:aware - some:blind == 0  0.33252    0.22324   1.490  0.13635 - some:aware - some:blind == 0 -0.10158    0.14877  -0.683  0.49475 + some:aware - some:blind == 0 -0.10158    0.14877  -0.683  0.49475 - high:aware - some:blind == 0 -0.25759    0.15799  -1.630  0.10302 + high:aware - some:blind == 0 -0.25759    0.15799  -1.630  0.10302 - none:aware - high:blind == 0  0.50267    0.26582   1.891  0.05862 . + none:aware - high:blind == 0  0.50267    0.26582   1.891  0.05862 . - some:aware - high:blind == 0  0.06857    0.20727   0.331  0.74076 + some:aware - high:blind == 0  0.06857    0.20727   0.331  0.74076 - high:aware - high:blind == 0 -0.08744    0.21398  -0.409  0.68282 + high:aware - high:blind == 0 -0.08744    0.21398  -0.409  0.68282 - some:aware - none:aware == 0 -0.43410    0.21852  -1.986  0.04698 * + some:aware - none:aware == 0 -0.43410    0.21852  -1.986  0.04698 * high:aware - none:aware == 0 -0.59010    0.22490  -2.624  0.00869 ** high:aware - none:aware == 0 -0.59010    0.22490  -2.624  0.00869 ** high:aware - some:aware == 0 -0.15601    0.15126  -1.031  0.30235 high:aware - some:aware == 0 -0.15601    0.15126  -1.031  0.30235