Title: | Multicountry Term Structure of Interest Rates Models |
---|---|
Description: | Estimation routines for several classes of affine term structure of interest rates models. All the models are based on the single-country unspanned macroeconomic risk framework from Joslin, Priebsch, and Singleton (2014, JF) <doi:10.1111/jofi.12131>. Multicountry extensions such as the ones of 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 (Forthcoming, JFEC) <doi:10.1093/jjfinec/nbae008> are also available. |
Authors: | Rubens Moura [aut, cre] |
Maintainer: | Rubens Moura <[email protected]> |
License: | GPL-2 | GPL-3 |
Version: | 1.0.0 |
Built: | 2024-10-31 06:02:16 UTC |
Source: | https://github.com/cran/MultiATSM |
Estimates an unbiased VAR(1) using stochastic approximation (Bauer, Rudebusch and Wu, 2012)
Bias_Correc_VAR( ModelType, BRWinputs, RiskFactors, N, Economies, FactorLabels, GVARinputs = NULL, JLLinputs = NULL, ev_restr = 1, nargout = 4 )
Bias_Correc_VAR( ModelType, BRWinputs, RiskFactors, N, Economies, FactorLabels, GVARinputs = NULL, JLLinputs = NULL, ev_restr = 1, nargout = 4 )
ModelType |
A character vector indicating the model type to be estimated. |
BRWinputs |
A list containing the necessary inputs for the BRW model estimation:
|
RiskFactors |
A numeric matrix (T x F) representing the time series of risk factors. |
N |
Integer. Number of country-specific spanned factors. |
Economies |
A character vector containing the names of the economies included in the system. |
FactorLabels |
A list of character vectors with labels for all variables in the model. |
GVARinputs |
List. Inputs for GVAR model estimation (see |
JLLinputs |
List. Inputs for JLL model estimation (see |
ev_restr |
Numeric. Restriction on the largest eigenvalue under the P-measure. Default is 1. |
nargout |
Integer. Number of elements in the output list. Default is 4. |
Bias-corrected VAR paramaters based on the framework of Bauer, Rudebusch and Wu (2012). The list contains:
Phi_tilde
: estimated coefficient matrix (F x F);
mu_tilde
: estimated intercept (F x 1);
V_tilde
: estimated variance-covariance matrix (F x F);
dist
: root mean square distance (scalar);
Phi_sample
: sample estimated variance-covariance matrix used in the checks (F x F x B_check) - this output is
reported if nargout is 5.
Bauer, Rudebusch and, Wu (2012). "Correcting Estimation Bias in Dynamic Term Structure Models"
This function is based on the est_unb_var
Matlab function available at Cynthia Wu's website
(https://sites.google.com/view/jingcynthiawu/).
data(CM_Factors) Factors <- t(RiskFactors[1:7,]) BRWinputs <- list(flag_mean = TRUE, 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, N, Economies, FactorLabels)
data(CM_Factors) Factors <- t(RiskFactors[1:7,]) BRWinputs <- list(flag_mean = TRUE, 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, N, Economies, FactorLabels)
Generates the bootstrap-related outputs
Bootstrap( ModelType, ModelParaPE, NumOutPE, Economies, InputsForOutputs, FactorLabels, JLLlist = NULL, GVARlist = NULL, WishBC = 0, BRWlist = NULL )
Bootstrap( ModelType, ModelParaPE, NumOutPE, Economies, InputsForOutputs, FactorLabels, JLLlist = NULL, GVARlist = NULL, WishBC = 0, BRWlist = NULL )
ModelType |
A character vector indicating the model type to be estimated. |
ModelParaPE |
A list containing the point estimates of the model parameters. For details, refer to the outputs from the |
NumOutPE |
The point estimate derived from numerical outputs. See the outputs from the |
Economies |
A character vector containing the names of the economies included in the system. |
InputsForOutputs |
A list containing the necessary inputs for generating IRFs, GIRFs, FEVDs, GFEVDs and Term Premia. |
FactorLabels |
A list of character vectors with labels for all variables in the model. |
JLLlist |
List. Inputs for JLL model estimation (see |
GVARlist |
List. Inputs for GVAR model estimation (see |
WishBC |
Whether to estimate the physical parameter model with bias correction, based on the method by Bauer, Rudebusch and Wu (2012) (see |
BRWlist |
List of necessary inputs for performing the bias-corrected estimation (see |
list containing the following elements:
list of model parameters for one each one the draws;
list of numerical outputs (IRFs, GIRFs, FEVDs, GFEVDs and Term Premia) for each one of the draws;
Confidence bounds for the chosen level of significance.
This function is a modified and extended version of the VARirbound
function from "A toolbox for VAR analysis"
by Ambrogio Cesa-Bianchi (https://github.com/ambropo/VAR-Toolbox)
# See an example of implementation in the vignette file of this package (Section 4).
# See an example of implementation in the vignette file of this package (Section 4).
Unspanned macro risk model outputs by Bauer and Rudebusch (2017)
data("BR_jps_gro_R3")
data("BR_jps_gro_R3")
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, Wgvar = NULL, DataPathMacro = NULL, DataPathYields = NULL )
DatabasePrep( t_First, t_Last, Economies, N, FactorLabels, ModelType, Wgvar = NULL, DataPathMacro = NULL, DataPathYields = NULL )
t_First |
Start date of the sample period in the format yyyy-mm-dd. |
t_Last |
End date of the sample period in the format yyyy-mm-dd. |
Economies |
A character vector containing the names of the economies included in the system. |
N |
Integer. Number of country-specific spanned factors. |
FactorLabels |
A list of character vectors with labels for all variables in the model. |
ModelType |
A character vector indicating the model type to be estimated. |
Wgvar |
GVAR transition matrix of size C x C, applicable if a GVAR-type model is selected. Default is NULL. |
DataPathMacro |
File path to the Excel file containing macroeconomic data, if provided. The default path points to the Excel file available within the package. |
DataPathYields |
File path to the Excel file containing yields data, if provided. The default path points to the Excel file available within the package |
List containing the risk factor set used in the estimation of the GVAR-based models
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 <- 3 ModelType <- "GVAR multi" FactorLabels <- LabFac(N, DomVar, GlobalVar, Economies, ModelType) Wgvar <- Transition_Matrix(t_First = "2006", t_Last= "2019", Economies, type = "Sample Mean") GVARFactors <- DatabasePrep(t0, tF, Economies, N, FactorLabels, ModelType, Wgvar)
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 <- 3 ModelType <- "GVAR multi" FactorLabels <- LabFac(N, DomVar, GlobalVar, Economies, ModelType) Wgvar <- Transition_Matrix(t_First = "2006", t_Last= "2019", Economies, type = "Sample Mean") GVARFactors <- DatabasePrep(t0, tF, Economies, N, FactorLabels, ModelType, Wgvar)
Retrieves data from Excel and build the database used in the model estimation
DataForEstimation( t0, tF, Economies, N, FactorLabels, ModelType, DataFrequency, W_type = NULL, t_First_Wgvar = NULL, t_Last_Wgvar = NULL, DataPathMacro = NULL, DataPathYields = NULL, DataPathTrade = NULL )
DataForEstimation( t0, tF, Economies, N, FactorLabels, ModelType, DataFrequency, W_type = NULL, t_First_Wgvar = NULL, t_Last_Wgvar = NULL, DataPathMacro = NULL, DataPathYields = NULL, DataPathTrade = NULL )
t0 |
Start date of the sample period in the format yyyy-mm-dd. |
tF |
End date of the sample period in the format yyyy-mm-dd. |
Economies |
A character vector containing the names of the economies included in the system. |
N |
Integer. Number of country-specific spanned factors. |
FactorLabels |
String-list based which contains the labels of all the variables present in the model |
ModelType |
String-vector containing the label of the model to be estimated |
DataFrequency |
Character-based-vector. Avaialable options are: "Daily All Days", "Daily Business Days", "Weekly", "Monthly", "Quarterly", "Annually" |
W_type |
Three possibilities:
|
t_First_Wgvar |
Sample starting date (year) |
t_Last_Wgvar |
Sample last date (year) |
DataPathMacro |
Path of the Excel file containing the macroeconomic data (if any). The default is linked to the excel file present in the package. |
DataPathYields |
Path of the Excel file containing the yields data (if any). The default is linked to the excel file present in the package. |
DataPathTrade |
Path of the Excel file containing the trade data (if any). The default is linked to the excel file present in the package. |
A list containing the
time series of the complete set of bond yields (matrix, J x T or CJ x T);
time series of the complete set risk factors (matrix, K x T);
'GVARFactors': list of all variables that are used in the estimation of the VARX
(see e.g. CM_Factors_GVAR
file). If the estimated model type is not GVAR-based, then returns NULL.
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" DataModel <- DataForEstimation(t0, tF, Economies, N, FactorLabels, ModelType, DataFrequency)
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" DataModel <- DataForEstimation(t0, tF, Economies, N, FactorLabels, ModelType, DataFrequency)
Risk factors data used in Candelon and Moura (forthcoming, JFEC)
data("CM_DomMacroFactors")
data("CM_DomMacroFactors")
matrix containing the risk factors of the models
Candelon, B. and Moura, R. (Forthcoming) "A Multicountry Model of the Term Structures of Interest Rates with a GVAR". (Journal of Financial Econometrics)
Risk factors data used in the GVAR models - Candelon and Moura (2023)
data("CM_DomMacro_2023")
data("CM_DomMacro_2023")
list containing the variables used in the GVAR models
Candelon, B. and Moura, R. (2023) "Sovereign yield curves and the COVID-19 in emerging markets". (Economic Modelling)
Risk factors data used in the GVAR models - Candelon and Moura (forthcoming, JFEC)
data("CM_Factors_GVAR")
data("CM_Factors_GVAR")
list containing the variables used in the GVAR models
Candelon, B. and Moura, R. (Forthcoming) "A Multicountry Model of the Term Structures of Interest Rates with a GVAR". (Journal of Financial Econometrics)
Generates forecasts of bond yields for all model types
ForecastYields( ModelType, ModelPara, InputsForOutputs, FactorLabels, Economies, JLLlist = NULL, GVARlist = NULL, WishBRW, BRWlist = NULL )
ForecastYields( ModelType, ModelPara, InputsForOutputs, FactorLabels, Economies, JLLlist = NULL, GVARlist = NULL, WishBRW, BRWlist = NULL )
ModelType |
A character vector indicating the model type to be estimated. |
ModelPara |
A list containing the point estimates of the model parameters. For details, refer to the outputs from the |
InputsForOutputs |
A list containing the necessary inputs for generating IRFs, GIRFs, FEVDs, GFEVDs and Term Premia. |
FactorLabels |
A list of character vectors with labels for all variables in the model. |
Economies |
A character vector containing the names of the economies included in the system. |
JLLlist |
A list of necessary inputs for the estimation of JLL-based models (see the |
GVARlist |
A list containing the necessary inputs for the estimation of GVAR-based models (see the |
WishBRW |
Whether to estimate the physical parameter model with bias correction, based on the method by Bauer, Rudebusch and Wu (2012) (see |
BRWlist |
List of necessary inputs for performing the bias-corrected estimation (see |
List 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
# See an example of implementation in the vignette file of this package (Section 4).
# See an example of implementation in the vignette file of this package (Section 4).
Risk factors data used in Candelon and Moura (2023)
data("CM_GlobalMacro_2023")
data("CM_GlobalMacro_2023")
matrix containing the risk factors of the models
Candelon, B. and Moura, R. (2023) "Sovereign yield curves and the COVID-19 in emerging markets". (Economic Modelling)
Risk factors data used in Candelon and Moura (forthcoming, JFEC)
data("CM_GlobalMacroFactors")
data("CM_GlobalMacroFactors")
matrix containing the risk factors of the models
Candelon, B. and Moura, R. (Forthcoming) "A Multicountry Model of the Term Structures of Interest Rates with a GVAR". (Journal of Financial Econometrics)
Estimates a GVAR(1) and a VARX(1,1,1) models
GVAR(GVARinputs, N, CheckInputs = F)
GVAR(GVARinputs, N, CheckInputs = F)
GVARinputs |
GVARinputs List. Inputs for GVAR model estimation:
|
N |
Integer. Number of country-specific spanned factors. |
CheckInputs |
A logical flag to indicate whether to perform a prior consistency check on the inputs provided in |
A list containing
parameters of the country-specific VARX(1,1,1)
intercept (M+Nx1);
phi_1 (M+N x M+N);
phi_1^star (M+N x M+N);
phi_g (M+N x M+N);
Sigma (M+N x G)
parameters of the GVAR.
F0 (F X 1);
F1 (F x F);
Sigma_y (F x F)
Chudik and Pesaran, (2016). "Theory and Practice of GVAR modelling" (Journal of Economic Surveys)
data(CM_Factors_GVAR) GVARinputs <- list( Economies = c("China", "Brazil", "Mexico", "Uruguay"), GVARFactors = FactorsGVAR, 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(CM_Factors_GVAR) GVARinputs <- list( Economies = c("China", "Brazil", "Mexico", "Uruguay"), GVARFactors = FactorsGVAR, 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)
Generates several inputs that are necessary to build the likelihood function
InputsForOpt( InitialSampleDate, FinalSampleDate, ModelType, Yields, GlobalMacro, DomMacro, FactorLabels, Economies, DataFrequency, GVARlist = NULL, JLLlist = NULL, WishBRW = 0, BRWlist = NULL, UnitYields = "Month", CheckInputs = TRUE, BS_Adj = FALSE )
InputsForOpt( InitialSampleDate, FinalSampleDate, ModelType, Yields, GlobalMacro, DomMacro, FactorLabels, Economies, DataFrequency, GVARlist = NULL, JLLlist = NULL, WishBRW = 0, BRWlist = NULL, UnitYields = "Month", CheckInputs = TRUE, BS_Adj = FALSE )
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 |
A character vector indicating the model type to be estimated. |
Yields |
A numerical matrix with time series of yields (JxT or CJ x T) |
GlobalMacro |
A numerical matrix with time series of the global risk factors (G x T) |
DomMacro |
A numerical matrix with time series of the country-specific risk factors for all C countries (CM x T) |
FactorLabels |
A list of character vectors with labels for all variables in the model. |
Economies |
A character vector containing the names of the economies included in the system. |
DataFrequency |
A character vector specifying the frequency of the data. Available options are: "Daily All Days", "Daily Business Days", "Weekly", "Monthly", "Quarterly", or "Annually". |
GVARlist |
A list containing the necessary inputs for the estimation of GVAR-based models |
JLLlist |
A list of necessary inputs for the estimation of JLL-based models. If the chosen model is "JLL original" or "JLL joint Sigma", then a dominant unit economy must be chosen. Otherwise, this list must be set as 'None'. |
WishBRW |
Whether to estimate the physical parameter model with bias correction, based on the method by Bauer, Rudebusch and Wu (2012) (see |
BRWlist |
List of necessary inputs for performing the bias-corrected estimation (see |
UnitYields |
A character string indicating the maturity unit of yields. Options are: (i) "Month" for yields expressed in months, or (ii) "Year" for yields expressed in years. Default is "Month". |
CheckInputs |
A logical value indicating whether to perform a prior check on the consistency of the provided input list. Default is TRUE. |
BS_Adj |
A logical value indicating whether to adjust the global series for the sepQ models in the Bootstrap setting. Default is FALSE. |
List of necessary inputs for performing the model optimization.
# Example 1: data(CM_GlobalMacroFactors) data(CM_DomMacroFactors) data(CM_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, GlobalMacroVar, DomesticMacroVar, FactorLabels, Economies, DataFreq, CheckInputs = 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") ATSMInputs <- InputsForOpt(t0, tF, ModelType, Yields, GlobalMacroVar, DomesticMacroVar, FactorLabels, Economies, DataFreq, GVARlist, CheckInputs = FALSE) # Example 3: if (requireNamespace('neldermead', quietly = TRUE)) { 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, GlobalMacroVar, DomesticMacroVar, FactorLabels, Economies, DataFreq, JLLlist = JLLinputs, CheckInputs = FALSE) } else { message("skipping functionality due to missing Suggested dependency") }
# Example 1: data(CM_GlobalMacroFactors) data(CM_DomMacroFactors) data(CM_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, GlobalMacroVar, DomesticMacroVar, FactorLabels, Economies, DataFreq, CheckInputs = 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") ATSMInputs <- InputsForOpt(t0, tF, ModelType, Yields, GlobalMacroVar, DomesticMacroVar, FactorLabels, Economies, DataFreq, GVARlist, CheckInputs = FALSE) # Example 3: if (requireNamespace('neldermead', quietly = TRUE)) { 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, GlobalMacroVar, DomesticMacroVar, FactorLabels, Economies, DataFreq, JLLlist = JLLinputs, CheckInputs = FALSE) } else { message("skipping functionality due to missing Suggested dependency") }
Collects the inputs that are used to construct the numerical and the graphical outputs
InputsForOutputs( ModelType, Horiz, ListOutputWished, OutputLabel, WishStationarityQ, DataFrequency, WishGraphYields = 0, WishGraphRiskFactors = 0, WishOrthoJLLgraphs = 0, WishForwardPremia = 0, LimFP = NULL, WishBootstrap = 0, ListBoot = NULL, WishForecast = 0, ListForecast = NULL, UnitYields = "Month" )
InputsForOutputs( ModelType, Horiz, ListOutputWished, OutputLabel, WishStationarityQ, DataFrequency, WishGraphYields = 0, WishGraphRiskFactors = 0, WishOrthoJLLgraphs = 0, WishForwardPremia = 0, LimFP = NULL, WishBootstrap = 0, ListBoot = NULL, WishForecast = 0, ListForecast = NULL, UnitYields = "Month" )
ModelType |
A character vector indicating the model type to be estimated. |
Horiz |
A numeric scalar specifying the desired analysis horizon for the outputs. |
ListOutputWished |
A list of desired graphical outputs. Available options are: "Fit", "IRF", "FEVD", "GIRF", "GFEVD", "TermPremia". |
OutputLabel |
A string for the name of the output label to be stored. |
WishStationarityQ |
A binary variable (1 or 0) indicating whether to impose that the largest eigenvalue under Q is strictly smaller than 1. Set to 1 to impose the restriction, or 0 otherwise. |
DataFrequency |
A character vector specifying the data frequency. Available options: "Daily All Days", "Daily Business Days", "Weekly", "Monthly", "Quarterly", "Annually". |
WishGraphYields |
A binary variable (1 or 0) indicating whether the user wishes to generate graphs for yields. Default is 0. |
WishGraphRiskFactors |
A binary variable (1 or 0) indicating whether the user wishes to generate graphs for risk factors. Default is 0. |
WishOrthoJLLgraphs |
A binary variable (1 or 0) indicating whether the user wishes to generate orthogonalized JLL-based graphs. Default is 0. |
WishForwardPremia |
A binary variable (1 or 0) indicating whether the user wishes to generate forward premia graphs. Default is 0. |
LimFP |
A numeric vector containing the maturities associated with the start and end dates of the loan. |
WishBootstrap |
A binary variable (1 or 0) indicating whether the user wishes to perform bootstrap-based estimation. Default is 0. |
ListBoot |
A List containing the following four elements:
|
WishForecast |
A binary variable (1 or 0) indicating whether the user wishes to generate forecasts. Default is 0. |
ListForecast |
A list containing the following three elements:
|
UnitYields |
A character string indicating the maturity unit of yields. Options are: (i) "Month" for yields expressed in months, or (ii) "Year" for yields expressed in years. Default is "Month". |
List of necessary inputs to generate the graphs of the outputs of the desired model
ModelType <- "JPS original" Horiz <- 100 DesiredOutputGraphs <- c("Fit", "GIRF", "GFEVD") OutputLabel <- "Test" WishStationarityQ <- 1 WishGraphRiskFac <- 0 WishGraphYields <- 1 InputsList <- InputsForOutputs(ModelType, Horiz, DesiredOutputGraphs, OutputLabel, WishStationarityQ, WishGraphYields, WishGraphRiskFac)
ModelType <- "JPS original" Horiz <- 100 DesiredOutputGraphs <- c("Fit", "GIRF", "GFEVD") OutputLabel <- "Test" WishStationarityQ <- 1 WishGraphRiskFac <- 0 WishGraphYields <- 1 InputsList <- InputsForOutputs(ModelType, Horiz, DesiredOutputGraphs, OutputLabel, WishStationarityQ, WishGraphYields, WishGraphRiskFac)
Estimates the P-dynamics from JLL-based models
JLL(NonOrthoFactors, N, JLLinputs, CheckInputs = F)
JLL(NonOrthoFactors, N, JLLinputs, CheckInputs = F)
NonOrthoFactors |
A numeric matrix (F x T) representing the time series of risk factors before the orthogonalization process. |
N |
Integer. Number of country-specific spanned factors. |
JLLinputs |
List of necessary inputs to estimate JLL models:
|
CheckInputs |
A logical flag to indicate 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's based models
Jotiskhatira, Le and Lundblad (2015). "Why do interest rates in different currencies co-move?" (Journal of Financial Economics)
data(CM_Factors) RF_TS <- RiskFactors N <- 3 JLLinputs <- list(Economies = c("China", "Brazil", "Mexico", "Uruguay"), DomUnit = "China", WishSigmas = 1, SigmaNonOrtho = NULL, JLLModelType = "JLL original") JLLPara <- JLL(RF_TS, N, JLLinputs)
data(CM_Factors) RF_TS <- RiskFactors N <- 3 JLLinputs <- list(Economies = c("China", "Brazil", "Mexico", "Uruguay"), DomUnit = "China", WishSigmas = 1, SigmaNonOrtho = NULL, JLLModelType = "JLL original") JLLPara <- JLL(RF_TS, N, JLLinputs)
Generates the labels factors
LabFac(N, DomVar, GlobalVar, Economies, ModelType)
LabFac(N, DomVar, GlobalVar, Economies, ModelType)
N |
Integer. Number of country-specific spanned factors. |
DomVar |
A character vector containing the names of the domestic variables. |
GlobalVar |
A character vector containing the names of the global variables. |
Economies |
A character vector containing the names of the economies included in the system. |
ModelType |
A character vector indicating the model type to be estimated. |
List containing the risk factor labels
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)
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 (forthcoming). "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")
Unspanned macro risk model outputs by the MultiATSM package
data("JPSrep")
data("JPSrep")
list of inputs and outputs
general model inputs
model parameters estimates (JPS form)
log-likelihood of the observations
model parameters estimates (rotation form)
Estimation of several classes of affine term structure of interest rates models.
Rubens Moura [email protected]
Constructs the model numerical outputs (model fit, IRFs, GIRFs, FEVDs, GFEVDs, and risk premia decomposition)
NumOutputs(ModelType, ModelPara, InputsForOutputs, FactorLabels, Economies)
NumOutputs(ModelType, ModelPara, InputsForOutputs, FactorLabels, Economies)
ModelType |
A character vector indicating the model type to be estimated. |
ModelPara |
A list containing the point estimates of the model parameters. For details, refer to the outputs from the |
InputsForOutputs |
A list containing the necessary inputs for generating IRFs, GIRFs, FEVDs, GFEVDs and Term Premia. |
FactorLabels |
A list of character vectors with labels for all variables in the model. |
Economies |
A character vector containing the names of the economies included in the system. |
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.
List of the model numerical outputs, namely
Model fit of bond yields
IRFs
FEVDs
GIRFs
GFEVDs
Bond yield decomposition
Pesaran, H. Hashem, and Shin, Yongcheol. "Generalized impulse response analysis in linear multivariate models." Economics letters 58.1 (1998): 17-29.
# See an example of implementation in the vignette file of this package (Section 4).
# See an example of implementation in the vignette file of this package (Section 4).
Perform the optimization of the log-likelihood function of the chosen ATSM
Optimization( MLEinputs, StatQ, DataFreq, FactorLabels, Economies, ModelType, tol = 1e-04, TimeCount = TRUE, BS_outputs = FALSE )
Optimization( MLEinputs, StatQ, DataFreq, FactorLabels, Economies, ModelType, tol = 1e-04, TimeCount = TRUE, BS_outputs = FALSE )
MLEinputs |
A list containing the necessary inputs for building the log-likelihood function (see |
StatQ |
A binary variable (1 or 0) indicating whether to impose that the largest eigenvalue under Q is strictly smaller than 1. Set to 1 to impose the restriction, or 0 otherwise. |
DataFreq |
A character vector specifying the data frequency. Available options: "Daily All Days", "Daily Business Days", "Weekly", "Monthly", "Quarterly", "Annually". |
FactorLabels |
A list of character vectors with labels for all variables in the model. |
Economies |
A character vector containing the names of the economies included in the system. |
ModelType |
A character vector indicating the model type to be estimated. |
tol |
Convergence tolerance (scalar). The default is 1e-4. |
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. |
An extensive list containing model outputs after the optimization of the chosen ATSM specification.
This function is partially adapted from the LS__opt
function by Le and Singleton (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).
Available at: https://cepr.org/40029
# See examples in the vignette file of this package (Section 4).
# See examples in the vignette file of this package (Section 4).
Weight matrix from principal components
pca_weights_one_country(Y, Economy)
pca_weights_one_country(Y, Economy)
Y |
A numeric matrix (T x J) representing the time series of bond yields of a specific country |
Economy |
String-vector containing the name of a single economy. |
A matrix (J x J) that corresponds to the eigenvectors of the variance-covariance matrix of yields
data("CM_Yields") pca_weights_one_country(Yields, Economy= "Brazil")
data("CM_Yields") pca_weights_one_country(Yields, Economy= "Brazil")
Risk factors data used in Candelon and Moura (forthcoming, JFEC)
data("CM_Factors")
data("CM_Factors")
matrix containing the risk factors of the models
Candelon, B. and Moura, R. (Forthcoming) "A Multicountry Model of the Term Structures of Interest Rates with a GVAR". (Journal of Financial Econometrics)
Computes the country-specific spanned factors
Spanned_Factors(Yields, Economies, N)
Spanned_Factors(Yields, Economies, N)
Yields |
matrix (J x T), where J is the number of maturities and T is the length of the time series. |
Economies |
A character vector containing the names of the economies included in the system. |
N |
Scalar representing the desired number of country-specific spanned factors (maximum allowed is N = J). |
Matrix containing the N spanned for all the countries of the system (CJ xT)
data(CM_Yields) Economies <- c("China", "Brazil", "Mexico", "Uruguay") N <- 3 SpaFact_TS <- Spanned_Factors(Yields, Economies, N)
data(CM_Yields) Economies <- c("China", "Brazil", "Mexico", "Uruguay") N <- 3 SpaFact_TS <- Spanned_Factors(Yields, Economies, N)
Generates the star variables necessary for the GVAR estimation
StarFactors(RiskFactors, Economies, W)
StarFactors(RiskFactors, Economies, W)
RiskFactors |
time series of the risk factors (F x T) |
Economies |
string-vector containing the names of the economies which are part of the economic system |
W |
GVAR transition matrix (C x C) |
List containg the star factors of each country of the economic system
data(CM_Factors) Economies <- c("China", "Brazil", "Mexico", "Uruguay") 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, dimnames = list(Economies, Economies)) SF <- StarFactors(RiskFactors, Economies, Wgvar)
data(CM_Factors) Economies <- c("China", "Brazil", "Mexico", "Uruguay") 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, dimnames = list(Economies, Economies)) SF <- StarFactors(RiskFactors, Economies, Wgvar)
Trade Flows data used in Candelon and Moura (2023)
data("CM_Trade")
data("CM_Trade")
list containing the bilateral trade flows
Candelon, B. and Moura, R. (2023) "Sovereign yield curves and the COVID-19 in emerging markets". (Economic Modelling)
Trade Flows data used in Candelon and Moura (forthcoming, JFEC)
data("CM_Trade")
data("CM_Trade")
list containing the bilateral trade flows
Candelon, B. and Moura, R. (Forthcoming) "A Multicountry Model of the Term Structures of Interest Rates with a GVAR". (Journal of Financial Econometrics)
Computes the transition matrix required in the estimation of the GVAR model
Transition_Matrix( t_First, t_Last, Economies, type, DataConnectedness = NULL, DataPath = NULL )
Transition_Matrix( t_First, t_Last, Economies, type, DataConnectedness = NULL, DataPath = NULL )
t_First |
Sample starting date (in the format: yyyy). |
t_Last |
Sample ending date (in the format: yyyy). |
Economies |
A character vector containing the names of the economies included in the system. |
type |
A character string indicating the method for computing interdependence. Possible options include:
|
DataConnectedness |
Data used to compute the transition matrix. Default is set to NULL. |
DataPath |
Path to the Excel file containing the data (if applicable). The default is linked to the Excel file available in the package. |
If there is missing data for any country of the system for that particularly year, then the transition matrix will include only NAs.
matrix or list of matrices
data(CM_Trade) t_First <- "2006" t_Last <- "2019" Economies <- c("China", "Brazil", "Mexico", "Uruguay") type <- "Sample Mean" W_mat <- Transition_Matrix(t_First, t_Last, Economies, type, DataConnectedness = TradeFlows)
data(CM_Trade) t_First <- "2006" t_Last <- "2019" Economies <- c("China", "Brazil", "Mexico", "Uruguay") type <- "Sample Mean" W_mat <- Transition_Matrix(t_First, t_Last, Economies, type, DataConnectedness = TradeFlows)
Estimates a standard VAR(1)
VAR(RiskFactors, VARtype, Bcon = NULL)
VAR(RiskFactors, VARtype, Bcon = NULL)
RiskFactors |
A numeric matrix (FTx T) representing the time series of risk factors. |
VARtype |
String vector with two possible values: 'unconstrained' or 'constrained'. |
Bcon |
Constraints matrix (F+1 x N), which includes an intercept. If Bcon(i,j) = NA, then B(i,j) is treated as a free parameter. |
intercept, feedback matrix and the variance-covariance matrix of a VAR(1)
data("CM_Factors") #Example 1: unconstrained case VAR(RiskFactors, VARtype= 'unconstrained') #Example 2: constrainted case K <- nrow(RiskFactors) Bcon <-matrix(0, nrow = K, ncol = K+1) Bcon[ , 1:3] <- NaN VAR(RiskFactors, VARtype= 'constrained', Bcon)
data("CM_Factors") #Example 1: unconstrained case VAR(RiskFactors, VARtype= 'unconstrained') #Example 2: constrainted case K <- nrow(RiskFactors) Bcon <-matrix(0, nrow = K, ncol = K+1) Bcon[ , 1:3] <- NaN VAR(RiskFactors, VARtype= 'constrained', Bcon)
Yields data used in Candelon and Moura (forthcoming, JFEC)
Bond yield data used in Candelon and Moura (2023)
data("CM_Yields") data("CM_Yields_2023")
data("CM_Yields") data("CM_Yields_2023")
matrix containing the Yields of the models
matrix containing the Yields of the models
Candelon, B. and Moura, R. (Forthcoming) "A Multicountry Model of the Term Structures of Interest Rates with a GVAR". (Journal of Financial Econometrics)
Candelon, B. and Moura, R. (2023) "Sovereign yield curves and the COVID-19 in emerging markets". (Economic Modelling)