add_hf_lags: Add high frequency lags to low frequency tsibble

Description Usage Arguments Details Value Examples

View source: R/midas_processing.R

Description

Add high frequency lags to low frequency tsibble

Usage

1
add_hf_lags(lf_data, hf_data, hf_variable = NULL, n_lags = 1, one_row = TRUE)

Arguments

lf_data

low frequency data

hf_data

high frequency data

hf_variable

names of high frequency time series, all by default

n_lags

number of lags to add

one_row

output representation

Details

Adds high frequency lags to low frequency tsibble. The function concatenates n_lags of hf_data to lf_data. The concatenated observations from hf_data are from the same day or earlier than the date indicated by lf_date. If one_row is TRUE the high frequency observations are put in a row so as the number of rows in the new table is equal to those of lf_data. Otherwise the lags of high-frequency data increase the number of rows and the number of rows in new table is (number of rows in lf_data)*n_lags.

Value

tsibble with high frequency lags added

Examples

1
2
3
4
hf_data <- tibble::tibble(date = lubridate::ymd("2011-01-01") +
                            lubridate::days(0:90), observations = rnorm(91))
lf_data <- stats::ts(rnorm(4), start = c(2011, 01), frequency = 12)
add_hf_lags(lf_data, hf_data, n_lags = 5)

kassandra-ru/kassandr documentation built on Jan. 1, 2022, 7:39 a.m.