The function can be used to update and (by default) re-fit "rma" models. It does this by extracting the call stored in the object, updating the call and (by default) evaluating that call.

# S3 method for rma
update(object, formula., ..., evaluate=TRUE)

Arguments

object

an object of class "rma".

formula.

changes to the formula. See ‘Details’.

...

additional arguments to the call, or arguments with changed values.

evaluate

logical to specify whether to evaluate the new call or just return the call.

Details

For objects of class "rma.uni", "rma.glmm", and "rma.mv", the formula. argument can be used to update the set of moderators included in the model (see ‘Examples’).

Value

If evaluate=TRUE the fitted object, otherwise the updated call.

Author

The present function is based on update.default, with changes made by Wolfgang Viechtbauer (wvb@metafor-project.org) so that the formula updating works with the (somewhat non-standard) interface of the rma.uni, rma.glmm, and rma.mv functions.

References

Viechtbauer, W. (2010). Conducting meta-analyses in R with the metafor package. Journal of Statistical Software, 36(3), 1–48. https://doi.org/10.18637/jss.v036.i03

See also

rma.uni, rma.mh, rma.peto, rma.glmm, and rma.mv for functions to fit models which can be updated / re-fit.

Examples

### calculate log risk ratios and corresponding sampling variances
dat <- escalc(measure="RR", ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg)

### fit random-effects model (method="REML" is default)
res <- rma(yi, vi, data=dat, digits=3)
res
#> 
#> Random-Effects Model (k = 13; tau^2 estimator: REML)
#> 
#> tau^2 (estimated amount of total heterogeneity): 0.313 (SE = 0.166)
#> tau (square root of estimated tau^2 value):      0.560
#> I^2 (total heterogeneity / total variability):   92.22%
#> H^2 (total variability / sampling variability):  12.86
#> 
#> Test for Heterogeneity:
#> Q(df = 12) = 152.233, p-val < .001
#> 
#> Model Results:
#> 
#> estimate     se    zval   pval   ci.lb   ci.ub      
#>   -0.715  0.180  -3.974  <.001  -1.067  -0.362  *** 
#> 
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#> 

### fit mixed-effects model with two moderators (absolute latitude and publication year)
res <- update(res, ~ ablat + year)
res
#> 
#> Mixed-Effects Model (k = 13; tau^2 estimator: REML)
#> 
#> tau^2 (estimated amount of residual heterogeneity):     0.111 (SE = 0.084)
#> tau (square root of estimated tau^2 value):             0.333
#> I^2 (residual heterogeneity / unaccounted variability): 71.98%
#> H^2 (unaccounted variability / sampling variability):   3.57
#> R^2 (amount of heterogeneity accounted for):            64.63%
#> 
#> Test for Residual Heterogeneity:
#> QE(df = 10) = 28.325, p-val = 0.002
#> 
#> Test of Moderators (coefficients 2:3):
#> QM(df = 2) = 12.204, p-val = 0.002
#> 
#> Model Results:
#> 
#>          estimate      se    zval   pval    ci.lb   ci.ub     
#> intrcpt    -3.546  29.096  -0.122  0.903  -60.572  53.481     
#> ablat      -0.028   0.010  -2.737  0.006   -0.048  -0.008  ** 
#> year        0.002   0.015   0.130  0.897   -0.027   0.031     
#> 
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#> 

### remove 'year' moderator
res <- update(res, ~ . - year)
res
#> 
#> Mixed-Effects Model (k = 13; tau^2 estimator: REML)
#> 
#> tau^2 (estimated amount of residual heterogeneity):     0.076 (SE = 0.059)
#> tau (square root of estimated tau^2 value):             0.276
#> I^2 (residual heterogeneity / unaccounted variability): 68.39%
#> H^2 (unaccounted variability / sampling variability):   3.16
#> R^2 (amount of heterogeneity accounted for):            75.62%
#> 
#> Test for Residual Heterogeneity:
#> QE(df = 11) = 30.733, p-val = 0.001
#> 
#> Test of Moderators (coefficient 2):
#> QM(df = 1) = 16.357, p-val < .001
#> 
#> Model Results:
#> 
#>          estimate     se    zval   pval   ci.lb   ci.ub      
#> intrcpt     0.251  0.249   1.009  0.313  -0.237   0.740      
#> ablat      -0.029  0.007  -4.044  <.001  -0.043  -0.015  *** 
#> 
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#> 

### fit model with ML estimation
update(res, method="ML")
#> 
#> Mixed-Effects Model (k = 13; tau^2 estimator: ML)
#> 
#> tau^2 (estimated amount of residual heterogeneity):     0.034 (SE = 0.028)
#> tau (square root of estimated tau^2 value):             0.185
#> I^2 (residual heterogeneity / unaccounted variability): 49.33%
#> H^2 (unaccounted variability / sampling variability):   1.97
#> R^2 (amount of heterogeneity accounted for):            87.73%
#> 
#> Test for Residual Heterogeneity:
#> QE(df = 11) = 30.733, p-val = 0.001
#> 
#> Test of Moderators (coefficient 2):
#> QM(df = 1) = 28.911, p-val < .001
#> 
#> Model Results:
#> 
#>          estimate     se    zval   pval   ci.lb   ci.ub      
#> intrcpt     0.282  0.187   1.507  0.132  -0.085   0.649      
#> ablat      -0.030  0.005  -5.377  <.001  -0.040  -0.019  *** 
#> 
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#> 

### example with rma.glmm()
res <- rma.glmm(measure="OR", ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg, digits=3)
res <- update(res, mods = ~ ablat)
res
#> 
#> Mixed-Effects Model (k = 13; tau^2 estimator: ML)
#> Model Type: Unconditional Model with Fixed Study Effects
#> 
#> tau^2 (estimated amount of residual heterogeneity):     0
#> tau (square root of estimated tau^2 value):             0
#> I^2 (residual heterogeneity / unaccounted variability): 0.000%
#> H^2 (unaccounted variability / sampling variability):   1.000
#> 
#> Tests for Residual Heterogeneity:
#> Wld(df = 11) = 25.095, p-val = 0.009
#> LRT(df = 11) = 25.014, p-val = 0.009
#> 
#> Test of Moderators (coefficient 2):
#> QM(df = 1) = 143.181, p-val < .001
#> 
#> Model Results:
#> 
#>          estimate     se     zval   pval   ci.lb   ci.ub      
#> intrcpt     0.399  0.082    4.851  <.001   0.238   0.560  *** 
#> ablat      -0.033  0.003  -11.966  <.001  -0.039  -0.028  *** 
#> 
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#> 

### fit conditional model with approximate likelihood
update(res, model="CM.AL")
#> 
#> Mixed-Effects Model (k = 13; tau^2 estimator: ML)
#> Model Type: Conditional Model with Approximate Likelihood
#> 
#> tau^2 (estimated amount of residual heterogeneity):     0.032
#> tau (square root of estimated tau^2 value):             0.179
#> I^2 (residual heterogeneity / unaccounted variability): 45.973%
#> H^2 (unaccounted variability / sampling variability):   1.851
#> 
#> Tests for Residual Heterogeneity:
#> Wld(df = 11) = 29.895, p-val = 0.002
#> LRT(df = 11) = 30.013, p-val = 0.002
#> 
#> Test of Moderators (coefficient 2):
#> QM(df = 1) = 31.169, p-val < .001
#> 
#> Model Results:
#> 
#>          estimate     se    zval   pval   ci.lb   ci.ub      
#> intrcpt     0.293  0.187   1.568  0.117  -0.073   0.659      
#> ablat      -0.030  0.005  -5.583  <.001  -0.040  -0.019  *** 
#> 
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>