DNS.forecast: Dynamic Nelson-Siegel Forecasting for Yield Curves

View source: R/fts.VARforecast.R

DNS.forecastR Documentation

Dynamic Nelson-Siegel Forecasting for Yield Curves

Description

DNS.forecast implements the Dynamic Nelson-Siegel (DNS) model of Diebold and Li (2006) to forecast yield curves. The function accommodates both Vector Autoregression (VAR) and Autoregressive (AR) models. This function is designed to work with preprocessed functional data objects (fdaobj).

Usage

DNS.forecast(
  fdaobj,
  p = 1,
  AR = FALSE,
  obsdata = FALSE,
  start = NULL,
  end = NULL,
  h = 1
)

Arguments

fdaobj

An object of class fdaobj.

p

Integer defining the number of lags to include in the VAR model.

AR

A logical flag indicating whether to model individual AR(p) processes (TRUE) for each factor, or a collective VAR(p) model (FALSE). Default is FALSE.

obsdata

A logical flag indicating whether to use the raw data (TRUE) or the preprocessed data (FALSE) from fdaobj. Default is FALSE.

start

Optional integer specifying the start index for a restricted sample period.

end

Optional integer specifying the end index for a restricted sample period.

h

An integer specifying the forecast horizon. If h=0, an in-sample fit is returned. For h > 0, an out-of-sample h-step forecast is generated. Default is h=1.

Value

The function returns different outputs based on the value of h. If h > 0: Returns the h-step ahead forecasted curve. If h = 0: Returns a list containing:

curve.predict

The in-sample predicted curves.

factors.predict

The in-sample predicted factors.

NSloadings

The Nelson Siegel loadings.

betas

The estimated betas (factors) in the Nelson-Siegel model.

VARmatrix

The estimated VAR matrix.

References

  • Diebold, F. X., & Li, C. (2006). Forecasting the term structure of government bond yields. Journal of Econometrics, 130(2), 337-364.

Examples

# Load, preprocess data, and perform in-sample prediction
fed = load.fed()
fdaobj = fda.preprocess(data = fed)
in_sample_fit = DNS.forecast(fdaobj, h=0)

# Perform 1-step ahead prediction
one_step_ahead = DNS.forecast(fdaobj, h=1)

ottosven/dffm documentation built on Feb. 23, 2025, 1:15 p.m.