mlsd: MIDAS lag structure with dates

View source: R/midaslag.R

mlsdR Documentation

MIDAS lag structure with dates

Description

MIDAS lag structure with dates

Usage

mlsd(x, k, y, ...)

Arguments

x

a vector, of high frequency time series. Must be zoo or ts object

k

lags, a vector

y

a vector of low frequency time series. Must be zoo or ts object

...

further arguments used in fitting MIDAS regression

Details

High frequency time series is aligned with low frequency time series using date information. Then the high frequency lags are calculated.

To align the time series the low frequency series index needs to be extended by one low frequency period into the past and into the future. If supplied time series object does not support extending time index, a simple heuristic is used.

It is expected that time index for zoo objects can be converted to POSIXct format.

Value

a matrix containing the lags

Author(s)

Virmantas Kvedaras, Vaidotas Zemlys-Balevičius

Examples


# Example with ts objects
x <- ts(c(1:144), start = c(1980, 1), frequency = 12)
y <- ts(c(1:12), start = 1980, frequency = 1)


# msld and mls should give the same results

m1 <- mlsd(x, 0:5, y)

m2 <- mls(x, 0:5, 12)

sum(abs(m1 - m2))

# Example with zooreg

# Convert x to zooreg object using yearmon time index
## Not run: 
xz <- zoo::as.zooreg(x)

yz <- zoo::zoo(as.numeric(y), order.by = as.Date(paste0(1980 + 0:11, "-01-01")))

# Heuristic works here
m3 <- mlsd(xz, 0:5, yz)

sum(abs(m3 - m1))

## End(Not run)

mpiktas/midasr documentation built on Aug. 24, 2022, 2:32 p.m.