# 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/02/12 15:53]Wolfgang Viechtbauer tips:models_with_or_without_intercept [2021/02/12 16:09] (current)Wolfgang Viechtbauer Both sides previous revision Previous revision 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/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 106: Line 106: &\beta_2 = \mu_s - \mu_a. &\beta_2 = \mu_s - \mu_a. \end{align} \end{align} - But what about the contrast between random and systematic allocation? It turns out that we can obtain this from the model as the difference between the $\beta_1$ and $\beta_2$ coefficients. In particular, if we subtract $\beta_1$ from $\beta_2$, then + But what about the contrast between systematic and random allocation? It turns out that we can obtain this from the model as the difference between the $\beta_1$ and $\beta_2$ coefficients. In particular, if we subtract $\beta_1$ from $\beta_2$, then  \beta_2 - \beta_1 = (\mu_r - \mu_a) - (\mu_s - \mu_a) = \mu_r - \mu_s \beta_2 - \beta_1 = (\mu_r - \mu_a) - (\mu_s - \mu_a) = \mu_r - \mu_s  - so this difference reflects how different random allocation is compared to systematic 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, L=c(0,-1,1)) Line 224: Line 224: - 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. For example, let's test the difference between alternating and random allocation and the difference between systematic allocation 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))) + anova(res, L=rbind(c(-1,1,0),c(-1,0,1), c(0,-1,1))) - Hypotheses: + Hypotheses: - 1:     -factor(alloc)alternate + factor(alloc)random = 0 + 1:     -factor(alloc)alternate + factor(alloc)random = 0 - 2: -factor(alloc)alternate + factor(alloc)systematic = 0 + 2: -factor(alloc)alternate + factor(alloc)systematic = 0 + 3:    -factor(alloc)random + factor(alloc)systematic = 0 Results: Results: - estimate     se    zval   pval + estimate     se    zval   pval - 1:  -0.4478 0.5158 -0.8682 0.3853 + 1:  -0.4478 0.5158 -0.8682 0.3853 - 2:   0.0890 0.5600  0.1590 0.8737 + 2:   0.0890 0.5600  0.1590 0.8737 + 3:   0.5369 0.4364  1.2303 0.2186 + + These are now the exact same results we obtained earlier for the model that included the intercept term. + 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))) + + Omnibus Test of Hypotheses: Omnibus Test of Hypotheses: QM(df = 2) = 1.7675, p-val = 0.4132 QM(df = 2) = 1.7675, p-val = 0.4132 - These are now the exact same results we obtained earlier for the model that included the intercept term. ==== Parameterization ==== ==== Parameterization ====