| Title: | Multicountry Term Structure of Interest Rates Models |
|---|---|
| Description: | Package for estimating, analyzing, and forecasting multi-country macro-finance affine term structure models (ATSMs). All setups build on the single-country unspanned macroeconomic risk framework from Joslin, Priebsch, and Singleton (2014, JF) <doi:10.1111/jofi.12131>. Multicountry extensions by Jotikasthira, Le, and Lundblad (2015, JFE) <doi:10.1016/j.jfineco.2014.09.004>, Candelon and Moura (2023, EM) <doi:10.1016/j.econmod.2023.106453>, and Candelon and Moura (2024, JFEC) <doi:10.1093/jjfinec/nbae008> are also available. The package also provides tools for bias correction as in Bauer Rudebusch and Wu (2012, JBES) <doi:10.1080/07350015.2012.693855>, bootstrap analysis, and several graphical/numerical outputs. |
| Authors: | Rubens Moura [aut, cre]
|
| Maintainer: | Rubens Moura <[email protected]> |
| License: | GPL-2 | GPL-3 |
| Version: | 1.5.1-1 |
| Built: | 2026-05-28 06:51:29 UTC |
| Source: | https://github.com/rubensmoura87/multiatsm |
Autoplot generic function
autoplot(x, ...)autoplot(x, ...)
x |
Object to plot |
... |
Additional arguments passed to methods |
Autoplot method for ATSMModelBoot objects
## S3 method for class 'ATSMModelBoot' autoplot(x, NumOutPE, type, ...)## S3 method for class 'ATSMModelBoot' autoplot(x, NumOutPE, type, ...)
x |
An object of class 'ATSMModelBoot' |
NumOutPE |
An object of class 'ATSMNumOutputs': point estimates of the numerical outputs |
type |
Plot type: one of "IRF", "FEVD", "GIRF", "GFEVD" (each must be suffixed with "_Factors" or "_Yields"). For JLL-based models, an additional "_Ortho" suffix produces orthogonalized outputs. All inputs must end by "_Boot" as a reference to the bootstrap procedure. |
... |
Additional arguments (not used) |
Autoplot method for ATSMNumOutputs objects
## S3 method for class 'ATSMNumOutputs' autoplot(x, type, ...)## S3 method for class 'ATSMNumOutputs' autoplot(x, type, ...)
x |
An object of class 'ATSMNumOutputs' |
type |
Plot type: "RiskFactors", "Fit", "TermPremia", or one of "IRF", "FEVD", "GIRF", "GFEVD" (each must be suffixed with "_Factors" or "_Yields"). For JLL-based models, an additional "_Ortho" suffix produces orthogonalized outputs. |
... |
Additional arguments (not used) |
Estimates an unbiased VAR(1) using stochastic approximation (Bauer, Rudebusch and Wu, 2012)
Bias_Correc_VAR( ModelType, BRWinputs, RiskFactors, Economies, FactorLabels, GVARinputs = NULL, JLLinputs = NULL, verbose = TRUE )Bias_Correc_VAR( ModelType, BRWinputs, RiskFactors, Economies, FactorLabels, GVARinputs = NULL, JLLinputs = NULL, verbose = TRUE )
ModelType |
character. Model type to be estimated. Permissible choices: "JPS original", "JPS global", "GVAR single", "JPS multi", "GVAR multi", "JLL original", "JLL No DomUnit", "JLL joint Sigma". |
BRWinputs |
list. Contains the necessary inputs for the BRW model estimation:
|
RiskFactors |
numeric matrix ( |
Economies |
character vector. Names of the |
FactorLabels |
list. Labels for all variables in the model. |
GVARinputs |
list. Inputs for GVAR model estimation (see |
JLLinputs |
list. Inputs for JLL model estimation (see |
verbose |
logical. Flag controlling function messaging. Default TRUE. |
Bias-corrected VAR parameters based on the framework of Bauer, Rudebusch and Wu (2012). The list contains:
KOZ_BC: estimated intercept (K x 1);
K1Z_BC: estimated feedback matrix (K x K);
SSZ_BC: estimated variance-covariance matrix (K x K);
dist: root mean square distance (scalar);
Td denotes the model time series dimension.
C number of countries in the system.
K denotes the total number of risk factors.
Bauer, Rudebusch and, Wu (2012). "Correcting Estimation Bias in Dynamic Term Structure Models"
This function offers an independent R implementation that is informed
by the conceptual framework outlined in Bauer, Rudebusch and Wu (2012), but adapted to the
present modeling context. Related Matlab routines are available on Cynthia Wu's
website (https://sites.google.com/view/jingcynthiawu/).
data(RiskFacFull) Factors <- t(RiskFacFull[1:7, ]) BRWinputs <- list( Cent_Measure = "Mean", gamma = 0.4, N_iter = 1000, N_burn = 100, B = 10, check = 1, B_check = 5000 ) Economies <- "China" N <- 3 ModelType <- "JPS original" FactorLabels <- NULL BRWpara <- Bias_Correc_VAR(ModelType, BRWinputs, Factors, Economies, FactorLabels, verbose = FALSE)data(RiskFacFull) Factors <- t(RiskFacFull[1:7, ]) BRWinputs <- list( Cent_Measure = "Mean", gamma = 0.4, N_iter = 1000, N_burn = 100, B = 10, check = 1, B_check = 5000 ) Economies <- "China" N <- 3 ModelType <- "JPS original" FactorLabels <- NULL BRWpara <- Bias_Correc_VAR(ModelType, BRWinputs, Factors, Economies, FactorLabels, verbose = FALSE)
Generates the bootstrap-related outputs
Bootstrap( ModelType, ModelParaPE, NumOutPE, Economies, InputsForOutputs, FactorLabels, JLLlist, GVARlist, WishBC = FALSE, BRWlist = NULL, Folder2save = NULL, verbose = TRUE )Bootstrap( ModelType, ModelParaPE, NumOutPE, Economies, InputsForOutputs, FactorLabels, JLLlist, GVARlist, WishBC = FALSE, BRWlist = NULL, Folder2save = NULL, verbose = TRUE )
ModelType |
character. Model type to be estimated. Permissible choices: "JPS original", "JPS global", "GVAR single", "JPS multi", "GVAR multi", "JLL original", "JLL No DomUnit", "JLL joint Sigma". |
ModelParaPE |
list. Point estimates of the model parameters. See outputs from |
NumOutPE |
list. Point estimates from numerical outputs. See outputs from |
Economies |
character vector. Names of the |
InputsForOutputs |
list. Inputs for generating IRFs, GIRFs, FEVDs, GFEVDs, and Term Premia. |
FactorLabels |
list. Labels for all variables present in the model, as returned by |
JLLlist |
list. Inputs for JLL model estimation (see |
GVARlist |
list. Inputs for GVAR model estimation (see |
WishBC |
logical. Whether to estimate the physical parameter model with bias correction (see |
BRWlist |
list. Inputs for bias-corrected estimation (see |
Folder2save |
character. Folder path where outputs will be stored. Default saves outputs in a temporary directory. |
verbose |
logical. Print progress messages. Default is TRUE. |
An object of class 'ATSMModelBoot' containing:
List of model parameters for each draw
List of numerical outputs (IRFs, GIRFs, FEVDs, GFEVDs) for each draw
Confidence bounds for the chosen level of significance
InputsForOutputs
methodBS : "bs" (standard bootstrap), "wild" (wild bootstrap), "block" (block bootstrap)
BlockLength : required input for the block bootstrap method. Block length must be larger than 0 and smallar than the model time series dimension (Td).
ndraws: number of draws. Must be a positive integer.
pctg : confidence level. Must be a positive integer. Common choices are: 68, 90 and 95.
- autoplot(object, NumOutPE, type)
data("ParaSetEx") data("InpForOutEx") data("NumOutEx") ModelType <- "JPS original" Economy <- "Brazil" FacLab <- LabFac(N = 1, DomVar = "Eco_Act", GlobalVar = "Gl_Eco_Act", Economy, ModelType) # Adjust Forecasting setting InpForOutEx[[ModelType]]$Bootstrap <- list( WishBootstrap = 1, methodBS = "bs", BlockLength = 4, ndraws = 5, pctg = 95 ) Boot <- Bootstrap(ModelType, ParaSetEx, NumOutEx, Economy, InpForOutEx, FacLab, JLLlist = NULL, GVARlist = NULL, WishBC = FALSE, BRWlist = NULL, Folder2save = NULL, verbose = FALSE )data("ParaSetEx") data("InpForOutEx") data("NumOutEx") ModelType <- "JPS original" Economy <- "Brazil" FacLab <- LabFac(N = 1, DomVar = "Eco_Act", GlobalVar = "Gl_Eco_Act", Economy, ModelType) # Adjust Forecasting setting InpForOutEx[[ModelType]]$Bootstrap <- list( WishBootstrap = 1, methodBS = "bs", BlockLength = 4, ndraws = 5, pctg = 95 ) Boot <- Bootstrap(ModelType, ParaSetEx, NumOutEx, Economy, InpForOutEx, FacLab, JLLlist = NULL, GVARlist = NULL, WishBC = FALSE, BRWlist = NULL, Folder2save = NULL, verbose = FALSE )
Unspanned macro risk model outputs by Bauer and Rudebusch (2017)
data("BR_jps_out")data("BR_jps_out")
Unspanned macro risk model outputs by Bauer and Rudebusch (2017)
summary list of log-likelihood estimations
time series of unspanned factors
additional summary list of log-likelihood estimations
Weight matrix that results from principal components analysis
time series of bond yields
total number of risk factor of the model (spanned and unspanned)
total number of spanned factor of the model
Bauer, M. and Rudebusch, G. "Resolving the Spanning Puzzle in Macro-Finance Term Structure Models"
Gather data of several countries in a list. Particularly useful for GVAR-based setups (Compute "GVARFactors")
DatabasePrep( t_First, t_Last, Economies, N, FactorLabels, ModelType, Macro_FullData, Yields_FullData, Wgvar = NULL )DatabasePrep( t_First, t_Last, Economies, N, FactorLabels, ModelType, Macro_FullData, Yields_FullData, Wgvar = NULL )
t_First |
character. Start date of the sample period in the format yyyy-mm-dd. |
t_Last |
character. End date of the sample period in the format yyyy-mm-dd. |
Economies |
character vector. Names of the |
N |
positive integer. Number of country-specific spanned factors per country. |
FactorLabels |
list. Labels for all variables present in the model, as returned by |
ModelType |
character. Model type to be estimated. Permissible choices: "JPS original", "JPS global", "GVAR single", "JPS multi", "GVAR multi", "JLL original", "JLL No DomUnit", "JLL joint Sigma". |
Macro_FullData |
list. Full set of macroeconomic data, as returned by |
Yields_FullData |
list. Full set of bond yield data, as returned by |
Wgvar |
GVAR transition matrix. For GVAR models, either a matrix ( |
List containing the risk factor set for all countries and global factors. Particularly useful for GVAR-based models.
C: number of countries in the system.
N: number of country-specific spanned factors.
# Load data from excel macro_data <- Load_Excel_Data(system.file("extdata", "MacroData.xlsx", package = "MultiATSM")) yields_data <- Load_Excel_Data(system.file("extdata", "YieldsData.xlsx", package = "MultiATSM")) trade_data <- Load_Excel_Data(system.file("extdata", "TradeData.xlsx", package = "MultiATSM")) # Adjust trade data trade_data <- lapply(trade_data, function(df) { countries <- df[[1]] df <- as.data.frame(df[-1]) rownames(df) <- countries df }) # Define features of interest ModelType <- "GVAR multi" Economies <- c("China", "Uruguay", "Russia") GlobalVar <- c("GBC", "CPI_OECD") DomVar <- c("Eco_Act", "Inflation") N <- 3 t0 <- "2006-09-01" tF <- "2019-01-01" # Compute some inputs FactorLabels <- LabFac(N, DomVar, GlobalVar, Economies, ModelType) Wgvar <- Transition_Matrix( t_First = "2006", t_Last = "2019", Economies, type = "Sample Mean", trade_data ) # Compute GVARFactors GVARFactors <- DatabasePrep( t0, tF, Economies, N, FactorLabels, ModelType, macro_data, yields_data, Wgvar )# Load data from excel macro_data <- Load_Excel_Data(system.file("extdata", "MacroData.xlsx", package = "MultiATSM")) yields_data <- Load_Excel_Data(system.file("extdata", "YieldsData.xlsx", package = "MultiATSM")) trade_data <- Load_Excel_Data(system.file("extdata", "TradeData.xlsx", package = "MultiATSM")) # Adjust trade data trade_data <- lapply(trade_data, function(df) { countries <- df[[1]] df <- as.data.frame(df[-1]) rownames(df) <- countries df }) # Define features of interest ModelType <- "GVAR multi" Economies <- c("China", "Uruguay", "Russia") GlobalVar <- c("GBC", "CPI_OECD") DomVar <- c("Eco_Act", "Inflation") N <- 3 t0 <- "2006-09-01" tF <- "2019-01-01" # Compute some inputs FactorLabels <- LabFac(N, DomVar, GlobalVar, Economies, ModelType) Wgvar <- Transition_Matrix( t_First = "2006", t_Last = "2019", Economies, type = "Sample Mean", trade_data ) # Compute GVARFactors GVARFactors <- DatabasePrep( t0, tF, Economies, N, FactorLabels, ModelType, macro_data, yields_data, Wgvar )
Retrieves data from Excel and builds the database used in the model estimation
DataForEstimation( t0, tF, Economies, N, FactorLabels, ModelType, DataFrequency, Macro_FullData, Yields_FullData, DataConnect = NULL, W_type = NULL, t_First_Wgvar = NULL, t_Last_Wgvar = NULL )DataForEstimation( t0, tF, Economies, N, FactorLabels, ModelType, DataFrequency, Macro_FullData, Yields_FullData, DataConnect = NULL, W_type = NULL, t_First_Wgvar = NULL, t_Last_Wgvar = NULL )
t0 |
character. Start date of the sample period in the format yyyy-mm-dd. |
tF |
character. End date of the sample period in the format yyyy-mm-dd. |
Economies |
character vector. Names of the |
N |
positive integer. Number of country-specific spanned factors. |
FactorLabels |
list. Labels for all variables present in the model, as returned by |
ModelType |
character. Model type to be estimated. Permissible choices: "JPS original", "JPS global", "GVAR single", "JPS multi", "GVAR multi", "JLL original", "JLL No DomUnit", "JLL joint Sigma". |
DataFrequency |
character. Data frequency. Permissible choices: "Daily All Days", "Daily Business Days", "Weekly", "Monthly", "Quarterly", "Annually". |
Macro_FullData |
list. Full set of macroeconomic data. |
Yields_FullData |
list. Full set of bond yield data. |
DataConnect |
list. Data for computing bilateral connectedness measures. Default is NULL. Required for GVAR-based models. |
W_type |
character. Weight matrix type. Permissible choices: "Full Sample" (all years), "Sample Mean" (average over sample), or a specific year (e.g. "1998", "2005"). Default is NULL. |
t_First_Wgvar |
character. First year for weight matrix computation. Default is NULL. |
t_Last_Wgvar |
character. Last year for weight matrix computation. Default is NULL. |
A list containing:
Yields: matrix (J x Td or CJ x Td) of bond yields for all countries.
RiskFactors: matrix (K x Td) of risk factors for all countries.
GVARFactors: list of variables used in VARX estimation (see GVARFactors data file). NULL if not GVAR-based.
Td: model time series dimension.
C: number of countries in the system.
N: number of country-specific spanned factors.
K: total number of risk factors.
J: number of bond yields per country used in estimation.
DomVar <- c("Eco_Act", "Inflation") GlobalVar <- c("GBC", "CPI_OECD") t0 <- "2006-09-01" tF <- "2019-01-01" Economies <- c("China", "Brazil", "Mexico", "Uruguay", "Russia") N <- 2 ModelType <- "JPS original" FactorLabels <- LabFac(N, DomVar, GlobalVar, Economies, ModelType) DataFrequency <- "Monthly" MacroData <- Load_Excel_Data(system.file("extdata", "MacroData.xlsx", package = "MultiATSM")) YieldData <- Load_Excel_Data(system.file("extdata", "YieldsData.xlsx", package = "MultiATSM")) DataModel <- DataForEstimation( t0, tF, Economies, N, FactorLabels, ModelType, DataFrequency, MacroData, YieldData )DomVar <- c("Eco_Act", "Inflation") GlobalVar <- c("GBC", "CPI_OECD") t0 <- "2006-09-01" tF <- "2019-01-01" Economies <- c("China", "Brazil", "Mexico", "Uruguay", "Russia") N <- 2 ModelType <- "JPS original" FactorLabels <- LabFac(N, DomVar, GlobalVar, Economies, ModelType) DataFrequency <- "Monthly" MacroData <- Load_Excel_Data(system.file("extdata", "MacroData.xlsx", package = "MultiATSM")) YieldData <- Load_Excel_Data(system.file("extdata", "YieldsData.xlsx", package = "MultiATSM")) DataModel <- DataForEstimation( t0, tF, Economies, N, FactorLabels, ModelType, DataFrequency, MacroData, YieldData )
Domestic risk factors data used in Candelon and Moura (2024, JFEC)
data("DomMacro")data("DomMacro")
A matrix of country-specific risk factors (inflation and economic activity growth) for Brazil, China, Mexico, and Uruguay. The data have monthly frequency and span the period from June/2004 to January/2020.
year-over-year variation from Consumer price index published by the International Monetary Fund <https://data.imf.org/en/datasets/IMF.STA:CPI>
GDP leading indicator published by the OECD <https://www.oecd.org/en/data/indicators/composite-leading-indicator-cli.html>
Candelon, B. and Moura, R. (2024) "A Multicountry Model of the Term Structures of Interest Rates with a GVAR". (Journal of Financial Econometrics)
Domestic risk factors data used in the GVAR models - Candelon and Moura (2023)
data("DomMacro_covid")data("DomMacro_covid")
A matrix of country-specific risk factors (inflation, output growth, CDS, and COVID-19 reproduction rate) for Brazil, India, Mexico, and Russia. The data have weekly frequency and span the period from March 22, 2020, to September 26, 2021.
Monthly CPI (from OECD) interpolated to daily data (spline), converted to weekly year-over-year changes, and detrended <https://www.oecd.org/en/data/indicators/inflation-cpi.html>
Detrended weekly estimate of GDP year-over-year growth derived from the OECD Weekly Tracker index <https://web-archive.oecd.org/sections/weekly-tracker-of-gdp-growth/index.htm>
5-year maturity CDS. Simulated data constructed using Bloomberg bond yield series.
detrended R rate from the Our World in Data database <https://ourworldindata.org/coronavirus>
Candelon, B. and Moura, R. (2023) "Sovereign yield curves and the COVID-19 in emerging markets". (Economic Modelling)
FEVD and GFEVD graphs for all models
FEVDandGFEVDgraphs( ModelType, NumOut, WishPdynamicsgraphs, WishYieldsgraphs, FEVDhoriz, PathsGraphs, OutputType, Economies, Folder2save, verbose )FEVDandGFEVDgraphs( ModelType, NumOut, WishPdynamicsgraphs, WishYieldsgraphs, FEVDhoriz, PathsGraphs, OutputType, Economies, Folder2save, verbose )
ModelType |
character. Estimated model type. Permissible choices: "JPS original", "JPS global", "GVAR single", "JPS multi", "GVAR multi", "JLL original", "JLL No DomUnit", "JLL joint Sigma". |
NumOut |
list. Computed outputs containing model fit, IRFs, FEVDs, GIRFs, GFEVDs and Term premia. |
WishPdynamicsgraphs |
logical. Set TRUE to generate risk factor graphs, FALSE otherwise. |
WishYieldsgraphs |
logical. Set TRUE to generate bond yield graphs, FALSE otherwise. |
FEVDhoriz |
integer. Desired horizon of analysis for the FEVDs. |
PathsGraphs |
character. Path of the folder in which the graphs will be saved. |
OutputType |
character. Available options: "FEVD", "GFEVD", "FEVD Ortho", "GFEVD Ortho". |
Economies |
character vector. Names of the |
Folder2save |
character. Folder path where the outputs will be stored. |
verbose |
logical. Flag controlling function messaging. |
- 'autoplot(object, type = "FEVD_Factor")', 'autoplot(object, type = "FEVD_Yields")',
'autoplot(object, type = "GFEVD_Yields")', 'autoplot(object, type = "GFEVD_Yields")'.
For JLL-based models: 'autoplot(object, type = "FEVD_Factor-_Ortho")',
'autoplot(object, type = "FEVD_Yields_Ortho")', 'autoplot(object, type = "GFEVD_Yields_Ortho")',
'autoplot(object, type = "GFEVD_Yields_Ortho")'.
data("NumOutEx") ModelType <- "JPS original" Economy <- "Brazil" FEVDhoriz <- 20 FEVDandGFEVDgraphs(ModelType, NumOutEx, WishPdynamicsgraphs = FALSE, WishYieldsgraphs = TRUE, FEVDhoriz, PathsGraphs = NULL, OutputType = "FEVD", Economy, Folder2save = NULL, verbose = FALSE )data("NumOutEx") ModelType <- "JPS original" Economy <- "Brazil" FEVDhoriz <- 20 FEVDandGFEVDgraphs(ModelType, NumOutEx, WishPdynamicsgraphs = FALSE, WishYieldsgraphs = TRUE, FEVDhoriz, PathsGraphs = NULL, OutputType = "FEVD", Economy, Folder2save = NULL, verbose = FALSE )
Model fit graphs for all models
Fitgraphs( ModelType, WishFitgraphs, ModelPara, NumOut, Economies, PathsGraphs, Folder2save, verbose )Fitgraphs( ModelType, WishFitgraphs, ModelPara, NumOut, Economies, PathsGraphs, Folder2save, verbose )
ModelType |
character. Estimated model type. |
WishFitgraphs |
logical. Set TRUE to generate fit graphs, FALSE otherwise. |
ModelPara |
list. Model parameter estimates (see |
NumOut |
list. Outputs containing model fit, IRFs, FEVDs, GIRFs, GFEVDs and Term premia. |
Economies |
character vector. Names of the economies included in the system. |
PathsGraphs |
character. Path of the folder in which the graphs will be saved. |
Folder2save |
character. Desired folder path to save outputs. |
verbose |
logical. Flag controlling function messaging. |
- 'autoplot(object, type = "Fit")'
data("ParaSetEx") data("NumOutEx") ModelType <- "JPS original" Economy <- "Brazil" Fitgraphs(ModelType, WishFitgraphs = TRUE, ParaSetEx, NumOutEx, Economy, PathsGraphs = NULL, Folder2save = NULL, verbose = FALSE )data("ParaSetEx") data("NumOutEx") ModelType <- "JPS original" Economy <- "Brazil" Fitgraphs(ModelType, WishFitgraphs = TRUE, ParaSetEx, NumOutEx, Economy, PathsGraphs = NULL, Folder2save = NULL, verbose = FALSE )
Generates forecasts of bond yields for all model types
ForecastYields( ModelType, ModelPara, InputsForOutputs, FactorLabels, Economies, JLLlist = NULL, GVARlist = NULL, WishBRW = FALSE, BRWlist = NULL, Folder2save = NULL, verbose = TRUE )ForecastYields( ModelType, ModelPara, InputsForOutputs, FactorLabels, Economies, JLLlist = NULL, GVARlist = NULL, WishBRW = FALSE, BRWlist = NULL, Folder2save = NULL, verbose = TRUE )
ModelType |
character. Model type to be estimated. Permissible choices: "JPS original", "JPS global", "GVAR single", "JPS multi", "GVAR multi", "JLL original", "JLL No DomUnit", "JLL joint Sigma". |
ModelPara |
list. Point estimates of the model parameters. See outputs from |
InputsForOutputs |
list. Inputs for generating IRFs, GIRFs, FEVDs, GFEVDs, and Term Premia. |
FactorLabels |
list. Labels for all variables present in the model, as returned by |
Economies |
character vector. Names of the |
JLLlist |
list. Inputs for JLL model estimation (see |
GVARlist |
list. Inputs for GVAR model estimation (see |
WishBRW |
logical. Whether to estimate the physical parameter model with bias correction (see |
BRWlist |
list. Inputs for bias-corrected estimation (see |
Folder2save |
character. Folder path where outputs will be stored. Default saves outputs in a temporary directory. |
verbose |
logical. Print progress messages. Default is TRUE. |
An object of class 'ATSMModelForecast' containing the following elements:
Out-of-sample forecasts of bond yields per forecast horizon
Out-of-sample forecast errors of bond yields per forecast horizon
Root mean square errors per forecast horizon
InputsForOutputs input)ForHoriz: forecast horizon. Must be a positive integer.
t0Sample: initial sample date. Must be a positive integer smaller than the time series dimension of the model (Td)
t0Forecast: last sample date for the first forecast. Note that Td > t0Forecast + ForHoriz.
ForType: "Rolling" (rolling window forecast) or "Expanding" (for expanding window forecast)
- 'plot(object)'
data("ParaSetEx") data("InpForOutEx") # Adjust inputs according to the loaded features ModelType <- "JPS original" Economy <- "Brazil" FacLab <- LabFac(N = 1, DomVar = "Eco_Act", GlobalVar = "Gl_Eco_Act", Economy, ModelType) # Adjust Forecasting setting InpForOutEx[[ModelType]]$Forecasting <- list( WishForecast = 1, ForHoriz = 12, t0Sample = 1, t0Forecast = 143, ForType = "Expanding" ) Forecast <- ForecastYields(ModelType, ParaSetEx, InpForOutEx, FacLab, Economy, WishBRW = FALSE, verbose = TRUE )data("ParaSetEx") data("InpForOutEx") # Adjust inputs according to the loaded features ModelType <- "JPS original" Economy <- "Brazil" FacLab <- LabFac(N = 1, DomVar = "Eco_Act", GlobalVar = "Gl_Eco_Act", Economy, ModelType) # Adjust Forecasting setting InpForOutEx[[ModelType]]$Forecasting <- list( WishForecast = 1, ForHoriz = 12, t0Sample = 1, t0Forecast = 143, ForType = "Expanding" ) Forecast <- ForecastYields(ModelType, ParaSetEx, InpForOutEx, FacLab, Economy, WishBRW = FALSE, verbose = TRUE )
Global risk factors data used in Candelon and Moura (2024, JFEC)
data("GlobalMacro")data("GlobalMacro")
A matrix containing the time series of global risk factors, namely global economic activity and global inflation. The data have monthly frequency and span the period from June/2004 to January/2020.
Lutz Kilian’s index of global real economic activity <https://sites.google.com/site/lkilian2019/research/data-sets?authuser=0>
year-over-year variation of the OECD aggregated CPI containing all its state members <https://www.oecd.org/en/data/indicators/inflation-cpi.html>
Candelon, B. and Moura, R. (2024) "A Multicountry Model of the Term Structures of Interest Rates with a GVAR". (Journal of Financial Econometrics)
Global risk factors data used in Candelon and Moura (2023)
data("GlobalMacro_covid")data("GlobalMacro_covid")
A matrix containing the time series of global risk factors, namely the year-over-year growth rates of U.S. and Chinese output, and the S&P 500 index. The data have weekly frequency and span the period from March 22, 2020, to September 26, 2021.
OECD Weekly Tracker index <https://web-archive.oecd.org/sections/weekly-tracker-of-gdp-growth/index.htm>
weekly year-over-year change in the interpolated OECD leading indicator <https://www.oecd.org/en/data/indicators/composite-leading-indicator-cli.html>
year-over-year variation from the Standard and Poor’s 500 stock market index. Simulated data constructed using FRED series.
Candelon, B. and Moura, R. (2023) "Sovereign yield curves and the COVID-19 in emerging markets". (Economic Modelling)
Estimates a GVAR(1) and VARX(1,1,1) models
GVAR(GVARinputs, N, CheckInputs = FALSE)GVAR(GVARinputs, N, CheckInputs = FALSE)
GVARinputs |
list. Inputs for GVAR model estimation:
|
N |
positive integer. Number of country-specific spanned factors. |
CheckInputs |
logical. Whether to perform a prior consistency check on the inputs provided in |
list. Contains:
parameters of the country-specific VARX(1,1,1):
intercept (M + N x 1)
phi_1 (M + N x M + N)
phi_1* (M + N x M + N)
phi_g (M + N x M + N)
Sigma (M + N x G)
parameters of the GVAR:
F0 (K x K)
F1 (K x K)
Sigma_y (K x K)
C: number of countries in the system
G: number of global unspanned factors
M: number of country-specific unspanned factors
N: number of country-specific spanned factors
K: total number of risk factors (K = C x (N + M) + G)
Chudik, A. and Pesaran, M. H. (2016). "Theory and Practice of GVAR modelling" (Journal of Economic Surveys)
data(GVARFactors) GVARinputs <- list( Economies = c("China", "Brazil", "Mexico", "Uruguay"), GVARFactors = GVARFactors, VARXtype = "unconstrained" ) GVARinputs$Wgvar <- matrix(c( 0, 0.83, 0.86, 0.38, 0.65, 0, 0.13, 0.55, 0.32, 0.12, 0, 0.07, 0.03, 0.05, 0.01, 0 ), nrow = 4, ncol = 4) N <- 3 GVARPara <- GVAR(GVARinputs, N)data(GVARFactors) GVARinputs <- list( Economies = c("China", "Brazil", "Mexico", "Uruguay"), GVARFactors = GVARFactors, VARXtype = "unconstrained" ) GVARinputs$Wgvar <- matrix(c( 0, 0.83, 0.86, 0.38, 0.65, 0, 0.13, 0.55, 0.32, 0.12, 0, 0.07, 0.03, 0.05, 0.01, 0 ), nrow = 4, ncol = 4) N <- 3 GVARPara <- GVAR(GVARinputs, N)
Risk factors data used in the GVAR-ATSM from Candelon and Moura (2024, JFEC)
data("GVARFactors")data("GVARFactors")
List of risk factors organized for GVAR estimation. It includes global unspanned factors (economic activity, inflation) and domestic factors—both unspanned (economic activity, inflation) and spanned (level, slope, curvature) with their starred counterparts. The dataset covers Brazil, China, Mexico, and Uruguay at a monthly frequency from June 2004 to January 2020.
See data("GlobalMacro") for a detailed data description.
See data("DomMacro") for a detailed data description.
First three principal components of each country set of bond yields. See data("Yields") for a detailed data description.
Weighted average of foreign factors. See Transition_Matrix for the computation of weights.
Candelon, B. and Moura, R. (2024) "A Multicountry Model of the Term Structures of Interest Rates with a GVAR". (Journal of Financial Econometrics)
List of inputs of a JPS-based model for Brazilian data
data("InpForOutEx")data("InpForOutEx")
list of inputs
Generates inputs necessary to build the likelihood function for the ATSM model
InputsForOpt( InitialSampleDate, FinalSampleDate, ModelType, Yields, GlobalMacro, DomMacro, FactorLabels, Economies, DataFrequency, GVARlist = NULL, JLLlist = NULL, WishBRW = FALSE, BRWlist = NULL, UnitYields = "Month", CheckInputs = TRUE, BS_Adj = FALSE, verbose = TRUE )InputsForOpt( InitialSampleDate, FinalSampleDate, ModelType, Yields, GlobalMacro, DomMacro, FactorLabels, Economies, DataFrequency, GVARlist = NULL, JLLlist = NULL, WishBRW = FALSE, BRWlist = NULL, UnitYields = "Month", CheckInputs = TRUE, BS_Adj = FALSE, verbose = TRUE )
InitialSampleDate |
Start date of the sample period in the format "dd-mm-yyyy" |
FinalSampleDate |
End date of the sample period in the format "dd-mm-yyyy" |
ModelType |
character. Model type to be estimated. Permissible choices: "JPS original", "JPS global", "GVAR single", "JPS multi", "GVAR multi", "JLL original", "JLL No DomUnit", "JLL joint Sigma". |
Yields |
numerical matrix with time series of yields ( |
GlobalMacro |
numerical matrix with time series of the global risk factors ( |
DomMacro |
numerical matrix with time series of the country-specific risk factors for all |
FactorLabels |
list. Labels for all variables present in the model, as returned by |
Economies |
character vector. Names of the |
DataFrequency |
character. Data frequency. Permissible choices: "Daily All Days", "Daily Business Days", "Weekly", "Monthly", "Quarterly", "Annually". |
GVARlist |
list. Inputs for GVAR model estimation. See details below. |
JLLlist |
list. Inputs for JLL model estimation. See details below. |
WishBRW |
logical. Whether to estimate the physical parameter model with bias correction (see |
BRWlist |
list. Inputs for bias-corrected estimation. |
UnitYields |
character. Maturity unit of yields. Permissible choices: "Month" or "Year". Default is "Month". |
CheckInputs |
logical. Whether to perform a prior check on the consistency of the provided input list. Default is TRUE. |
BS_Adj |
logical. Whether to adjust the global series for the sepQ models in the Bootstrap setting. Default is FALSE. |
verbose |
logical. Print progress messages. Default is TRUE. |
An object of class 'ATSMModelInputs' containing the necessary inputs for performing the model optimization.
VARXtype: "unconstrained" or "constrained"
W_type: "Time-varying" or "Sample Mean"
t_First_Wgvar, t_Last_Wgvar: year as character
DomUnit: name of the dominant economy or None
WishSigmas: TRUE (estimate variance-covariance matrices) or FALSE
SigmaNonOrtho: NULL or K x K matrix
BiasCorrection: TRUE (bias-corrected) or FALSE
flag_mean: TRUE (mean) or FALSE (median)
gamma: numeric adjustment parameter
N_iter: number of iterations
N_burn: number of burn-in iterations
B: number of bootstrap samples
checkBRW: TRUE or FALSE
B_check: number of bootstrap samples for closeness check
Td model time series dimension.
C number of countries in the system.
G number of global unspanned factors.
M number of country-specific unspanned factors.
K total number of risk factors.
J number of bond yields per country used in estimation.
- 'print(object)' - 'summary(object)'
# Example 1: data(GlobalMacro) data(DomMacro) data(Yields) ModelType <- "JPS original" Economies <- "Mexico" t0 <- "01-05-2007" # Initial Sample Date (Format: "dd-mm-yyyy") tF <- "01-12-2018" # Final Sample Date (Format: "dd-mm-yyyy") N <- 3 GlobalVar <- c("Gl_Eco_Act") # Global Variables DomVar <- c("Eco_Act") # Domestic Variables FactorLabels <- LabFac(N, DomVar, GlobalVar, Economies, ModelType) DataFreq <- "Monthly" ATSMInputs <- InputsForOpt(t0, tF, ModelType, Yields, GlobalMacro, DomMacro, FactorLabels, Economies, DataFreq, CheckInputs = FALSE, verbose = FALSE ) # Example 2: LoadData("CM_2024") ModelType <- "GVAR multi" Economies <- c("China", "Brazil", "Mexico", "Uruguay") t0 <- "01-05-2007" # InitialSampleDate (Format: "dd-mm-yyyy") tF <- "01-12-2019" # FinalSampleDate (Format: "dd-mm-yyyy") N <- 2 GlobalVar <- c("Gl_Eco_Act", "Gl_Inflation") # Global Variables DomVar <- c("Inflation") # Domestic Variables FactorLabels <- LabFac(N, DomVar, GlobalVar, Economies, ModelType) DataFreq <- "Monthly" GVARlist <- list( VARXtype = "unconstrained", W_type = "Sample Mean", t_First_Wgvar = "2007", t_Last_Wgvar = "2019", DataConnectedness = TradeFlows ) ATSMInputs <- InputsForOpt(t0, tF, ModelType, Yields, GlobalMacro, DomMacro, FactorLabels, Economies, DataFreq, GVARlist, CheckInputs = FALSE, verbose = FALSE ) # Example 3: LoadData("CM_2024") ModelType <- "JLL original" Economies <- c("China", "Brazil", "Uruguay") t0 <- "01-05-2007" # InitialSampleDate (Format: "dd-mm-yyyy") tF <- "01-12-2019" # FinalSampleDate (Format: "dd-mm-yyyy") N <- 2 GlobalVar <- c("Gl_Eco_Act", "Gl_Inflation") # Global Variables DomVar <- c("Eco_Act", "Inflation") # Domestic Variables FactorLabels <- LabFac(N, DomVar, GlobalVar, Economies, ModelType) JLLinputs <- list(DomUnit = "China") DataFrequency <- "Monthly" ATSMInputs <- InputsForOpt(t0, tF, ModelType, Yields, GlobalMacro, DomMacro, FactorLabels, Economies, DataFreq, JLLlist = JLLinputs, CheckInputs = FALSE, verbose = FALSE )# Example 1: data(GlobalMacro) data(DomMacro) data(Yields) ModelType <- "JPS original" Economies <- "Mexico" t0 <- "01-05-2007" # Initial Sample Date (Format: "dd-mm-yyyy") tF <- "01-12-2018" # Final Sample Date (Format: "dd-mm-yyyy") N <- 3 GlobalVar <- c("Gl_Eco_Act") # Global Variables DomVar <- c("Eco_Act") # Domestic Variables FactorLabels <- LabFac(N, DomVar, GlobalVar, Economies, ModelType) DataFreq <- "Monthly" ATSMInputs <- InputsForOpt(t0, tF, ModelType, Yields, GlobalMacro, DomMacro, FactorLabels, Economies, DataFreq, CheckInputs = FALSE, verbose = FALSE ) # Example 2: LoadData("CM_2024") ModelType <- "GVAR multi" Economies <- c("China", "Brazil", "Mexico", "Uruguay") t0 <- "01-05-2007" # InitialSampleDate (Format: "dd-mm-yyyy") tF <- "01-12-2019" # FinalSampleDate (Format: "dd-mm-yyyy") N <- 2 GlobalVar <- c("Gl_Eco_Act", "Gl_Inflation") # Global Variables DomVar <- c("Inflation") # Domestic Variables FactorLabels <- LabFac(N, DomVar, GlobalVar, Economies, ModelType) DataFreq <- "Monthly" GVARlist <- list( VARXtype = "unconstrained", W_type = "Sample Mean", t_First_Wgvar = "2007", t_Last_Wgvar = "2019", DataConnectedness = TradeFlows ) ATSMInputs <- InputsForOpt(t0, tF, ModelType, Yields, GlobalMacro, DomMacro, FactorLabels, Economies, DataFreq, GVARlist, CheckInputs = FALSE, verbose = FALSE ) # Example 3: LoadData("CM_2024") ModelType <- "JLL original" Economies <- c("China", "Brazil", "Uruguay") t0 <- "01-05-2007" # InitialSampleDate (Format: "dd-mm-yyyy") tF <- "01-12-2019" # FinalSampleDate (Format: "dd-mm-yyyy") N <- 2 GlobalVar <- c("Gl_Eco_Act", "Gl_Inflation") # Global Variables DomVar <- c("Eco_Act", "Inflation") # Domestic Variables FactorLabels <- LabFac(N, DomVar, GlobalVar, Economies, ModelType) JLLinputs <- list(DomUnit = "China") DataFrequency <- "Monthly" ATSMInputs <- InputsForOpt(t0, tF, ModelType, Yields, GlobalMacro, DomMacro, FactorLabels, Economies, DataFreq, JLLlist = JLLinputs, CheckInputs = FALSE, verbose = FALSE )
Collects the inputs that are used to construct the numerical and graphical outputs
InputsForOutputs( ModelType, Horiz, ListOutputWished, OutputLabel, WishStationarityQ, DataFrequency, WishGraphYields = FALSE, WishGraphRiskFactors = FALSE, WishOrthoJLLgraphs = FALSE, WishForwardPremia = FALSE, LimFP = NULL, WishBootstrap = FALSE, ListBoot = NULL, WishForecast = FALSE, ListForecast = NULL, UnitYields = "Month" )InputsForOutputs( ModelType, Horiz, ListOutputWished, OutputLabel, WishStationarityQ, DataFrequency, WishGraphYields = FALSE, WishGraphRiskFactors = FALSE, WishOrthoJLLgraphs = FALSE, WishForwardPremia = FALSE, LimFP = NULL, WishBootstrap = FALSE, ListBoot = NULL, WishForecast = FALSE, ListForecast = NULL, UnitYields = "Month" )
ModelType |
character. Model type to be estimated. Permissible choices: "JPS original", "JPS global", "GVAR single", "JPS multi", "GVAR multi", "JLL original", "JLL No DomUnit", "JLL joint Sigma". |
Horiz |
numeric scalar. Desired analysis horizon for the outputs. |
ListOutputWished |
character vector. Desired graphical outputs. Available options: "RiskFactors", "Fit", "IRF", "FEVD", "GIRF", "GFEVD", "TermPremia", "ForwardPremia". |
OutputLabel |
character. Name of the output label to be stored. |
WishStationarityQ |
logical. Whether to impose that the largest eigenvalue under Q is strictly smaller than 1. TRUE to impose. |
DataFrequency |
character. Data frequency. Permissible choices: "Daily All Days", "Daily Business Days", "Weekly", "Monthly", "Quarterly", "Annually". |
WishGraphYields |
logical. Whether to generate graphs for yields. Default is FALSE. |
WishGraphRiskFactors |
logical. Whether to generate graphs for risk factors. Default is FALSE. |
WishOrthoJLLgraphs |
logical. Whether to generate orthogonalized JLL-based graphs. Default is FALSE. |
WishForwardPremia |
logical. Whether to generate forward premia graphs. Default is FALSE. |
LimFP |
numeric vector. Maturities associated with the start and end dates of the loan. |
WishBootstrap |
logical. Whether to perform bootstrap-based estimation. Default is FALSE. |
ListBoot |
list. Contains bootstrap settings: methodBS ("bs", "wild", "block"), BlockLength (numeric), ndraws (numeric), pctg (numeric). |
WishForecast |
logical. Whether to generate forecasts. Default is FALSE. |
ListForecast |
list. Contains forecast settings: ForHoriz (numeric), t0Sample (numeric), t0Forecast (numeric), ForType ("Rolling", "Expanding"). |
UnitYields |
character. Maturity unit of yields. Options: "Month" or "Year". Default is "Month". |
List of necessary inputs to generate the graphs and outputs of the desired model.
ModelType <- "JPS original" Horiz <- 100 DesiredOutputGraphs <- c("Fit", "GIRF", "GFEVD") OutputLabel <- "Test" WishStationarityQ <- TRUE WishGraphRiskFac <- FALSE WishGraphYields <- TRUE InputsList <- InputsForOutputs( ModelType, Horiz, DesiredOutputGraphs, OutputLabel, WishStationarityQ, WishGraphYields, WishGraphRiskFac )ModelType <- "JPS original" Horiz <- 100 DesiredOutputGraphs <- c("Fit", "GIRF", "GFEVD") OutputLabel <- "Test" WishStationarityQ <- TRUE WishGraphRiskFac <- FALSE WishGraphYields <- TRUE InputsList <- InputsForOutputs( ModelType, Horiz, DesiredOutputGraphs, OutputLabel, WishStationarityQ, WishGraphYields, WishGraphRiskFac )
IRF and GIRF graphs for all models
IRFandGIRFgraphs( ModelType, NumOut, WishPdynamicsgraphs, WishYieldsgraphs, IRFhoriz, PathsGraphs, OutputType, Economies, Folder2save, verbose )IRFandGIRFgraphs( ModelType, NumOut, WishPdynamicsgraphs, WishYieldsgraphs, IRFhoriz, PathsGraphs, OutputType, Economies, Folder2save, verbose )
ModelType |
character. Estimated model type.Permissible choices: "JPS original", "JPS global", "GVAR single", "JPS multi", "GVAR multi", "JLL original", "JLL No DomUnit", "JLL joint Sigma". |
NumOut |
list. Computed outputs containing model fit, IRFs, FEVDs, GIRFs, GFEVDs and term premia. |
WishPdynamicsgraphs |
logical. Set TRUE to generate risk factor graphs, FALSE otherwise. |
WishYieldsgraphs |
logical. Set TRUE to generate bond yield graphs, FALSE otherwise. |
IRFhoriz |
integer. Desired horizon of analysis for the IRFs. |
PathsGraphs |
character. Path of the folder in which the graphs will be saved. |
OutputType |
character. Available options: "IRF", "GIRF", "IRF Ortho", "GIRF Ortho". |
Economies |
character vector. Names of the |
Folder2save |
character. Folder path where the outputs will be stored. |
verbose |
logical. Flag controlling function messaging. |
- 'autoplot(object, type = "IRF_Factor")', 'autoplot(object, type = "IRF_Yields")',
'autoplot(object, type = "GIRF_Yields")', 'autoplot(object, type = "GIRF_Yields")'.
For JLL-based models: 'autoplot(object, type = "IRF_Factor-_Ortho")',
'autoplot(object, type = "IRF_Yields_Ortho")', 'autoplot(object, type = "GIRF_Yields_Ortho")',
'autoplot(object, type = "GIRF_Yields_Ortho")'.
data("NumOutEx") ModelType <- "JPS original" Economy <- "Brazil" IRFhoriz <- 20 irf_Out <- IRFandGIRFgraphs(ModelType, NumOutEx, WishPdynamicsgraphs = FALSE, WishYieldsgraphs = TRUE, IRFhoriz, PathsGraphs = NULL, OutputType = "GIRF", Economy, Folder2save = NULL, verbose = FALSE )data("NumOutEx") ModelType <- "JPS original" Economy <- "Brazil" IRFhoriz <- 20 irf_Out <- IRFandGIRFgraphs(ModelType, NumOutEx, WishPdynamicsgraphs = FALSE, WishYieldsgraphs = TRUE, IRFhoriz, PathsGraphs = NULL, OutputType = "GIRF", Economy, Folder2save = NULL, verbose = FALSE )
Estimates the P-dynamics from JLL-based models
JLL(NonOrthoFactors, N, JLLinputs, CheckInputs = FALSE)JLL(NonOrthoFactors, N, JLLinputs, CheckInputs = FALSE)
NonOrthoFactors |
numeric matrix ( |
N |
positive integer. Number of country-specific spanned factors. |
JLLinputs |
list. Necessary inputs to estimate JLL models:
|
CheckInputs |
logical. Whether to perform a prior consistency check on the inputs provided in |
List of model parameters from both the orthogonalized and non-orthogonalized versions of the JLL-based models
Td: model time series dimension
C number of countries in the system.
K: total number of risk factors
Jotiskhatira, P. ; Le, A. and Lundblad, C. (2015). "Why do interest rates in different currencies co-move?" (Journal of Financial Economics)
data(RiskFacFull) RF_TS <- RiskFacFull N <- 3 JLLinputs <- list( Economies = c("China", "Brazil", "Mexico", "Uruguay"), DomUnit = "China", WishSigmas = TRUE, SigmaNonOrtho = NULL, JLLModelType = "JLL original" ) JLLPara <- JLL(RF_TS, N, JLLinputs)data(RiskFacFull) RF_TS <- RiskFacFull N <- 3 JLLinputs <- list( Economies = c("China", "Brazil", "Mexico", "Uruguay"), DomUnit = "China", WishSigmas = TRUE, SigmaNonOrtho = NULL, JLLModelType = "JLL original" ) JLLPara <- JLL(RF_TS, N, JLLinputs)
Generates the labels for risk factors used in the model
LabFac(N, DomVar, GlobalVar, Economies, ModelType)LabFac(N, DomVar, GlobalVar, Economies, ModelType)
N |
positive integer. Number of country-specific spanned factors. Must be between 1 and 8. |
DomVar |
character vector. Names of the domestic variables. |
GlobalVar |
character vector. Names of the global variables. |
Economies |
character vector. Names of the economies included in the system. |
ModelType |
character. Model type to be estimated. Permissible choices: "JPS original", "JPS global", "GVAR single", "JPS multi", "GVAR multi", "JLL original", "JLL No DomUnit", "JLL joint Sigma". |
List containing the risk factor labels for spanned, domestic, star, and global variables, as well as tables for each country and all countries.
N <- 2 DomVar <- c("inflation", "Output gap") GlobalVar <- "Commodity Prices" Economies <- c("U.S.", "Canada", "Germany", "Japan") ModelType <- "JPS original" VarLabels <- LabFac(N, DomVar, GlobalVar, Economies, ModelType)N <- 2 DomVar <- c("inflation", "Output gap") GlobalVar <- "Commodity Prices" Economies <- c("U.S.", "Canada", "Germany", "Japan") ModelType <- "JPS original" VarLabels <- LabFac(N, DomVar, GlobalVar, Economies, ModelType)
Read data from Excel files and return a named list of data frames
Load_Excel_Data(ExcelFilePath)Load_Excel_Data(ExcelFilePath)
ExcelFilePath |
character. Path to the Excel file (.xlsx) to load. Must be a valid file path. The file can contain multiple sheets; each sheet will be loaded as a separate data frame in the output list. |
Uses the readxl package to read all sheets from the specified Excel file. Each sheet is returned as a data frame. The output is a named list, with names matching the sheet names in the Excel file.
Named list of data frames, one for each sheet in the Excel file. The names of the list elements correspond to the sheet names.
if (!requireNamespace("readxl", quietly = TRUE)) { stop( "Please install package \"readxl\" to use this feature.", call. = FALSE ) Load_Excel_Data(system.file("extdata", "MacroData.xlsx", package = "MultiATSM")) Load_Excel_Data(system.file("extdata", "YieldsData.xlsx", package = "MultiATSM")) }if (!requireNamespace("readxl", quietly = TRUE)) { stop( "Please install package \"readxl\" to use this feature.", call. = FALSE ) Load_Excel_Data(system.file("extdata", "MacroData.xlsx", package = "MultiATSM")) Load_Excel_Data(system.file("extdata", "YieldsData.xlsx", package = "MultiATSM")) }
Loads data sets from several papers
LoadData(DataPaper)LoadData(DataPaper)
DataPaper |
Available options are |
Complete set of data from several papers.
Bauer and Rudebusch (2017). "Resolving the Spanning Puzzle in Macro-Finance Term Structure Models" (Review of Finance)
Candelon and Moura (2023). "Sovereign yield curves and the COVID-19 in emerging markets" (Economic Modelling)
Candelon and Moura (2024). "A Multicountry Model of the Term Structures of Interest Rates with a GVAR" (Journal of Financial Econometrics)
# Example 1: LoadData("BR_2017") # Example 2: LoadData("CM_2023") # Example 3: LoadData("CM_2024")# Example 1: LoadData("BR_2017") # Example 2: LoadData("CM_2023") # Example 3: LoadData("CM_2024")
Estimation of several classes of affine term structure of interest rates models.
Rubens Moura [email protected]
The package includes several pre-processed datasets used for estimation and replication examples:
Global macro-financial risk factors, namely global economic activity and global inflation.
Global macro-financial risk factors, namely the output growth rate from the U.S. and China and the S&P 500 index.
Domestic macroeconomic risk factors, namely economic activity and inflation.
Domestic macroeconomic risk factors, namely otput growth, inflation, CDS and the COVID-19 reproduction rate
Bilateral trade flow series used in GVAR examples as a proxy measure of cross-country conectdness.
Bilateral trade flow series used in GVAR examples as a proxy measure of cross-country conectdness.
Monthly series of bond yields by maturity for multiple economies.
Weekly series of sovereign bond yields by maturity for multiple economies.
Full set of risk factors (global and domestic) data used throughout the package
List of risk factors used in the estimation of GVAR models.
Replications of the JPS outputs by Bauer and Rudebusch (2017)
List of inputs for an illustrative JPS model with Brazilian data
List of set of parameterafter optimization for an illustrative JPS model with Brazilian data
List of numerical outputs for an illustrative JPS model with Brazilian data
re-loaded examaple of a complete list of several model outputs. Used in the package vignette.
Each dataset is documented separately using '?GlobalMacro', '?DomMacro', '?TradeFlows', '?Yields', etc.
Datasets ending with the suffix _covid are based on those used in Candelon and Moura (2023) and cover Brazil, India, Mexico, and Russia.
The remaining datasets correspond to Candelon and Moura (2024) and include Brazil, China, Mexico, and Uruguay.
Candelon, B. and Moura, R. (2023) "Sovereign yield curves and the COVID-19 in emerging markets". (Economic Modelling)
Candelon, B. and Moura, R. (2024) "A Multicountry Model of the Term Structures of Interest Rates with a GVAR". (Journal of Financial Econometrics)
Numerical outputs for JPS-based model using Brazilian data
data("NumOutEx")data("NumOutEx")
list of inputs and outputs
variance explained per spanned factor
model fit of bond yields
Impulse response function
Forecast error variance decomposition
Generalized impulse response function
Generalized Forecast error variance decomposition
Term Premia decomposition
Constructs the model numerical outputs (model fit, IRFs, GIRFs, FEVDs, GFEVDs, and term premia)
NumOutputs( ModelType, ModelPara, InputsForOutputs, FactorLabels, Economies, Folder2save = NULL, verbose = TRUE )NumOutputs( ModelType, ModelPara, InputsForOutputs, FactorLabels, Economies, Folder2save = NULL, verbose = TRUE )
ModelType |
character. Model type to be estimated. Permissible choices: "JPS original", "JPS global", "GVAR single", "JPS multi", "GVAR multi", "JLL original", "JLL No DomUnit", "JLL joint Sigma". |
ModelPara |
list. Point estimates of the model parameters. See outputs from |
InputsForOutputs |
list. Inputs for generating IRFs, GIRFs, FEVDs, GFEVDs, and Term Premia. |
FactorLabels |
list. Labels for all variables present in the model, as returned by |
Economies |
character vector. Names of the |
Folder2save |
Folder path where the outputs will be stored. Default option saves the outputs in a temporary directory. |
verbose |
Logical flag controlling function messaging. Default is TRUE. |
Both IRFs and FEVDs are computed using the Cholesky decomposition method. The risk factors are ordered as follows: (i) global unspanned factors, and (ii) domestic unspanned and spanned factors for each country. The order of countries follows the sequence defined in the Economies vector.
An object of class 'ATSMNumOutputs' containing the following keys elements:
Model parameter estimates
Model fit of bond yields
IRFs
FEVDs
GIRFs
GFEVDs
Bond yield decomposition
- 'autoplot(object, type)'
Pesaran, H. Hashem, and Shin, Yongcheol. "Generalized impulse response analysis in linear multivariate models." Economics letters 58.1 (1998): 17-29.
data("ParaSetEx") data("InpForOutEx") # Adjust inputs according to the loaded features ModelType <- "JPS original" Economy <- "Brazil" FacLab <- LabFac(N = 1, DomVar = "Eco_Act", GlobalVar = "Gl_Eco_Act", Economy, ModelType) NumOut <- NumOutputs(ModelType, ParaSetEx, InpForOutEx, FacLab, Economy, Folder2save = NULL, verbose = FALSE )data("ParaSetEx") data("InpForOutEx") # Adjust inputs according to the loaded features ModelType <- "JPS original" Economy <- "Brazil" FacLab <- LabFac(N = 1, DomVar = "Eco_Act", GlobalVar = "Gl_Eco_Act", Economy, ModelType) NumOut <- NumOutputs(ModelType, ParaSetEx, InpForOutEx, FacLab, Economy, Folder2save = NULL, verbose = FALSE )
Perform the optimization of the log-likelihood function of the chosen ATSM
Optimization( MLEinputs, StatQ, DataFreq, FactorLabels, Economies, ModelType, tol = 1e-04, EstType = c("BFGS", "Nelder-Mead"), TimeCount = TRUE, BS_outputs = FALSE, verbose = TRUE )Optimization( MLEinputs, StatQ, DataFreq, FactorLabels, Economies, ModelType, tol = 1e-04, EstType = c("BFGS", "Nelder-Mead"), TimeCount = TRUE, BS_outputs = FALSE, verbose = TRUE )
MLEinputs |
list. Contains the inputs for building the log-likelihood function (see |
StatQ |
A logical value indicating whether to impose that the largest eigenvalue under Q is strictly smaller than 1. Set TRUE to impose this restriction. |
DataFreq |
character vector specifying the data frequency. Available options: "Daily All Days", "Daily Business Days", "Weekly", "Monthly", "Quarterly", "Annually". |
FactorLabels |
list. Labels for all variables present in the model, as returned by |
Economies |
character vector. Names of the |
ModelType |
character. Model type to be estimated. Permissible choices: "JPS original", "JPS global", "GVAR single", "JPS multi", "GVAR multi", "JLL original", "JLL No DomUnit", "JLL joint Sigma". |
tol |
numeric. Convergence tolerance. The default is 1e-4. |
EstType |
Available options are"BFGS" and/or "Nelder-Mead". |
TimeCount |
Logical. If TRUE, computes the time required for model estimation. Default is TRUE. |
BS_outputs |
Logical. If TRUE, generates a simplified output list in the bootstrap setting. Default is FALSE. |
verbose |
Logical flag controlling function messaging. Default is TRUE. |
An object of class 'ATSMModelOutputs' containing model outputs after the optimization of the chosen ATSM specification.
- 'summary(object)'
Candelon, C. and Moura, R. (2024). “A Multicountry Model of the Term Structures of Interest Rates with a GVAR.” Journal of Financial Econometrics 22 (5): 1558–87.
Jotikasthira, C; Le, A. and Lundblad, C (2015). “Why Do Term Structures in Different Currencies Co-Move?” Journal of Financial Economics 115: 58–83.
Joslin, S,; Priebsch, M. and Singleton, K. (2014). “Risk Premiums in Dynamic Term Structure Models with Unspanned Macro Risks.” Journal of Finance 69 (3): 1197–1233.
Joslin, S., Singleton, K. and Zhu, H. (2011). "A new perspective on Gaussian dynamic term structure models". The Review of Financial Studies.
Le, A. and Singleton, K. (2018). "A Small Package of Matlab Routines for the Estimation of Some Term Structure Models." Euro Area Business Cycle Network Training School - Term Structure Modelling.
LoadData("CM_2024") ModelType <- "JPS original" Economy <- "Brazil" t0 <- "01-05-2007" # Initial Sample Date (Format: "dd-mm-yyyy") tF <- "01-12-2018" # Final Sample Date (Format: "dd-mm-yyyy") N <- 1 GlobalVar <- "Gl_Eco_Act" # Global Variables DomVar <- "Eco_Act" # Domestic Variables DataFreq <- "Monthly" StatQ <- FALSE FacLab <- LabFac(N, DomVar, GlobalVar, Economy, ModelType) ATSMInputs <- InputsForOpt(t0, tF, ModelType, Yields, GlobalMacro, DomMacro, FacLab, Economy, DataFreq, CheckInputs = FALSE, verbose = FALSE ) OptPara <- Optimization(ATSMInputs, StatQ, DataFreq, FacLab, Economy, ModelType, verbose = FALSE)LoadData("CM_2024") ModelType <- "JPS original" Economy <- "Brazil" t0 <- "01-05-2007" # Initial Sample Date (Format: "dd-mm-yyyy") tF <- "01-12-2018" # Final Sample Date (Format: "dd-mm-yyyy") N <- 1 GlobalVar <- "Gl_Eco_Act" # Global Variables DomVar <- "Eco_Act" # Domestic Variables DataFreq <- "Monthly" StatQ <- FALSE FacLab <- LabFac(N, DomVar, GlobalVar, Economy, ModelType) ATSMInputs <- InputsForOpt(t0, tF, ModelType, Yields, GlobalMacro, DomMacro, FacLab, Economy, DataFreq, CheckInputs = FALSE, verbose = FALSE ) OptPara <- Optimization(ATSMInputs, StatQ, DataFreq, FacLab, Economy, ModelType, verbose = FALSE)
Example for illustration used in the package vignette
data("Out_Example")data("Out_Example")
several model classes
List of parameter estimates of the selected ATSM
General inputs from an ATSM
List of forecast outputs
List of numerical outputs
List of set of outputs after bootstrap
JPS-based model for Brazilian data
data("ParaSetEx")data("ParaSetEx")
list of inputs and outputs
general model inputs
model parameters estimates (JPS form)
Computes the PCA weights for a single country
pca_weights_one_country(Yields, Economy)pca_weights_one_country(Yields, Economy)
Yields |
matrix ( |
Economy |
character. Name of the economy. |
matrix (J x J). Eigenvectors of the variance-covariance matrix of yields.
Td: model time series dimension
J: number of bond yields per country used in estimation
data(Yields) Economy <- "Mexico" pca_weights <- pca_weights_one_country(Yields, Economy)data(Yields) Economy <- "Mexico" pca_weights <- pca_weights_one_country(Yields, Economy)
Plot method for ATSMModelForecast objects
## S3 method for class 'ATSMModelForecast' plot(x, ...)## S3 method for class 'ATSMModelForecast' plot(x, ...)
x |
An object of class |
... |
Additional arguments (not used) |
Print method for ATSMModelInputs objects
## S3 method for class 'ATSMModelInputs' print(x, ...)## S3 method for class 'ATSMModelInputs' print(x, ...)
x |
An object of class 'ATSMModelInputs' |
... |
Additional arguments (not used) |
Full set of risk factors data used in Candelon and Moura (2024, JFEC)
data("RiskFacFull")data("RiskFacFull")
matrix containing the full risk factors: (i) global unspanned factors (global economic activity and global inflation); (ii) domestic unspanned factors (economic activity and inflation); and (iii) domestic spanned factors (level, slope, and curvature). Economic system is formed by Brazil, China, Mexico and Uruguay. The data have monthly frequency and span the period from June/2004 to January/2020.
See data("GlobalMacro") for a detailed data description.
See data("DomMacro") for a detailed data description.
First three principal components of each country set of bond yields. See data("Yields") for a detailed data description.
Candelon, B. and Moura, R. (2024) "A Multicountry Model of the Term Structures of Interest Rates with a GVAR". (Journal of Financial Econometrics)
Spanned and unspanned factors plot
RiskFactorsGraphs( ModelType, WishRFgraphs, ModelOutputs, Economies, FactorLabels, Folder2save, verbose )RiskFactorsGraphs( ModelType, WishRFgraphs, ModelOutputs, Economies, FactorLabels, Folder2save, verbose )
ModelType |
character. Estimated model type. Permissible choices: "JPS original", "JPS global", "GVAR single", "JPS multi", "GVAR multi", "JLL original", "JLL No DomUnit", "JLL joint Sigma". |
WishRFgraphs |
logical. Set TRUE to generate graphs, FALSE otherwise. |
ModelOutputs |
list. Model parameter estimates (see |
Economies |
character vector. Names of the |
FactorLabels |
list. Labels for all variables in the model. |
Folder2save |
character. Folder path where the outputs will be stored. |
verbose |
logical. Flag controlling function messaging. |
- 'autoplot(object, type = "RiskFactors")'
data("ParaSetEx") # Adapt factor labels according to the example ModelType <- "JPS original" Economy <- "Brazil" FacLab <- LabFac(N = 1, DomVar = "Eco_Act", GlobalVar = "Gl_Eco_Act", Economy, ModelType) RiskFactorsGraphs(ModelType, WishRFgraphs = FALSE, ParaSetEx, Economy, FacLab, Folder2save = NULL, verbose = FALSE )data("ParaSetEx") # Adapt factor labels according to the example ModelType <- "JPS original" Economy <- "Brazil" FacLab <- LabFac(N = 1, DomVar = "Eco_Act", GlobalVar = "Gl_Eco_Act", Economy, ModelType) RiskFactorsGraphs(ModelType, WishRFgraphs = FALSE, ParaSetEx, Economy, FacLab, Folder2save = NULL, verbose = FALSE )
Computes the country-specific spanned factors
Spanned_Factors(Yields, Economies, N)Spanned_Factors(Yields, Economies, N)
Yields |
matrix ( |
Economies |
character vector. Names of the |
N |
integer. Desired number of country-specific spanned factors (maximum allowed is |
matrix. Contains the N spanned factors for all countries in the system (CJ x Td).
Td: model time series dimension
C: number of countries in the system
N: number of country-specific spanned factors
J: number of bond yields per country used in estimation
data(Yields) Economies <- c("China", "Brazil", "Mexico", "Uruguay") N <- 3 SpaFact_TS <- Spanned_Factors(Yields, Economies, N)data(Yields) Economies <- c("China", "Brazil", "Mexico", "Uruguay") N <- 3 SpaFact_TS <- Spanned_Factors(Yields, Economies, N)
Summary method for ATSMModelInputs objects
## S3 method for class 'ATSMModelInputs' summary(object, ...)## S3 method for class 'ATSMModelInputs' summary(object, ...)
object |
An object of class 'ATSMModelInputs' |
... |
Additional arguments (not used) |
Summary method for ATSMModelOutputs objects
## S3 method for class 'ATSMModelOutputs' summary(object, ...)## S3 method for class 'ATSMModelOutputs' summary(object, ...)
object |
An object of class 'ATSMModelOutputs' |
... |
Additional arguments (not used) |
Term Premia decomposition graphs for all models
TPDecompGraph( ModelType, NumOut, ModelPara, WishRPgraphs, UnitYields, Economies, PathsGraphs, Folder2Save, verbose )TPDecompGraph( ModelType, NumOut, ModelPara, WishRPgraphs, UnitYields, Economies, PathsGraphs, Folder2Save, verbose )
ModelType |
character. Estimated model type. Permissible choices: "JPS original", "JPS global", "GVAR single", "JPS multi", "GVAR multi", "JLL original", "JLL No DomUnit", "JLL joint Sigma". |
NumOut |
list. Computed outputs containing model fit, IRFs, FEVDs, GIRFs, GFEVDs and risk premia. |
ModelPara |
list. Model parameter estimates (see |
WishRPgraphs |
logical. Set TRUE to generate term premia graphs, FALSE otherwise. |
UnitYields |
character. "Month" if yields are in months, "Year" if in years. |
Economies |
character vector. Names of the |
PathsGraphs |
character. Path of the folder in which the graphs will be saved. |
Folder2Save |
character. Folder path where the outputs will be stored. |
verbose |
logical. Flag controlling function messaging. |
- 'autoplot(object, type = "TermPremia")'
data("ParaSetEx") data("NumOutEx") ModelType <- "JPS original" Economy <- "Brazil" UnitYields <- "Month" TPDecompGraph(ModelType, NumOutEx, ParaSetEx, WishRPgraphs = FALSE, UnitYields, Economy, PathsGraphs = NULL, Folder2Save = NULL, verbose = FALSE )data("ParaSetEx") data("NumOutEx") ModelType <- "JPS original" Economy <- "Brazil" UnitYields <- "Month" TPDecompGraph(ModelType, NumOutEx, ParaSetEx, WishRPgraphs = FALSE, UnitYields, Economy, PathsGraphs = NULL, Folder2Save = NULL, verbose = FALSE )
Trade Flows data used in Candelon and Moura (2024, JFEC)
data("TradeFlows")data("TradeFlows")
A list. Contains bilateral trade flow data for Brazil, China, Mexico, and Uruguay, covering the sample period from 1948 to 2019.
International Monetary Fund - International Trade in Goods (IMTS) <https://data.imf.org/en/datasets/IMF.STA:IMTS>
Candelon, B. and Moura, R. (2024) "A Multicountry Model of the Term Structures of Interest Rates with a GVAR". (Journal of Financial Econometrics)
Trade Flows data used in Candelon and Moura (2023, EM)
data("TradeFlows_covid")data("TradeFlows_covid")
A list. Contains bilateral trade flow data for Brazil, India, Mexico, and Russia, covering the sample period from 1948 to 2020.
International Monetary Fund - International Trade in Goods (IMTS) <https://data.imf.org/en/datasets/IMF.STA:IMTS>
Candelon, B. and Moura, R. (2023) "Sovereign yield curves and the COVID-19 in emerging markets". (Economic Modelling)
Computes the transition matrix required in the estimation of the GVAR model
Transition_Matrix(t_First, t_Last, Economies, type, DataConnectedness)Transition_Matrix(t_First, t_Last, Economies, type, DataConnectedness)
t_First |
character. Sample starting date (format: yyyy). |
t_Last |
character. Sample ending date (format: yyyy). |
Economies |
character vector. Names of the |
type |
character. Method for computing interdependence. Possible options:
|
DataConnectedness |
list or data frame. Data used to compute the transition matrix (e.g., trade flows). |
If there is missing data for any country in a particular year, the transition matrix will include only NAs.
matrix or list of matrices. Time-varying or time-invariant transition matrix depending on 'type'.
t_First <- "2006" t_Last <- "2019" Economies <- c("China", "Brazil", "Mexico", "Uruguay") type <- "Sample Mean" # Load data if Connectedness data from excel, otherwise use pre-saved data GetExcelData <- FALSE if (GetExcelData) { if (!requireNamespace("readxl", quietly = TRUE)) { stop( "Please install package \"readxl\" to use this feature.", call. = FALSE ) DataPath <- system.file("extdata", "TradeData.xlsx", package = "MultiATSM") tab_names_Trade <- readxl::excel_sheets(DataPath) list_all_Trade <- suppressMessages(lapply(tab_names_Trade, function(x) { readxl::read_excel(path = DataPath, sheet = x) })) names(list_all_Trade) <- tab_names_Trade L <- length(list_all_Trade) for (i in 1:L) { Countries <- list_all_Trade[[i]][[1]] list_all_Trade[[i]] <- as.data.frame(list_all_Trade[[i]][, -1]) rownames(list_all_Trade[[i]]) <- Countries } DataConnectedness <- list_all_Trade } } else { data(TradeFlows) DataConnectedness <- TradeFlows } W_mat <- Transition_Matrix(t_First, t_Last, Economies, type, DataConnectedness)t_First <- "2006" t_Last <- "2019" Economies <- c("China", "Brazil", "Mexico", "Uruguay") type <- "Sample Mean" # Load data if Connectedness data from excel, otherwise use pre-saved data GetExcelData <- FALSE if (GetExcelData) { if (!requireNamespace("readxl", quietly = TRUE)) { stop( "Please install package \"readxl\" to use this feature.", call. = FALSE ) DataPath <- system.file("extdata", "TradeData.xlsx", package = "MultiATSM") tab_names_Trade <- readxl::excel_sheets(DataPath) list_all_Trade <- suppressMessages(lapply(tab_names_Trade, function(x) { readxl::read_excel(path = DataPath, sheet = x) })) names(list_all_Trade) <- tab_names_Trade L <- length(list_all_Trade) for (i in 1:L) { Countries <- list_all_Trade[[i]][[1]] list_all_Trade[[i]] <- as.data.frame(list_all_Trade[[i]][, -1]) rownames(list_all_Trade[[i]]) <- Countries } DataConnectedness <- list_all_Trade } } else { data(TradeFlows) DataConnectedness <- TradeFlows } W_mat <- Transition_Matrix(t_First, t_Last, Economies, type, DataConnectedness)
Estimates a standard VAR(1)
VAR(RiskFactors, VARtype, Bcon_Mat = NULL)VAR(RiskFactors, VARtype, Bcon_Mat = NULL)
RiskFactors |
numeric matrix ( |
VARtype |
character. Permissible choices: "unconstrained" or "constrained". |
Bcon_Mat |
matrix ( |
list. Contains:
intercept (K x 1)
feedback matrix (K x K)
variance-covariance matrix (K x K) of a VAR(1)
Td: model time series dimension
N: number of country-specific spanned factors
K: total number of risk factors
data(RiskFacFull) # Example 1: unconstrained case VAR_para1 <- VAR(RiskFacFull, VARtype = "unconstrained") # Example 2: constrained case K <- nrow(RiskFacFull) Bcon_Mat <- matrix(0, nrow = K, ncol = K + 1) Bcon_Mat[, 1:3] <- NaN VAR_para2 <- VAR(RiskFacFull, VARtype = "constrained", Bcon_Mat)data(RiskFacFull) # Example 1: unconstrained case VAR_para1 <- VAR(RiskFacFull, VARtype = "unconstrained") # Example 2: constrained case K <- nrow(RiskFacFull) Bcon_Mat <- matrix(0, nrow = K, ncol = K + 1) Bcon_Mat[, 1:3] <- NaN VAR_para2 <- VAR(RiskFacFull, VARtype = "constrained", Bcon_Mat)
Yields data used in Candelon and Moura (2024, JFEC)
data("Yields")data("Yields")
A matrix containing bond yields with maturities of 3, 6, 12, 36, 60, and 120 months for Brazil, China, Mexico, and Uruguay. The data are at monthly frequency and cover the period from June 2004, to January 2020.
Swap fixed-DI contracts (derivative securities indexed to the interbank loan rates). <https://www.b3.com.br/pt_br/market-data-e-indices/servicos-de-dados/market-data/consultas/mercado-de-derivativos/precos-referenciais/taxas-referenciais-bm-fbovespa/>
Government bond yield data in domestic currency. Simulated data constructed using Bloomberg bond yield series.
Government bond yield data in domestic currency. Simulated data constructed using Bloomberg bond yield series.
Government bond yield data in US dollars <https://web.bevsa.com.uy/CurvasVectorPrecios/CurvasIndices/CUD.aspx>.
Candelon, B. and Moura, R. (2024) "A Multicountry Model of the Term Structures of Interest Rates with a GVAR". (Journal of Financial Econometrics)
Bond yield data used in Candelon and Moura (2023)
data("Yields_covid")data("Yields_covid")
A matrix containing Government bond yields with maturities of 12, 24, 36, 60, and 120 months for Brazil, India, Mexico, and Russia. The data are at weekly frequency and cover the period from March 22, 2020, to September 26, 2021.
Simulated data constructed using Bloomberg bond yield series.
Candelon, B. and Moura, R. (2023) "Sovereign yield curves and the COVID-19 in emerging markets". (Economic Modelling)