The function extracts various types of variance-covariance matrices from objects of class "rma". By default, the variance-covariance matrix of the parameter estimates (fixed effects) is returned.

# S3 method for rma
vcov(object, type="fixed", ...)

Arguments

object

an object of class "rma".

type

character string indicating the type of variance-covariance matrix to return; type="fixed" returns the variance-covariance matrix of the fixed effects (the default), type="obs" returns the marginal variance-covariance matrix of the observed effect sizes or outcomes, type="fitted" returns the variance-covariance matrix of the fitted values, type="resid" returns the variance-covariance matrix of the residuals.

...

other arguments.

Details

Note that type="obs" currently only works for object of class "rma.uni" and "rma.mv".

For objects of class "rma.uni", the marginal variance-covariance matrix is just a diagonal matrix with \(\tau^2 + v_i\) along the diagonal, where \(\tau^2\) is the estimated amount of (residual) heterogeneity (set to 0 in fixed-effects models) and \(v_i\) is the sampling variance of the \(i\)th study.

For objects of class "rma.mv", the structure can be more complex and depends on the types of random effects included in the model.

Value

A matrix corresponding to the requested variance-covariance matrix.

References

Viechtbauer, W. (2010). Conducting meta-analyses in R with the metafor package. Journal of Statistical Software, 36(3), 1--48. http://www.jstatsoft.org/v36/i03/.

See also

Examples

### meta-analysis of the log risk ratios using a mixed-effects model ### with two moderators (absolute latitude and publication year) res <- rma(measure="RR", ai=tpos, bi=tneg, ci=cpos, di=cneg, mods = ~ ablat + year, data=dat.bcg) vcov(res)
#> intrcpt ablat year #> intrcpt 846.5702228 -0.1783751581 -0.4272176864 #> ablat -0.1783752 0.0001047356 0.0000889397 #> year -0.4272177 0.0000889397 0.0002156144
### marginal var-cov matrix of the observed log risk ratios vcov(res, type="obs")
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] #> [1,] 0.4363721 0.0000000 0.0000000 0.0000000 0.0000000 0.000000 0.0000000 #> [2,] 0.0000000 0.3053685 0.0000000 0.0000000 0.0000000 0.000000 0.0000000 #> [3,] 0.0000000 0.0000000 0.5261553 0.0000000 0.0000000 0.000000 0.0000000 #> [4,] 0.0000000 0.0000000 0.0000000 0.1307974 0.0000000 0.000000 0.0000000 #> [5,] 0.0000000 0.0000000 0.0000000 0.0000000 0.1619975 0.000000 0.0000000 #> [6,] 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.117693 0.0000000 #> [7,] 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.000000 0.3338046 #> [8,] 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.000000 0.0000000 #> [9,] 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.000000 0.0000000 #> [10,] 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.000000 0.0000000 #> [11,] 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.000000 0.0000000 #> [12,] 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.000000 0.0000000 #> [13,] 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.000000 0.0000000 #> [,8] [,9] [,10] [,11] [,12] [,13] #> [1,] 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.000000 #> [2,] 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.000000 #> [3,] 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.000000 #> [4,] 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.000000 #> [5,] 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.000000 #> [6,] 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.000000 #> [7,] 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.000000 #> [8,] 0.1147489 0.0000000 0.0000000 0.0000000 0.0000000 0.000000 #> [9,] 0.0000000 0.1672216 0.0000000 0.0000000 0.0000000 0.000000 #> [10,] 0.0000000 0.0000000 0.1838121 0.0000000 0.0000000 0.000000 #> [11,] 0.0000000 0.0000000 0.0000000 0.1231996 0.0000000 0.000000 #> [12,] 0.0000000 0.0000000 0.0000000 0.0000000 0.6432932 0.000000 #> [13,] 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.182192
### var-cov matrix of the fitted values vcov(res, type="fitted")
#> 1 2 3 4 5 #> 1 0.075274494 0.066352321 0.036850236 -2.415804e-02 0.008969395 #> 2 0.066352321 0.072275443 0.039773414 1.147263e-02 -0.008575967 #> 3 0.036850236 0.039773414 0.025624295 1.415547e-02 0.004190524 #> 4 -0.024158035 0.011472626 0.014155473 1.057123e-01 -0.022285939 #> 5 0.008969395 -0.008575967 0.004190524 -2.228594e-02 0.040217694 #> 6 0.058837510 0.055885092 0.032460721 -5.773337e-03 0.005698563 #> 7 0.005895881 -0.004203294 0.006263841 -4.856637e-03 0.031004314 #> 8 -0.014042383 -0.023230087 -0.001954797 3.452639e-03 0.035638528 #> 9 0.018234846 0.012094166 0.013417779 -2.265090e-06 0.021990641 #> 10 0.033562839 0.037679969 0.024746392 1.783241e-02 0.003536357 #> 11 0.003120737 -0.007025518 0.005040385 -4.084581e-03 0.031885711 #> 12 0.011873935 0.014373393 0.014613193 2.110398e-02 0.012123095 #> 13 -0.011137843 -0.000280727 0.008467872 4.684255e-02 0.007543929 #> 6 7 8 9 10 #> 1 0.058837510 0.005895881 -0.014042383 1.823485e-02 0.033562839 #> 2 0.055885092 -0.004203294 -0.023230087 1.209417e-02 0.037679969 #> 3 0.032460721 0.006263841 -0.001954797 1.341778e-02 0.024746392 #> 4 -0.005773337 -0.004856637 0.003452639 -2.265090e-06 0.017832413 #> 5 0.005698563 0.031004314 0.035638528 2.199064e-02 0.003536357 #> 6 0.047790886 0.005293240 -0.009766710 1.579943e-02 0.030251397 #> 7 0.005293240 0.025561416 0.030160616 1.890686e-02 0.006143313 #> 8 -0.009766710 0.030160616 0.041624471 1.858106e-02 -0.001099662 #> 9 0.015799432 0.018906860 0.018581060 1.723057e-02 0.012930696 #> 10 0.030251397 0.006143313 -0.001099662 1.293070e-02 0.024084104 #> 11 0.003151469 0.026348037 0.031928736 1.893374e-02 0.005046532 #> 12 0.013184784 0.013343434 0.013958283 1.365970e-02 0.014875363 #> 13 -0.002280489 0.012499736 0.019944225 1.025012e-02 0.010239343 #> 11 12 13 #> 1 0.003120737 0.01187394 -0.011137843 #> 2 -0.007025518 0.01437339 -0.000280727 #> 3 0.005040385 0.01461319 0.008467872 #> 4 -0.004084581 0.02110398 0.046842555 #> 5 0.031885711 0.01212309 0.007543929 #> 6 0.003151469 0.01318478 -0.002280489 #> 7 0.026348037 0.01334343 0.012499736 #> 8 0.031928736 0.01395828 0.019944225 #> 9 0.018933741 0.01365970 0.010250123 #> 10 0.005046532 0.01487536 0.010239343 #> 11 0.027277130 0.01340221 0.013445239 #> 12 0.013402214 0.01514221 0.016977401 #> 13 0.013445239 0.01697740 0.029377697
### var-cov matrix of the residuals vcov(res, type="resid")
#> 1 2 3 4 5 #> 1 0.361097623 -0.066352321 -0.036850236 2.415804e-02 -0.008969395 #> 2 -0.066352321 0.233093030 -0.039773414 -1.147263e-02 0.008575967 #> 3 -0.036850236 -0.039773414 0.500531022 -1.415547e-02 -0.004190524 #> 4 0.024158035 -0.011472626 -0.014155473 2.508510e-02 0.022285939 #> 5 -0.008969395 0.008575967 -0.004190524 2.228594e-02 0.121779830 #> 6 -0.058837510 -0.055885092 -0.032460721 5.773337e-03 -0.005698563 #> 7 -0.005895881 0.004203294 -0.006263841 4.856637e-03 -0.031004314 #> 8 0.014042383 0.023230087 0.001954797 -3.452639e-03 -0.035638528 #> 9 -0.018234846 -0.012094166 -0.013417779 2.265091e-06 -0.021990641 #> 10 -0.033562839 -0.037679969 -0.024746392 -1.783241e-02 -0.003536357 #> 11 -0.003120737 0.007025518 -0.005040385 4.084581e-03 -0.031885711 #> 12 -0.011873935 -0.014373393 -0.014613193 -2.110398e-02 -0.012123095 #> 13 0.011137843 0.000280727 -0.008467872 -4.684255e-02 -0.007543929 #> 6 7 8 9 10 #> 1 -0.058837510 -0.005895881 0.014042383 -1.823485e-02 -0.033562839 #> 2 -0.055885092 0.004203294 0.023230087 -1.209417e-02 -0.037679969 #> 3 -0.032460721 -0.006263841 0.001954797 -1.341778e-02 -0.024746392 #> 4 0.005773337 0.004856637 -0.003452639 2.265091e-06 -0.017832413 #> 5 -0.005698563 -0.031004314 -0.035638528 -2.199064e-02 -0.003536357 #> 6 0.069902084 -0.005293240 0.009766710 -1.579943e-02 -0.030251397 #> 7 -0.005293240 0.308243183 -0.030160616 -1.890686e-02 -0.006143313 #> 8 0.009766710 -0.030160616 0.073124460 -1.858106e-02 0.001099662 #> 9 -0.015799432 -0.018906860 -0.018581060 1.499910e-01 -0.012930696 #> 10 -0.030251397 -0.006143313 0.001099662 -1.293070e-02 0.159728042 #> 11 -0.003151469 -0.026348037 -0.031928736 -1.893374e-02 -0.005046532 #> 12 -0.013184784 -0.013343434 -0.013958283 -1.365970e-02 -0.014875363 #> 13 0.002280489 -0.012499736 -0.019944225 -1.025012e-02 -0.010239343 #> 11 12 13 #> 1 -0.003120737 -0.01187394 0.011137843 #> 2 0.007025518 -0.01437339 0.000280727 #> 3 -0.005040385 -0.01461319 -0.008467872 #> 4 0.004084581 -0.02110398 -0.046842555 #> 5 -0.031885711 -0.01212309 -0.007543929 #> 6 -0.003151469 -0.01318478 0.002280489 #> 7 -0.026348037 -0.01334343 -0.012499736 #> 8 -0.031928736 -0.01395828 -0.019944225 #> 9 -0.018933741 -0.01365970 -0.010250123 #> 10 -0.005046532 -0.01487536 -0.010239343 #> 11 0.095922436 -0.01340221 -0.013445239 #> 12 -0.013402214 0.62815098 -0.016977401 #> 13 -0.013445239 -0.01697740 0.152814314