Various extractor functions for objects of class "matreg".

# S3 method for class 'matreg'
coef(object, ...)
# S3 method for class 'matreg'
vcov(object, ...)
# S3 method for class 'matreg'
sigma(object, REML=TRUE, ...)

# S3 method for class 'matreg'
logLik(object, REML=FALSE, ...)
# S3 method for class 'matreg'
AIC(object, ..., k=2, correct=FALSE, REML=FALSE)
# S3 method for class 'matreg'
BIC(object, ..., REML=FALSE)

# S3 method for class 'matreg'
confint(object, parm, level, digits, ...)
# S3 method for class 'confint.matreg'
print(x, digits=x$digits, ...)

Arguments

object

an object of class "matreg".

REML

logical whether the returned value should be based on ML or REML estimation.

k

numeric value to specify the penalty per parameter. The default (k=2) is the classical AIC. See AIC for more details.

correct

logical to specify whether the regular (default) or corrected (i.e., AICc) should be extracted.

For confint():

parm

this argument is here for compatibility with the generic function confint, but is (currently) ignored.

level

numeric value between 0 and 100 to specify the confidence interval level (see here for details). If unspecified, the default is to take the value from the object.

digits

optional integer to specify the number of decimal places to which the results should be rounded. If unspecified, the default is to take the value from the object.

x

an object of class "confint.matreg".

...

other arguments.

Details

The coef function extracts the estimated (standardized) regression coefficients from objects of class "matreg". The vcov function extracts the corresponding variance-covariance matrix (note: the se function can also be used to extract the standard errors). The confint function extracts the confidence intervals.

Under the ‘Regular \(R\) Matrix’ case (see matreg), the sigma function extracts the square root of the estimated error variance (by default, based on the unbiased estimate of the error variance). The logLik, AIC, and BIC functions extract the corresponding values (note: for compatibility with the behavior for lm objects, these values are based by default on ML estimation).

Value

Depending on the function, either a vector, a matrix, or a scalar with the extracted value(s).

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)
summary(res)
#> 
#> Call:
#> lm(formula = mpg ~ hp + wt + am, data = mtcars)
#> 
#> Residuals:
#>     Min      1Q  Median      3Q     Max 
#> -3.4221 -1.7924 -0.3788  1.2249  5.5317 
#> 
#> Coefficients:
#>              Estimate Std. Error t value Pr(>|t|)    
#> (Intercept) 34.002875   2.642659  12.867 2.82e-13 ***
#> hp          -0.037479   0.009605  -3.902 0.000546 ***
#> wt          -2.878575   0.904971  -3.181 0.003574 ** 
#> am           2.083710   1.376420   1.514 0.141268    
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#> 
#> Residual standard error: 2.538 on 28 degrees of freedom
#> Multiple R-squared:  0.8399,	Adjusted R-squared:  0.8227 
#> F-statistic: 48.96 on 3 and 28 DF,  p-value: 2.908e-11
#> 
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
se(res)
#> (Intercept)          hp          wt          am 
#> 2.642659337 0.009605422 0.904970538 1.376420152 
sigma(res)
#> [1] 2.537512
confint(res)
#>                   2.5 %      97.5 %
#> (Intercept) 28.58963286 39.41611738
#> hp          -0.05715454 -0.01780291
#> wt          -4.73232353 -1.02482730
#> am          -0.73575874  4.90317900
logLik(res)
#> 'log Lik.' -73.06742 (df=5)
AIC(res)
#> [1] 156.1348
BIC(res)
#> [1] 163.4635

### 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))
summary(res)
#> 
#>          estimate      se     tval  df    pval    ci.lb    ci.ub      
#> intrcpt   34.0029  2.6427  12.8669  28  <.0001  28.5896  39.4161  *** 
#> hp        -0.0375  0.0096  -3.9018  28  0.0005  -0.0572  -0.0178  *** 
#> wt        -2.8786  0.9050  -3.1808  28  0.0036  -4.7323  -1.0248   ** 
#> am         2.0837  1.3764   1.5139  28  0.1413  -0.7358   4.9032      
#> 
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#> 
#> Residual standard error: 2.5375 on 28 degrees of freedom
#> Multiple R-squared: 0.8399,  Adjusted R-squared: 0.8227
#> F-statistic: 48.9600 on 3 and 28 DF,  p-value: <.0001
#> 
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
se(res)
#>     intrcpt          hp          wt          am 
#> 2.642659337 0.009605422 0.904970538 1.376420152 
sigma(res)
#> [1] 2.537512
confint(res)
#> 
#>         estimate   ci.lb   ci.ub 
#> intrcpt  34.0029 28.5896 39.4161 
#> hp       -0.0375 -0.0572 -0.0178 
#> wt       -2.8786 -4.7323 -1.0248 
#> am        2.0837 -0.7358  4.9032 
#> 
logLik(res)
#> 'log Lik.' -73.06742 (df=5)
AIC(res)
#> [1] 156.1348
BIC(res)
#> [1] 163.4635