tips:models_with_or_without_intercept
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
Previous revisionNext revision | |||
— | tips:models_with_or_without_intercept [2020/10/31 08:46] – Wolfgang Viechtbauer | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ===== Meta-Regression Models With or Without an Intercept ===== | ||
+ | |||
+ | A question that comes up frequently is the proper interpretation of meta-regression models with or without an intercept term. Below I illustrate the difference using the dataset for the BCG vaccine meta-analysis (Colditz et al., 1994). | ||
+ | |||
+ | ==== Model With Intercept ==== | ||
+ | |||
+ | The dataset is called '' | ||
+ | <code rsplus> | ||
+ | library(metafor) | ||
+ | dat <- escalc(measure=" | ||
+ | dat | ||
+ | </ | ||
+ | <code output> | ||
+ | | ||
+ | 1 1 Aronson 1948 4 | ||
+ | 2 2 | ||
+ | 3 3 Rosenthal et al 1960 3 | ||
+ | 4 4 Hart & Sutherland 1977 62 13536 248 12619 52 | ||
+ | 5 5 Frimodt-Moller et al 1973 | ||
+ | 6 6 Stein & Aronson 1953 180 1361 372 1079 44 alternate -0.7861 0.0069 | ||
+ | 7 7 | ||
+ | 8 8 TPT Madras 1980 505 87886 499 87892 13 | ||
+ | 9 9 | ||
+ | 10 10 Rosenthal et al 1961 | ||
+ | 11 11 | ||
+ | 12 12 | ||
+ | 13 13 | ||
+ | </ | ||
+ | Values of the log risk ratio (variable '' | ||
+ | |||
+ | As we can see above, 7 studies used random assignment to determine which study participants would receive the BCG vaccine, 2 studies used alternating assignment (e.g., first person is vaccinated, second person isn't, third person is vaccinated, next person isn't, and so on), and finally 4 studies used systematic assignment (e.g., where assignment to the vaccination group occurred on the basis of the birth year, as in Comstock et al., 1974). | ||
+ | |||
+ | We will now fit a (mixed-effects) meta-regression model to these data, including the method of treatment allocation ('' | ||
+ | <code rsplus> | ||
+ | res <- rma(yi, vi, mods = ~ factor(alloc), | ||
+ | res | ||
+ | </ | ||
+ | <code output> | ||
+ | Mixed-Effects Model (k = 13; tau^2 estimator: REML) | ||
+ | |||
+ | tau^2 (estimated amount of residual heterogeneity): | ||
+ | tau (square root of estimated tau^2 value): | ||
+ | I^2 (residual heterogeneity / unaccounted variability): | ||
+ | H^2 (unaccounted variability / sampling variability): | ||
+ | R^2 (amount of heterogeneity accounted for): 0.00% | ||
+ | |||
+ | Test for Residual Heterogeneity: | ||
+ | QE(df = 10) = 132.3676, p-val < .0001 | ||
+ | |||
+ | Test of Moderators (coefficients 2:3): | ||
+ | QM(df = 2) = 1.7675, p-val = 0.4132 | ||
+ | |||
+ | Model Results: | ||
+ | |||
+ | | ||
+ | intrcpt | ||
+ | factor(alloc)random | ||
+ | factor(alloc)systematic | ||
+ | |||
+ | --- | ||
+ | Signif. codes: | ||
+ | </ | ||
+ | |||
+ | By default, '' | ||
+ | |||
+ | The results given under "Test of Moderators" | ||
+ | |||
+ | We can also test one or multiple model coefficients ourselves (and contrasts between them, as we will see further below) using the '' | ||
+ | <code rsplus> | ||
+ | anova(res, btt=2:3) | ||
+ | </ | ||
+ | <code output> | ||
+ | Test of Moderators (coefficients 2:3): | ||
+ | QM(df = 2) = 1.7675, p-val = 0.4132 | ||
+ | </ | ||
+ | The '' | ||
+ | |||
+ | A different way to conduct the same test is to use the '' | ||
+ | <code rsplus> | ||
+ | anova(res, L=rbind(c(0, | ||
+ | </ | ||
+ | to test the two hypotheses | ||
+ | \begin{align} | ||
+ | &H_0: (0 \times \beta_0) + (1 \times \beta_1) + (0 \times \beta_2) = 0 \; \Leftrightarrow \; \beta_1 = 0 \\ | ||
+ | &H_0: (0 \times \beta_0) + (0 \times \beta_1) + (1 \times \beta_2) = 0 \; \Leftrightarrow \; \beta_2 = 0 | ||
+ | \end{align} | ||
+ | and the output then again includes the omnibus test of both of these two hypotheses: | ||
+ | <code output> | ||
+ | Hypotheses: | ||
+ | 1: | ||
+ | 2: factor(alloc)systematic = 0 | ||
+ | |||
+ | Results: | ||
+ | | ||
+ | 1: -0.4478 0.5158 -0.8682 0.3853 | ||
+ | 2: | ||
+ | |||
+ | Omnibus Test of Hypotheses: | ||
+ | QM(df = 2) = 1.7675, p-val = 0.4132 | ||
+ | </ | ||
+ | |||
+ | As discussed above, the coefficients for '' | ||
+ | \begin{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 | ||
+ | $$ | ||
+ | \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 '' | ||
+ | <code rsplus> | ||
+ | anova(res, L=c(0, | ||
+ | </ | ||
+ | <code output> | ||
+ | Hypothesis: | ||
+ | 1: -factor(alloc)random + factor(alloc)systematic = 0 | ||
+ | |||
+ | Results: | ||
+ | | ||
+ | 1: | ||
+ | |||
+ | Test of Hypothesis: | ||
+ | QM(df = 1) = 1.5137, p-val = 0.2186 | ||
+ | </ | ||
+ | |||
+ | The results of the omnibus test of a factor will be identical regardless of which level is chosen as the reference level. To illustrate this, let's make '' | ||
+ | <code rsplus> | ||
+ | res <- rma(yi, vi, mods = ~ relevel(factor(alloc), | ||
+ | res | ||
+ | </ | ||
+ | <code output> | ||
+ | Mixed-Effects Model (k = 13; tau^2 estimator: REML) | ||
+ | |||
+ | tau^2 (estimated amount of residual heterogeneity): | ||
+ | tau (square root of estimated tau^2 value): | ||
+ | I^2 (residual heterogeneity / unaccounted variability): | ||
+ | H^2 (unaccounted variability / sampling variability): | ||
+ | R^2 (amount of heterogeneity accounted for): 0.00% | ||
+ | |||
+ | Test for Residual Heterogeneity: | ||
+ | QE(df = 10) = 132.3676, p-val < .0001 | ||
+ | |||
+ | Test of Moderators (coefficients 2:3): | ||
+ | QM(df = 2) = 1.7675, p-val = 0.4132 | ||
+ | |||
+ | Model Results: | ||
+ | |||
+ | estimate | ||
+ | intrcpt | ||
+ | alternate | ||
+ | systematic | ||
+ | |||
+ | --- | ||
+ | Signif. codes: | ||
+ | </ | ||
+ | (I shortened the names of the coefficients in the output above to make the table under the '' | ||
+ | |||
+ | ==== Model Without Intercept ==== | ||
+ | |||
+ | Now we will fit the model, but remove the intercept, which can be done with: | ||
+ | <code rsplus> | ||
+ | res <- rma(yi, vi, mods = ~ factor(alloc) - 1, data=dat) | ||
+ | res | ||
+ | </ | ||
+ | <code output> | ||
+ | Mixed-Effects Model (k = 13; tau^2 estimator: REML) | ||
+ | |||
+ | tau^2 (estimated amount of residual heterogeneity): | ||
+ | tau (square root of estimated tau^2 value): | ||
+ | I^2 (residual heterogeneity / unaccounted variability): | ||
+ | H^2 (unaccounted variability / sampling variability): | ||
+ | |||
+ | Test for Residual Heterogeneity: | ||
+ | QE(df = 10) = 132.3676, p-val < .0001 | ||
+ | |||
+ | Test of Moderators (coefficients 1:3): | ||
+ | QM(df = 3) = 15.9842, p-val = 0.0011 | ||
+ | |||
+ | Model Results: | ||
+ | |||
+ | | ||
+ | factor(alloc)alternate | ||
+ | factor(alloc)random | ||
+ | factor(alloc)systematic | ||
+ | |||
+ | --- | ||
+ | Signif. codes: | ||
+ | </ | ||
+ | |||
+ | When we remove the intercept from the model, then all dummy variables are included in the model as predictors. Hence, in this example, each coefficient then reflects the estimated (average) log risk ratio for a particular level (i.e., in the notation used earlier, $\hat{\mu}_a$, | ||
+ | |||
+ | The results given under "Test of Moderators" | ||
+ | \begin{align} | ||
+ | &H_0: \mu_a = 0 \\ | ||
+ | &H_0: \mu_r = 0 \\ | ||
+ | &H_0: \mu_s = 0 | ||
+ | \end{align} | ||
+ | which we can also write more compactly as | ||
+ | $$ | ||
+ | H_0: \mu_a = \mu_r = \mu_s = 0. | ||
+ | $$ | ||
+ | This test is clearly significant ($p = .0011$), which indicates that we can reject the null hypothesis that the (average) log risk ratio is zero for all three methods of allocation. | ||
+ | |||
+ | Again, we could use the '' | ||
+ | <code rsplus> | ||
+ | anova(res, L=rbind(c(1, | ||
+ | </ | ||
+ | <code output> | ||
+ | Hypotheses: | ||
+ | 1: factor(alloc)alternate = 0 | ||
+ | 2: | ||
+ | 3: factor(alloc)systematic = 0 | ||
+ | |||
+ | Results: | ||
+ | | ||
+ | 1: -0.5180 0.4412 -1.1740 0.2404 | ||
+ | 2: -0.9658 0.2672 -3.6138 0.0003 | ||
+ | 3: -0.4289 0.3449 -1.2434 0.2137 | ||
+ | |||
+ | Omnibus Test of Hypotheses: | ||
+ | QM(df = 3) = 15.9842, p-val = 0.0011 | ||
+ | </ | ||
+ | |||
+ | 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: | ||
+ | <code rsplus> | ||
+ | anova(res, L=rbind(c(-1, | ||
+ | </ | ||
+ | <code output> | ||
+ | Hypotheses: | ||
+ | 1: | ||
+ | 2: -factor(alloc)alternate + factor(alloc)systematic = 0 | ||
+ | |||
+ | Results: | ||
+ | | ||
+ | 1: -0.4478 0.5158 -0.8682 0.3853 | ||
+ | 2: | ||
+ | |||
+ | Omnibus Test of Hypotheses: | ||
+ | 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 ==== | ||
+ | |||
+ | 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 ==== | ||
+ | |||
+ | A rather different case arises if the model we are fitting only involves one or multiple continuous moderators. For example, consider the following model: | ||
+ | <code rsplus> | ||
+ | res <- rma(yi, vi, mods = ~ ablat, data=dat) | ||
+ | </ | ||
+ | <code output> | ||
+ | Mixed-Effects Model (k = 13; tau^2 estimator: REML) | ||
+ | |||
+ | tau^2 (estimated amount of residual heterogeneity): | ||
+ | tau (square root of estimated tau^2 value): | ||
+ | I^2 (residual heterogeneity / unaccounted variability): | ||
+ | H^2 (unaccounted variability / sampling variability): | ||
+ | R^2 (amount of heterogeneity accounted for): 75.62% | ||
+ | |||
+ | Test for Residual Heterogeneity: | ||
+ | QE(df = 11) = 30.7331, p-val = 0.0012 | ||
+ | |||
+ | Test of Moderators (coefficient 2): | ||
+ | QM(df = 1) = 16.3571, p-val < .0001 | ||
+ | |||
+ | Model Results: | ||
+ | |||
+ | | ||
+ | intrcpt | ||
+ | ablat | ||
+ | |||
+ | --- | ||
+ | Signif. codes: | ||
+ | </ | ||
+ | Here, the absolute latitude ('' | ||
+ | |||
+ | Now what happens if we remove the intercept? | ||
+ | <code rsplus> | ||
+ | res <- rma(yi, vi, mods = ~ ablat - 1, data=dat) | ||
+ | </ | ||
+ | <code output> | ||
+ | Mixed-Effects Model (k = 13; tau^2 estimator: REML) | ||
+ | |||
+ | tau^2 (estimated amount of residual heterogeneity): | ||
+ | tau (square root of estimated tau^2 value): | ||
+ | I^2 (residual heterogeneity / unaccounted variability): | ||
+ | H^2 (unaccounted variability / sampling variability): | ||
+ | |||
+ | Test for Residual Heterogeneity: | ||
+ | QE(df = 12) = 48.7021, p-val < .0001 | ||
+ | |||
+ | Model Results: | ||
+ | |||
+ | | ||
+ | ablat | ||
+ | |||
+ | --- | ||
+ | Signif. codes: | ||
+ | </ | ||
+ | |||
+ | When the model only includes continuous (i.e., numeric) predictors/ | ||
+ | |||
+ | ==== References ==== | ||
+ | |||
+ | Colditz, G. A., Brewer, T. F., Berkey, C. S., Wilson, M. E., Burdick, E., Fineberg, H. V., et al. (1994). Efficacy of BCG vaccine in the prevention of tuberculosis: | ||
+ | |||
+ | Christensen, | ||
tips/models_with_or_without_intercept.txt · Last modified: 2024/06/12 17:45 by Wolfgang Viechtbauer