tips:models_with_or_without_intercept
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
tips:models_with_or_without_intercept [2020/03/19 14:25] – [Models with Continuous Moderators] Wolfgang Viechtbauer | tips:models_with_or_without_intercept [2021/12/12 13:08] – Wolfgang Viechtbauer | ||
---|---|---|---|
Line 5: | Line 5: | ||
==== Model With Intercept ==== | ==== Model With Intercept ==== | ||
- | The dataset is called '' | + | The dataset is called '' |
<code rsplus> | <code rsplus> | ||
library(metafor) | library(metafor) | ||
Line 76: | Line 76: | ||
The '' | The '' | ||
- | A different way to conduct | + | A different way of conducting |
<code rsplus> | <code rsplus> | ||
- | anova(res, | + | anova(res, |
</ | </ | ||
to test the two hypotheses | to test the two hypotheses | ||
Line 106: | Line 106: | ||
& | & | ||
\end{align} | \end{align} | ||
- | But what about the contrast between | + | But what about the contrast between systematic |
$$ | $$ | ||
\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 | + | so this contrast |
<code rsplus> | <code rsplus> | ||
- | anova(res, | + | anova(res, |
</ | </ | ||
<code output> | <code output> | ||
Line 156: | Line 156: | ||
Signif. codes: | Signif. codes: | ||
</ | </ | ||
- | (I shortened the names of the coefficients in the output above to make the table under the '' | + | (I shortened the names of the coefficients in the output above to make the table under the '' |
==== Model Without Intercept ==== | ==== Model Without Intercept ==== | ||
Line 165: | Line 165: | ||
res | res | ||
</ | </ | ||
+ | Alternatively, | ||
<code output> | <code output> | ||
Mixed-Effects Model (k = 13; tau^2 estimator: REML) | Mixed-Effects Model (k = 13; tau^2 estimator: REML) | ||
Line 206: | Line 207: | ||
Again, we could use the '' | Again, we could use the '' | ||
<code rsplus> | <code rsplus> | ||
- | anova(res, | + | anova(res, |
</ | </ | ||
<code output> | <code output> | ||
Line 224: | Line 225: | ||
</ | </ | ||
- | 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. | + | 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. |
<code rsplus> | <code rsplus> | ||
- | anova(res, | + | anova(res, |
</ | </ | ||
<code output> | <code output> | ||
- | Hypotheses: | + | Hypotheses: |
- | 1: | + | 1: |
- | 2: -factor(alloc)alternate + factor(alloc)systematic = 0 | + | 2: -factor(alloc)alternate |
+ | 3: -factor(alloc)random | ||
Results: | Results: | ||
- | | + | |
- | 1: -0.4478 0.5158 -0.8682 0.3853 | + | 1: -0.4478 0.5158 -0.8682 0.3853 |
- | 2: | + | 2: |
+ | 3: | ||
+ | </ | ||
+ | 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 ('' | ||
+ | <code rsplus> | ||
+ | anova(res, X=rbind(c(-1, | ||
+ | </ | ||
+ | <code output> | ||
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 ==== | ||
- | What the example above shows is that, whether we remove the intercept or not, we are essentially fitting the same model, but using a different [[wp> | + | What the example above shows is that, whether we remove the intercept or not, we are essentially fitting the same model, but using a different [[wp> |
==== Models with Continuous Moderators ==== | ==== Models with Continuous Moderators ==== |
tips/models_with_or_without_intercept.txt · Last modified: 2022/08/03 11:34 by Wolfgang Viechtbauer