The metafor Package

A Meta-Analysis Package for R

User Tools

Site Tools


tips:models_with_or_without_intercept

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
tips:models_with_or_without_intercept [2021/10/29 10:55] Wolfgang Viechtbauertips:models_with_or_without_intercept [2021/11/10 20:19] Wolfgang Viechtbauer
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:
 <code rsplus> <code rsplus>
-anova(res, L=rbind(c(0,1,0),c(0,0,1)))+anova(res, X=rbind(c(0,1,0),c(0,0,1)))
 </code> </code>
 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
 <code rsplus> <code rsplus>
-anova(res, L=c(0,-1,1))+anova(res, X=c(0,-1,1))
 </code> </code>
 <code output> <code output>
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
 </code> </code>
-(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:
 <code rsplus> <code rsplus>
-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)))
 </code> </code>
 <code output> <code output>
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):
 <code rsplus> <code rsplus>
-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)))
 </code> </code>
 <code output> <code output>
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):
 <code rsplus> <code rsplus>
-anova(res, L=rbind(c(-1,1,0),c(-1,0,1)))+anova(res, X=rbind(c(-1,1,0),c(-1,0,1)))
 </code> </code>
 <code output> <code output>
tips/models_with_or_without_intercept.txt · Last modified: 2022/08/03 11:34 by Wolfgang Viechtbauer