The function computes the weights given to the observed effect sizes or outcomes during the model fitting for objects of class "rma.uni", "rma.mh", "rma.peto", and "rma.mv".

# S3 method for rma.uni
weights(object, type="diagonal", ...)
# S3 method for rma.mh
weights(object, type="diagonal", ...)
# S3 method for rma.peto
weights(object, type="diagonal", ...)
# S3 method for rma.glmm
weights(object, ...)
# S3 method for rma.mv
weights(object, type="diagonal", ...)

## Arguments

object an object of class "rma.uni", "rma.mh", "rma.peto", or "rma.mv". The method is not yet implemented for objects of class "rma.glmm". character string to specify whether to return only the diagonal of the weight matrix ("diagonal") or the entire weight matrix ("matrix"). For "rma.mv", this can also be "rowsum" for ‘row-sum weights’ (for intercept-only models). other arguments.

## Value

Either a vector with the diagonal elements of the weight matrix or the entire weight matrix. When only the diagonal elements are returned, they are given in % (and they add up to 100%).

When the entire weight matrix is requested, this is always a diagonal matrix for objects of class "rma.uni", "rma.mh", "rma.peto".

For "rma.mv", the structure of the weight matrix depends on the model fitted (i.e., the random effects included and the variance-covariance matrix of the sampling errors) but is often more complex and not just diagonal.

For "rma.mv" intercept-only models, one can also take the sum over the rows in the weight matrix, which are actually the weights assigned to the observed effect sizes or outcomes when estimating the model intercept. These weights can be obtained with type="rowsum" (as with type="diagonal", they are also given in %).

## Author

Wolfgang Viechtbauer wvb@metafor-project.org https://www.metafor-project.org

## 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

rma.uni, rma.mh, rma.peto, rma.mv, influence.rma.uni

## 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 mixed-effects model with absolute latitude and publication year as moderators
res <- rma(yi, vi, mods = ~ ablat + year, data=dat)

### extract the model fitting weights (in %)
weights(res)
#>         1         2         3         4         5         6         7         8
#>  3.366420  4.810621  2.791974 11.231203  9.068114 12.481731  4.400814 12.801967
#>         9        10        11        12        13
#>  8.784824  7.991920 11.923841  2.283581  8.062988
### extract the weight matrix
weights(res, type="matrix")
#>           1        2        3        4        5        6        7        8
#> 1  2.291622 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
#> 2  0.000000 3.274732 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
#> 3  0.000000 0.000000 1.900579 0.000000 0.000000 0.000000 0.000000 0.000000
#> 4  0.000000 0.000000 0.000000 7.645413 0.000000 0.000000 0.000000 0.000000
#> 5  0.000000 0.000000 0.000000 0.000000 6.172934 0.000000 0.000000 0.000000
#> 6  0.000000 0.000000 0.000000 0.000000 0.000000 8.496684 0.000000 0.000000
#> 7  0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 2.995765 0.000000
#> 8  0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 8.714678
#> 9  0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
#> 10 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
#> 11 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
#> 12 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
#> 13 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
#>          9       10       11       12       13
#> 1  0.00000 0.000000 0.000000 0.000000 0.000000
#> 2  0.00000 0.000000 0.000000 0.000000 0.000000
#> 3  0.00000 0.000000 0.000000 0.000000 0.000000
#> 4  0.00000 0.000000 0.000000 0.000000 0.000000
#> 5  0.00000 0.000000 0.000000 0.000000 0.000000
#> 6  0.00000 0.000000 0.000000 0.000000 0.000000
#> 7  0.00000 0.000000 0.000000 0.000000 0.000000
#> 8  0.00000 0.000000 0.000000 0.000000 0.000000
#> 9  5.98009 0.000000 0.000000 0.000000 0.000000
#> 10 0.00000 5.440337 0.000000 0.000000 0.000000
#> 11 0.00000 0.000000 8.116912 0.000000 0.000000
#> 12 0.00000 0.000000 0.000000 1.554501 0.000000
#> 13 0.00000 0.000000 0.000000 0.000000 5.488715