Methods for objects of class "matreg".

# S3 method for class 'matreg'
coef(object, ...)
# S3 method for class 'matreg'
vcov(object, ...)

Arguments

object

an object of class "matreg".

...

other arguments.

Details

The coef function extracts the estimated model coefficients from objects of class "matreg". The vcov function extracts the corresponding variance-covariance matrix.

Value

Either a vector with the estimated model coefficients or a variance-covariance matrix.

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

matreg for the function to create matreg objects.

Examples

### fit a regression model with lm() to the 'mtcars' dataset
res <- lm(mpg ~ hp + wt + am, data=mtcars)
coef(res)
#> (Intercept)          hp          wt          am 
#> 34.00287512 -0.03747873 -2.87857541  2.08371013 
vcov(res)
#>              (Intercept)            hp           wt           am
#> (Intercept)  6.983648371  8.169829e-03 -2.110453741 -2.931655806
#> hp           0.008169829  9.226413e-05 -0.006091009 -0.005187758
#> wt          -2.110453741 -6.091009e-03  0.818971675  0.908534063
#> am          -2.931655806 -5.187758e-03  0.908534063  1.894532436

### covariance matrix of the dataset
S <- cov(mtcars)

### fit the same regression model using matreg()
res <- matreg(y="mpg", x=c("hp","wt","am"), R=S, cov=TRUE,
              means=colMeans(mtcars), n=nrow(mtcars))
coef(res)
#>     intrcpt          hp          wt          am 
#> 34.00287512 -0.03747873 -2.87857541  2.08371013 
vcov(res)
#>              intrcpt            hp           wt           am
#> intrcpt  6.983648371  8.169829e-03 -2.110453741 -2.931655806
#> hp       0.008169829  9.226413e-05 -0.006091009 -0.005187758
#> wt      -2.110453741 -6.091009e-03  0.818971675  0.908534063
#> am      -2.931655806 -5.187758e-03  0.908534063  1.894532436