View source: R/fts.VARforecast.R
DNS.forecast | R Documentation |
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
).
DNS.forecast(
fdaobj,
p = 1,
AR = FALSE,
obsdata = FALSE,
start = NULL,
end = NULL,
h = 1
)
fdaobj |
An object of class |
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 |
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. |
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. |
Diebold, F. X., & Li, C. (2006). Forecasting the term structure of government bond yields. Journal of Econometrics, 130(2), 337-364.
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.