bridge {bridgr}R Documentation

Estimate a Bridge Model

Description

This function estimates a bridge model, aligning high-frequency indicator variables with a lower-frequency target variable to perform nowcasting or forecasting. The bridge model leverages time series alignment, lag structures, and forecasting methods to provide a comprehensive tool for time series analysis.

Usage

bridge(
  target,
  indic,
  indic_predict = NULL,
  indic_aggregators = NULL,
  indic_lags = 0,
  target_lags = 0,
  h = 1,
  frequency_conversions = c(dpw = 5, wpm = 4, mpq = 3, qpy = 4),
  ...
)

Arguments

target

A time series or data frame representing the target variable (dependent variable). Must be in a format compatible with the tsbox package (see tsbox::ts_boxable()).

indic

A time series, list of time series, or data frame containing the indicator variables (independent variables). Must be in a format compatible with the tsbox package (see tsbox::ts_boxable()).

indic_predict

A character string or vector specifying the forecasting method(s) for the indicator variables. Supported methods include "mean", "last", "auto.arima", and "ets". Defaults to "auto.arima".

indic_aggregators

A character string or vector specifying the aggregation method(s) for aligning indicator variables with the target variable. Supported methods include "mean", "last", "expalmon", "sum" or o custom vector of weights with the same length as the frequency ratio. Defaults to "mean".

indic_lags

An integer or vector of integers specifying the number of lags to include for the indicator variables. Defaults to 0 (no lags).

target_lags

An integer specifying the number of lags to include for the target variable. Defaults to 0 (no lags).

h

An integer specifying the forecast horizon in terms of the target variable's frequency. Defaults to 1 (next period).

frequency_conversions

A named vector specifying the conversion factors between different time frequencies. Defaults to c("dpw" = 5, "wpm" = 4, "mpq" = 3, "qpy" = 4) for days per week, weeks per month, months per quarter, and quarters per year, respectively.

...

Additional arguments for future extension, not used at the moment.

Details

The bridge model aligns time series of different frequencies by slicing and aggregating indicator variables to match the target variable's frequency. It uses predefined rules for frequency conversion and alignment. The function checks for mismatches in start dates and aligns the variables when necessary.

Forecasting methods for the indicator variables

Aggregation methods for the indicator variables

Value

An object of class "bridge" containing:

Author(s)

Marc Burri

References

Examples

library(bridgr)

# Example usage
target_series <- suppressMessages(tsbox::ts_tbl(data.frame(
  time = seq(as.Date("2020-01-01"), as.Date("2022-12-01"), by = "quarter"),
  value = rnorm(12)
)))

indic_series <- suppressMessages(tsbox::ts_tbl(data.frame(
  time = seq(as.Date("2020-01-01"), as.Date("2023-01-01"), by = "month"),
  value = rnorm(37)
)))

bridge_model <- suppressMessages(bridge(
  target = target_series,
  indic = indic_series,
  indic_predict = "mean",
  indic_aggregators = "mean",
  indic_lags = 2,
  target_lags = 1,
  h = 1
))


[Package bridgr version 0.1.1 Index]