Functions to extract the log-likelihood, deviance, AIC, BIC, and AICc values from objects of class "rma".

fitstats(object, ...)

# S3 method for class 'rma'
fitstats(object, ..., REML)

# S3 method for class 'rma'
logLik(object, REML, ...)
# S3 method for class 'rma'
deviance(object, REML, ...)

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

Arguments

object

an object of class "rma".

...

optionally more fitted model objects (only for fitstats(), AIC(), and BIC()).

REML

logical to specify whether the regular or restricted likelihood function should be used to obtain the fit statistics and information criteria. Defaults to the method of estimation used (i.e., TRUE if object was fitted with method="REML" and FALSE otherwise).

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.

Value

For fitstats, a data frame with the (restricted) log-likelihood, deviance, AIC, BIC, and AICc values for each model passed to the function.

For logLik, an object of class "logLik", providing the (restricted) log-likelihood of the model evaluated at the estimated coefficient(s).

For deviance, a numeric value with the corresponding deviance.

For AIC and BIC, either a numeric value with the corresponding AIC, AICc, or BIC or a data frame with rows corresponding to the models and columns representing the number of parameters in the model (df) and the AIC, AICc, or BIC.

Note

Variance components in the model (e.g., \(\tau^2\) in random/mixed-effects models fitted with rma.uni) are counted as additional parameters in the calculation of the AIC, BIC, and AICc. Also, the fixed effects are counted as parameters in the calculation of the AIC, BIC, and AICc even when using REML estimation.

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

rma.uni, rma.mh, rma.peto, rma.glmm, and rma.mv for functions to fit models for which fit statistics and information criteria can be extracted.

anova for a function to conduct likelihood ratio tests.

Examples

### calculate log risk ratios and corresponding sampling variances
dat <- escalc(measure="RR", ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg)

### random-effects model
res1 <- rma(yi, vi, data=dat, method="ML")

### mixed-effects model with absolute latitude and publication year as moderators
res2 <- rma(yi, vi, mods = ~ ablat + year, data=dat, method="ML")

### compare fit statistics
fitstats(res1, res2)
#>                res1      res2
#> logLik:   -12.66508 -7.646115
#> deviance:  37.11602 27.078099
#> AIC:       29.33015 23.292231
#> BIC:       30.46005 25.552028
#> AICc:      30.53015 28.292231

### log-likelihoods
logLik(res1)
#> 'log Lik.' -12.66508 (df=2)
logLik(res2)
#> 'log Lik.' -7.646115 (df=4)

### deviances
deviance(res1)
#> [1] 37.11602
deviance(res2)
#> [1] 27.0781

### AIC, AICc, and BIC values
AIC(res1, res2)
#>      df      AIC
#> res1  2 29.33015
#> res2  4 23.29223
AIC(res1, res2, correct=TRUE)
#>      df     AICc
#> res1  2 30.53015
#> res2  4 28.29223
BIC(res1, res2)
#>      df      BIC
#> res1  2 30.46005
#> res2  4 25.55203