# The metafor Package

A Meta-Analysis Package for R

### Site Tools

tips:models_with_or_without_intercept

# Differences

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

 tips:models_with_or_without_intercept [2021/10/29 10:55]Wolfgang Viechtbauer tips:models_with_or_without_intercept [2021/11/10 20:19] (current)Wolfgang Viechtbauer Both sides previous revision Previous revision 2021/11/10 20:19 Wolfgang Viechtbauer 2021/10/29 10:55 Wolfgang Viechtbauer 2021/02/12 16:09 Wolfgang Viechtbauer 2021/02/12 15:53 Wolfgang Viechtbauer 2020/10/31 08:46 Wolfgang Viechtbauer 2020/03/19 14:25 Wolfgang Viechtbauer [Models with Continuous Moderators] 2020/03/19 14:22 Wolfgang Viechtbauer 2019/06/30 11:43 external edit 2021/11/10 20:19 Wolfgang Viechtbauer 2021/10/29 10:55 Wolfgang Viechtbauer 2021/02/12 16:09 Wolfgang Viechtbauer 2021/02/12 15:53 Wolfgang Viechtbauer 2020/10/31 08:46 Wolfgang Viechtbauer 2020/03/19 14:25 Wolfgang Viechtbauer [Models with Continuous Moderators] 2020/03/19 14:22 Wolfgang Viechtbauer 2019/06/30 11:43 external edit Line 78: Line 78: A different way of conducting the same test is to use the ''L'' argument, which allows us to specify one or more vectors of numbers, which are multiplied with the model coefficients. In particular, we can use: A different way of conducting the same test is to use the ''L'' argument, which allows us to specify one or more vectors of numbers, which are multiplied with the model coefficients. In particular, we can use: - anova(res, L=rbind(c(0,1,0),c(0,0,1))) + anova(res, X=rbind(c(0,1,0),c(0,0,1))) to test the two hypotheses to test the two hypotheses Line 112: Line 112: so this contrast reflects how different systematic allocation is compared to random allocation. Using the ''anova()'' function, we can obtain this contrast with so this contrast reflects how different systematic allocation is compared to random allocation. Using the ''anova()'' function, we can obtain this contrast with - anova(res, L=c(0,-1,1)) + anova(res, X=c(0,-1,1)) Line 156: Line 156: Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 - (I shortened the names of the coefficients in the output above to make the table under the ''Model Results'' more readable). Now the intercept reflects the estimated (average) log risk ratio for random allocation, while the coefficients for ''alternate'' and ''systematic'' are again contrasts of these two levels compared to random allocation. Note how the coefficient for systematic allocation is the same as we obtained earlier using ''anova(res, L=c(0,-1,1))''. Moreover, as we can see in the output, the results for the omnibus test of these two coefficients is identical to what we obtained earlier. + (I shortened the names of the coefficients in the output above to make the table under the ''Model Results'' more readable). Now the intercept reflects the estimated (average) log risk ratio for random allocation, while the coefficients for ''alternate'' and ''systematic'' are again contrasts of these two levels compared to random allocation. Note how the coefficient for systematic allocation is the same as we obtained earlier using ''anova(res, X=c(0,-1,1))''. Moreover, as we can see in the output, the results for the omnibus test of these two coefficients is identical to what we obtained earlier. ==== Model Without Intercept ==== ==== Model Without Intercept ==== Line 206: Line 206: Again, we could use the ''anova()'' function to carry out explicitly the same test with: Again, we could use the ''anova()'' function to carry out explicitly the same test with: - anova(res, L=rbind(c(1,0,0),c(0,1,0),c(0,0,1))) + anova(res, X=rbind(c(1,0,0),c(0,1,0),c(0,0,1))) Line 226: Line 226: It is important to realize that this does not test whether there are differences between the different forms of allocation (this is what we tested earlier in the model that included the intercept term). However, we can again use contrasts of the model coefficients to test differences between the levels. Let's test all pairwise differences (i.e., between random and alternating allocation, between systematic and alternating allocation, and between systematic and random allocation): It is important to realize that this does not test whether there are differences between the different forms of allocation (this is what we tested earlier in the model that included the intercept term). However, we can again use contrasts of the model coefficients to test differences between the levels. Let's test all pairwise differences (i.e., between random and alternating allocation, between systematic and alternating allocation, and between systematic and random allocation): - anova(res, L=rbind(c(-1,1,0),c(-1,0,1), c(0,-1,1))) + anova(res, X=rbind(c(-1,1,0),c(-1,0,1), c(0,-1,1))) Line 244: Line 244: Note that the output does not contain an omnibus test for the three contrasts because the matrix with the contrast coefficients (''L'' above) is not of full rank (i.e., one of the three contrasts is redundant). If we only include two of the three contrasts (again, it does not matter which two), then we also get the omnibus test (rest of the output omitted): Note that the output does not contain an omnibus test for the three contrasts because the matrix with the contrast coefficients (''L'' above) is not of full rank (i.e., one of the three contrasts is redundant). If we only include two of the three contrasts (again, it does not matter which two), then we also get the omnibus test (rest of the output omitted): - anova(res, L=rbind(c(-1,1,0),c(-1,0,1))) + anova(res, X=rbind(c(-1,1,0),c(-1,0,1))) 