Learn R Programming

dLagM (version 0.0.9)

finiteDLMauto: Find the optimal lag lenght for finite DLMs

Description

A function that fits finite DLMs for a range of lag lenths and orders the fitted models according to a desired measure.

Usage

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

Arguments

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. If set to MASE, the optimal lag lenthg is determined according to MASE. If set to AIC, the optimal lag lenthg is determined according to AIC. If set to BIC, the optimal lag lenthg is determined according to BIC. If set to radj, the optimal lag lenthg is determined according to Adjusted R-square.

trace

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

Value

Retunrs a data.frame including the values of goodness-of-fit measures and corresponding lag lenghts.

Details

If q.max is entered too large, its value will be adjusted to have a sample size of 10 for fitting the regression model for finite DLMs.

Examples

Run this code
# NOT RUN {
data(warming)
# Run the search over polynomial DLMs according to MASE values
finiteDLMauto(x = warming$NoMotorVehicles , y = warming$Warming ,
q.max = 12, k.order = 3, model.type = "poly",
error.type = "MASE", trace = TRUE)

# Run the search over finite DLMs according to AIC values
finiteDLMauto(x = warming$NoMotorVehicles , y = warming$Warming , 
q.min = 2, q.max = 12, model.type = "dlm" ,error.type = "AIC", 
trace = TRUE)


# }

Run the code above in your browser using DataLab