Learn R Programming

gkwreg (version 1.0.7)

BIC.gkwfit: Calculate Bayesian Information Criterion (BIC) for gkwfit Objects

Description

Computes the Bayesian Information Criterion (BIC), sometimes called the Schwarz criterion (SIC), for one or more fitted model objects of class "gkwfit".

Usage

# S3 method for gkwfit
BIC(object, ...)

Value

  • If only one object is provided: A single numeric value, the calculated BIC.

  • If multiple objects are provided: A data.frame with rows corresponding to the models and columns for the degrees of freedom (df) and the calculated BIC value (named BIC). The data frame is sorted in ascending order based on the BIC values. Row names are generated from the deparsed calls or the names of the arguments passed to BIC.

Arguments

object

An object of class "gkwfit", typically the result of a call to gkwfit.

...

Optionally, more fitted model objects of class "gkwfit".

Author

Lopes, J. E. (with refinements)

Details

This function calculates the BIC based on the formula \(-2 \times \log Likelihood + \log(n) \times df\), where \(n\) is the number of observations and \(df\) represents the number of estimated parameters in the model (degrees of freedom).

It relies on the logLik.gkwfit method to extract the log-likelihood, the degrees of freedom (df), and the number of observations (nobs) for each model. Ensure that logLik.gkwfit is defined and returns a valid "logLik" object with appropriate attributes.

When comparing multiple models fitted to the same data, the model with the lower BIC value is generally preferred, as BIC tends to penalize model complexity more heavily than AIC for larger sample sizes. The function returns a sorted data frame to facilitate this comparison when multiple objects are provided. A warning is issued if models were fitted to different numbers of observations.

See Also

gkwfit, BIC, logLik.gkwfit, AIC.gkwfit

Examples

Run this code
# \donttest{

set.seed(2203)
y <- rkw(1000, alpha = 2.5, beta = 1.5)

# Fit different models to the same data
fit1_kw <- gkwfit(y, family = "kw", silent = TRUE)
fit2_bkw <- gkwfit(y, family = "bkw", silent = TRUE)
fit3_gkw <- gkwfit(y, family = "gkw", silent = TRUE)

# Calculate BIC for a single model
bic1 <- BIC(fit1_kw)
print(bic1)

# Compare BIC values for multiple models
bic_comparison <- c(BIC(fit1_kw), BIC(fit2_bkw), BIC(fit3_gkw))
print(bic_comparison)
# }

Run the code above in your browser using DataLab