AIC.gkwfit | R Documentation |
Computes the Akaike Information Criterion (AIC) or variants like the Bayesian
Information Criterion (BIC) for one or more fitted model objects of class "gkwfit"
.
## S3 method for class 'gkwfit'
AIC(object, ..., k = 2)
object |
An object of class |
... |
Optionally, more fitted model objects of class |
k |
Numeric scalar specifying the penalty per parameter. The default |
This function calculates an information criterion based on the formula
-2 \times \log Likelihood + k \times df
, where 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
and the degrees of freedom for each model.
When comparing multiple models fitted to the same data, the model with the lower AIC or BIC value is generally preferred. The function returns a sorted data frame to facilitate this comparison when multiple objects are provided.
If only one object
is provided: A single numeric value representing the calculated criterion (AIC or 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 criterion value (named AIC
, regardless of the value of k
).
The data frame is sorted in ascending order based on the criterion values.
Row names are derived from the deparsed calls of the fitted models.
Lopes, J. E.
gkwfit
, AIC
, logLik.gkwfit
, BIC.gkwfit
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 AIC for a single model
aic1 <- AIC(fit1_kw)
print(aic1)
# Compare AIC values for multiple models
aic_comparison <- c(AIC(fit1_kw), AIC(fit2_bkw), AIC(fit3_gkw))
print(aic_comparison)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.