model_score: Return the model fit for the given varest model

Description Usage Arguments Value Examples

View source: R/model_score.r

Description

This function returns the model fit for the given model as either an AIC or BIC score. We compensating for logtransformation so that the model scores of logtransformed and non-logtransformed models can be compared with each other directly. This compensation is implemented by subtracting the logtransformed data from the log-likelihood score and using the result as log-likelihood score for the AIC/BIC calculations.

Usage

1
model_score(varest, criterion, logtransformed)

Arguments

varest

A varest model.

criterion

A character string being either 'AIC' or 'BIC'.

logtransformed

A boolean, either TRUE or FALSE, indicating whether the input data for the model has been logtransformed.

Value

This returns a floating point that is either the AIC or BIC criterion for the model. A lower number corresponds to a better model fit.

Examples

1
2
3
4
5
data_matrix <- matrix(nrow = 40, ncol = 3)
data_matrix[, ] <- runif(ncol(data_matrix) * nrow(data_matrix), 1, nrow(data_matrix))
colnames(data_matrix) <- c('rumination', 'happiness', 'activity')
varest <- autovarCore:::run_var(data_matrix, NULL, 1)
autovarCore:::model_score(varest, 'AIC', FALSE)

roqua/autovarCore documentation built on Oct. 12, 2020, 4:16 a.m.