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 revision
Previous revision
Last revisionBoth sides next revision
tips:models_with_or_without_intercept [2021/11/10 20:19] Wolfgang Viechtbauertips:models_with_or_without_intercept [2024/06/12 17:45] Wolfgang Viechtbauer
Line 162: Line 162:
 Now we will fit the model, but remove the intercept, which can be done with: Now we will fit the model, but remove the intercept, which can be done with:
 <code rsplus> <code rsplus>
-res <- rma(yi, vi, mods = ~ factor(alloc) - 1, data=dat)+res <- rma(yi, vi, mods = ~ 0 + factor(alloc), data=dat)
 res res
 </code> </code>
 +Alternatively, one could use ''mods = ~ factor(alloc) - 1'' to remove the intercept. In either case, the output is then:
 <code output> <code output>
 Mixed-Effects Model (k = 13; tau^2 estimator: REML) Mixed-Effects Model (k = 13; tau^2 estimator: REML)
Line 217: Line 218:
    estimate     se    zval   pval    estimate     se    zval   pval
 1:  -0.5180 0.4412 -1.1740 0.2404 1:  -0.5180 0.4412 -1.1740 0.2404
-2:  -0.9658 0.2672 -3.6138 0.0003+2:  -0.9658 0.2672 -3.6138 0.0003 ***
 3:  -0.4289 0.3449 -1.2434 0.2137 3:  -0.4289 0.3449 -1.2434 0.2137
  
Line 229: Line 230:
 </code> </code>
 <code output> <code output>
-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 +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 3:   0.5369 0.4364  1.2303 0.2186
 </code> </code>
Line 289: Line 290:
 Now what happens if we remove the intercept? Now what happens if we remove the intercept?
 <code rsplus> <code rsplus>
-res <- rma(yi, vi, mods = ~ ablat - 1, data=dat)+res <- rma(yi, vi, mods = ~ 0 + ablat, data=dat)
 </code> </code>
 <code output> <code output>
tips/models_with_or_without_intercept.txt · Last modified: 2024/06/18 19:29 by Wolfgang Viechtbauer