methods.vif.rma.Rd
Methods for objects of class "vif.rma"
.
# S3 method for class 'vif.rma'
as.data.frame(x, ...)
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
### copy data into 'dat'
dat <- dat.bcg
### calculate log risk ratios and corresponding sampling variances
dat <- escalc(measure="RR", ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat)
### fit mixed-effects meta-regression model
res <- rma(yi, vi, mods = ~ ablat + year + alloc, data=dat)
### get variance inflation factors for all individual coefficients
sav <- vif(res)
sav
#>
#> ablat year allocrandom allocsystematic
#> 1.7697 1.9148 2.0858 2.0193
#>
### turn object into a regular data frame
as.data.frame(sav)
#> coefs m vif sif
#> ablat 2 1 1.769732 1.330313
#> year 3 1 1.914820 1.383770
#> allocrandom 4 1 2.085765 1.444218
#> allocsystematic 5 1 2.019317 1.421027
### get VIFs for ablat and year and the generalized VIF for alloc
sav <- vif(res, btt=list("ablat","alloc","year"))
sav
#>
#> spec coefs m vif sif
#> 1 ablat 2 1 1.7697 1.3303
#> 2 alloc 4:5 2 1.2339 1.0540
#> 3 year 3 1 1.9148 1.3838
#>
### turn object into a regular data frame
as.data.frame(sav)
#> spec coefs m vif sif
#> 1 ablat 2 1 1.769732 1.330313
#> 2 alloc 4:5 2 1.233922 1.053955
#> 3 year 3 1 1.914820 1.383770