finiteDLMauto: Find the optimal lag length for finite DLMs

View source: R/finiteDLMauto.R

finiteDLMautoR Documentation

Find the optimal lag length for finite DLMs

Description

Fits finite DLMs for a range of lag lengths and orders the fitted models according to a desired measure.

Usage

finiteDLMauto(formula , data, x, y, q.min = 1, q.max = 10, k.order = NULL, 
              model.type = c("dlm","poly"), error.type = c("MASE","AIC",
                            "BIC","GMRAE", "MBRAE", "radj"), 
              trace = FALSE , type)

Arguments

formula

A formula object for the model to be fitted. In the case of multiple predictor series, the model should be entered via a formula object.

data

A data.frame including all dependent and independent series. In the case of multiple predictor series, the data should be entered via the data argument.

x

A vector including the observations of predictor time series. This is not restricted to ts objects.

y

A vector including the observations of dependent time series. This is not restricted to ts objects.

q.min

An integer representing the lower limit of the range of lag lengths to be considered. If missing, it will be set to 1.

q.max

An integer representing the upper limit of the range of lag lengths to be considered. If missing, it will be set to 10.

k.order

An integer representing order of polynomial distributed lags.

model.type

The type of model to be fitted. If set to dlm, finite distributed lag models are fitted. If set to poly, polynomial distributed lag models are fitted.

error.type

The type of goodness-of-fit measure to be used for the selection of optimal lag length. The optimal lag length is determined according to desired goodness-of-fit measure.

trace

If TRUE, prints all of the goodness-of-fit measures for all fitted models.

type

An integer taking 1 if only x and y vectors are entered, 2 if a formula and data matrix is entered. It can be left NULL since the correct value is checked and fixed by the code.

Details

When there is only one predictor series, both of model and formula objects can be used. But when they are supplied, both x and y arguments should be NULL.

The variable names in formula must match with the names of variables in data argument and it must be in the form of a generic formula for R functions.

The argument data contains dependent series and independent series. Required lags of dependent series are generated by the dlm function automatically.

If q.max is entered greater than the length of the series, its value will be adjusted to have the length of the series for fitting the regression model.

Value

Returns a data.frame including the values of goodness-of-fit measures and corresponding lag lengths.

Author(s)

Agung Andiojaya <agung.andiojaya@gmail.com>, Haydar Demirhan

Maintainer: Haydar Demirhan <haydar.demirhan@rmit.edu.au>

Examples

## Not run: 
library(dLagM)
# Multiple independent series
data(M1Germany)
data = M1Germany[1:44,]
# Run the search over finite DLMs according to AIC values
finiteDLMauto(formula = logprice ~ interest + logm1, 
              data = data.frame(data), q.min = 2, q.max = 5, 
              model.type = "dlm", error.type = "AIC", trace = FALSE)

## End(Not run)

dLagM documentation built on Oct. 2, 2023, 9:07 a.m.