Type: Package
Title: Multicountry Term Structure of Interest Rates Models
Version: 1.5.0
Date: 2025-10-23
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.
License: GPL-2 | GPL-3
Encoding: UTF-8
RoxygenNote: 7.2.3
Imports: cowplot, ggplot2, hablar, magic, pracma
Suggests: readxl, testthat (≥ 3.0.0), knitr, rmarkdown, bookdown, kableExtra, magrittr
Depends: R (≥ 4.3.0)
VignetteBuilder: knitr
URL: https://github.com/rubensmoura87/MultiATSM, https://rubensmoura87.github.io/MultiATSM/
BugReports: https://github.com/rubensmoura87/MultiATSM/issues
NeedsCompilation: no
Packaged: 2025-10-23 04:00:28 UTC; rmoura
Author: Rubens Moura ORCID iD [aut, cre]
Maintainer: Rubens Moura <rubens.gtmoura@gmail.com>
Repository: CRAN
Date/Publication: 2025-10-23 10:40:26 UTC
Config/testthat/edition: 3
LazyData: true

ATSM Package

Description

Estimation of several classes of affine term structure of interest rates models.

Author(s)

Rubens Moura rubens.gtmoura@gmail.com


Gathers the estimate of the bootstrap draws

Description

Gathers the estimate of the bootstrap draws

Usage

AdjustOptm_BS(ModelType, ModelBootstrap, Draw_Opt, Economies, tt)

Arguments

ModelType

String-vector containing the label of the model to be estimated

ModelBootstrap

List to store the bootstrap set

Draw_Opt

List of model estimated parameters

Economies

String-vector containing the names of the economies which are part of the economic system

tt

Number of the bootstrap draw


Generate paths to save IRFs/GIRFs graphs

Description

Generate paths to save IRFs/GIRFs graphs

Usage

AdjustPathFEVDs(OutputType, ElementType, PathsGraphs, Economies, ModelType)

Arguments

OutputType

available options are "IRF" and "GIRF"

ElementType

available options are "Factors" and "Yields"

PathsGraphs

desired path to save the graphs

Economies

Economies of the economic system

ModelType

Desired estimated model type


Generate paths to save IRFs/GIRFs graphs

Description

Generate paths to save IRFs/GIRFs graphs

Usage

AdjustPathIRFs(OutputType, ElementType, PathsGraphs, Economies, ModelType)

Arguments

OutputType

available options are "IRF" and "GIRF"

ElementType

available options are "Factors" and "Yields"

PathsGraphs

desired path to save the graphs

Economies

Economies of the economic system

ModelType

Desired estimated model type


Makes sure that the time series of yields and risk factors have coincident sample spans

Description

Makes sure that the time series of yields and risk factors have coincident sample spans

Usage

AdjustYieldsDates(Yields, PdynamicsFactors, Economies)

Arguments

Yields

time series of bond yields (CJ x T1 )

PdynamicsFactors

time series of risk factors (F x T2)

Economies

string-vector containing the names of the economies of the system.


Adjust the constant label

Description

Adjust the constant label

Usage

Adjust_Const_Type(Const_Type_Full)

Arguments

Const_Type_Full

Type of constraint (Full Name)


Transformation of the block diagonal parameters (auxiliary form)

Description

Transformation of the block diagonal parameters (auxiliary form)

Usage

Aux_BlockDiag(ParaValue, Const_Type, FactorLabels, Economies)

Arguments

ParaValue

Constrained parameter value

Const_Type

Type of constraint

FactorLabels

string-list based which contains the labels of all the variables present in the model

Economies

string-vector containing the names of the economies which are part of the economic system


Transformation of the JLL-related parameters (auxiliary form)

Description

Transformation of the JLL-related parameters (auxiliary form)

Usage

Aux_JLLstruct(ParaValue, Const_Type, FactorLabels, Economies, JLLinputs)

Arguments

ParaValue

Constrained parameter value

Const_Type

Type of constraint

FactorLabels

string-list based which contains the labels of all the variables present in the model

Economies

string-vector containing the names of the economies which are part of the economic system

JLLinputs

list of necessary inputs for the estimation of JLL-based models (see "JLL" function)


Transformation of the Jordan-related parameters (auxiliary form)

Description

Transformation of the Jordan-related parameters (auxiliary form)

Usage

Aux_Jordan(ParaValue, Const_Type, FactorLabels, Economies, JLLinputs)

Arguments

ParaValue

Constrained parameter

Const_Type

Type of constraint

FactorLabels

string-list based which contains the labels of all the variables present in the model

Economies

string-vector containing the names of the economies which are part of the economic system

JLLinputs

list of necessary inputs for the estimation of JLL-based models (see "JLL" function)


Transformation of a PSD matrix (auxiliary form)

Description

Transformation of a PSD matrix (auxiliary form)

Usage

Aux_PSD(ParaValue, Const_Type)

Arguments

ParaValue

Constrained parameter value

Const_Type

Type of constraint


Auxiliary function for a single-country specification

Description

Auxiliary function for a single-country specification

Usage

Aux_jordan_OneCountry(ParaValue, Const_Type)

Arguments

ParaValue

Constrained parameter

Const_Type

Type of constraint

References

Le, A., & Singleton, K. J. (2018). Small Package of Matlab Routines for Estimation of Some Term Structure Models. EABCN Training School.
This function offers an independent R implementation that is informed by the conceptual framework outlined in Le and Singleton (2018), but adapted to the present modeling context.


Replications of the JPS (2014) outputs by Bauer and Rudebusch (2017)

Description

Unspanned macro risk model outputs by Bauer and Rudebusch (2017)

Usage

data("BR_jps_out")

Format

Unspanned macro risk model outputs by Bauer and Rudebusch (2017)

est.llk

summary list of log-likelihood estimations

M.o

time series of unspanned factors

pars

additional summary list of log-likelihood estimations

W

Weight matrix that results from principal components analysis

Y

time series of bond yields

N

total number of risk factor of the model (spanned and unspanned)

R

total number of spanned factor of the model

References

Bauer, M. and Rudebusch, G. "Resolving the Spanning Puzzle in Macro-Finance Term Structure Models"


Transform B_spanned into B_unspanned for jointQ models

Description

Transform B_spanned into B_unspanned for jointQ models

Usage

BUnspannedAdapJoint(G, M, N, C, J, BSpanned)

Arguments

G

number of global unspanned factors

M

number of domestic unspanned factors

N

number of domestic spanned factors

C

number of economies of the economic system

J

number of country-specific observed bond yields

BSpanned

B that accomodates only the map to the spanned factors only


Transform B_spanned into B_unspanned for sepQ models

Description

Transform B_spanned into B_unspanned for sepQ models

Usage

BUnspannedAdapSep(G, M, ModelPara_Short, Economies, Economy, ModelType)

Arguments

G

number of global unspanned factors

M

number of domestic unspanned factors per country

ModelPara_Short

list of model parameter estimates (See the "Optimization" function)

Economies

complet set of economies of the economic system

Economy

specific economy under study

ModelType

a string-vector containing the label of the model to be estimated


Obtain the full form of B unspanned for "sep Q" models within the bootstrap setting

Description

Obtain the full form of B unspanned for "sep Q" models within the bootstrap setting

Usage

BUnspannedAdapSep_BS(G, M, ModelParaBoot, Economies, Economy, ModelType, tt)

Arguments

G

number of global unspanned factors

M

number of country-specific domestic unspanned factors

ModelParaBoot

list of model parameter estimates (see the "Optimization" function) after a bootstrap draw

Economies

string-vector containing the names of the economies which are part of the economic system

Economy

string-vector containing the names of the economy under study

ModelType

string-vector containing the label of the model to be estimated

tt

number of the bootstrap draw


Estimates an unbiased VAR(1) using stochastic approximation (Bauer, Rudebusch and Wu, 2012)

Description

Estimates an unbiased VAR(1) using stochastic approximation (Bauer, Rudebusch and Wu, 2012)

Usage

Bias_Correc_VAR(
  ModelType,
  BRWinputs,
  RiskFactors,
  Economies,
  FactorLabels,
  GVARinputs = NULL,
  JLLinputs = NULL,
  verbose = TRUE
)

Arguments

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:

  1. Cent_Measure: "Mean" or "Median" (unbiased estimation type)

  2. gamma: Numeric. Adjustment parameter between 0 and 1. Default is 0.5.

  3. N_iter: Integer. Number of iterations for the stochastic approximation algorithm after burn-in. Default is 5000.

  4. N_burn: Integer. Number of burn-in iterations. Default is 15

  5. B: Integer. Number of bootstrap samples per iteration for calculating the noisy measure of the biased estimator's mean or median. Default is 50.

  6. check: Logical. Indicates whether to perform a closeness check. Default is TRUE.

  7. B_check: Integer. Number of bootstrap samples for the closeness check. Default is 100000.

  8. Eigen_rest: Numeric. Restriction on the largest eigenvalue under the P-measure. Default is 1.

RiskFactors

numeric matrix (Td x K). Time series of risk factors.

Economies

character vector. Names of the C economies included in the system.

FactorLabels

list. Labels for all variables in the model.

GVARinputs

list. Inputs for GVAR model estimation (see GVAR). Default is NULL.

JLLinputs

list. Inputs for JLL model estimation (see JLL). Default is NULL.

verbose

logical. Flag controlling function messaging. Default TRUE.

Value

Bias-corrected VAR parameters based on the framework of Bauer, Rudebusch and Wu (2012). The list contains:

  1. KOZ_BC: estimated intercept (K x 1);

  2. K1Z_BC: estimated feedback matrix (K x K);

  3. SSZ_BC: estimated variance-covariance matrix (K x K);

  4. dist: root mean square distance (scalar);

General Notation

References

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/).

Examples


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 desired bootstrap graphs

Description

Generates the desired bootstrap graphs

Usage

Boot_DataGraphFact_perShock(
  NumOutBounds,
  NumOutPE,
  IdxShock,
  nmResponse,
  Lab_Int,
  ModelType,
  FacDim,
  Horiz,
  Economies = NULL,
  Ortho = FALSE
)

Arguments

NumOutBounds

numerical output set from the bootstrap analysis

NumOutPE

numerical output set from the point estimate analysis

IdxShock

index associated with the shock variable

nmResponse

Label of the response variable

Lab_Int

Output types "IRF", "GIRF" and "IRF Ortho"

ModelType

desired model type

FacDim

dimension from the P-dynamics

Horiz

horizon of analysis

Economies

name of economies forming the economic system

Ortho

Option for orthogonal outputs, for JLL models. Default is FALSE.


Generates the desired bootstrap graphs

Description

Generates the desired bootstrap graphs

Usage

Boot_DataGraphYield_perShock(
  NumOutBounds,
  NumOutPE,
  IdxShock,
  nmResponse,
  Lab_Int,
  ModelType,
  FacDim,
  YieldDim,
  Horiz,
  Economies = NULL,
  Ortho = FALSE
)

Arguments

NumOutBounds

numerical output set from the bootstrap analysis

NumOutPE

numerical output set from the point estimate analysis

IdxShock

index associated with the shock variable

nmResponse

Label of the response variable

Lab_Int

Output types "IRF" or "FEVD"

ModelType

desired model type

FacDim

dimension from bond yield set

YieldDim

dimension from the P-dynamics

Horiz

horizon of analysis

Economies

name of economies forming the economic system

Ortho

Option for orthogonal outputs, for JLL models. Default is FALSE.


Build P-dynamic graphs after the bootstrap implementation

Description

Build P-dynamic graphs after the bootstrap implementation

Usage

Boot_Fac_Graphs(
  NumOutBounds,
  NumOutPE,
  ModelType,
  FacDim,
  Horiz,
  Economies,
  PathsGraphs,
  OutInt,
  Folder2save,
  WishFacGraphs,
  WishFacGraphsOrtho = NULL
)

Arguments

NumOutBounds

numerical output set from the bootstrap analysis

NumOutPE

numerical output set from the point estimate analysis

ModelType

desired model type

FacDim

dimension of the risk factor set

Horiz

horizon of numerical outputs

Economies

Economies that are part of the economic system

PathsGraphs

Path to save the desired graphs

OutInt

available options are "IRF", "FEVD", "GIRF" or "GFEVD"

Folder2save

Folder path where the outputs will be stored.

WishFacGraphs

Binary variable reflecting the graphs of interest

WishFacGraphsOrtho

Binary variable reflecting the graphs of interest (orthogonalized version). Default is NULL


Build P-dynamic graphs after the bootstrap implementation

Description

Build P-dynamic graphs after the bootstrap implementation

Usage

Boot_Yields_Graphs(
  NumOutBounds,
  NumOutPE,
  ModelType,
  FacDim,
  YielDim,
  Horiz,
  Economies,
  PathsGraphs,
  OutInt,
  Folder2save,
  WishYieldGraphs,
  WishYieldGraphsOrtho = NULL
)

Arguments

NumOutBounds

numerical output set from the bootstrap analysis

NumOutPE

numerical output set from the point estimate analysis

ModelType

desired model type

FacDim

dimension of the risk factor set

Horiz

horizon of numerical outputs

Economies

Economies that are part of the economic system

PathsGraphs

Path to save the desired graphs

OutInt

Available option are "IRF", "FEVD", "GIRF" or "GFEVD"

Folder2save

Folder path where the outputs will be stored.

WishYieldGraphs

Binary variable reflecting the graphs of interest

WishYieldGraphsOrtho

Binary variable reflecting the graphs of interest (orthogonalized version). Default is NULL


Builds template from bootstrap-related graphs

Description

Builds template from bootstrap-related graphs

Usage

Boot_graph_template(ALLdata, nmResponse)

Arguments

ALLdata

data-frame containing the necessary data for building the graphs

nmResponse

string containing the name of the response variable


Generates the bootstrap-related outputs

Description

Generates the bootstrap-related outputs

Usage

Bootstrap(
  ModelType,
  ModelParaPE,
  NumOutPE,
  Economies,
  InputsForOutputs,
  FactorLabels,
  JLLlist,
  GVARlist,
  WishBC = FALSE,
  BRWlist = NULL,
  Folder2save = NULL,
  verbose = TRUE
)

Arguments

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 Optimization.

NumOutPE

list. Point estimates from numerical outputs. See outputs from NumOutputs.

Economies

character vector. Names of the C economies included in the system.

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 LabFac.

JLLlist

list. Inputs for JLL model estimation (see JLL). Default is NULL.

GVARlist

list. Inputs for GVAR model estimation (see GVAR). Default is NULL.

WishBC

logical. Whether to estimate the physical parameter model with bias correction (see Bias_Correc_VAR). Default is FALSE.

BRWlist

list. Inputs for bias-corrected estimation (see Bias_Correc_VAR).

Folder2save

character. Folder path where outputs will be stored. Default saves outputs in a temporary directory.

verbose

logical. Print progress messages. Default is TRUE.

Value

An object of class 'ATSMModelBoot' containing:

Permissible options - Bootstrap list in InputsForOutputs

Available methods

- autoplot(object, NumOutPE, type)

Examples


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
)



Builds the confidence bounds and graphs (Bootstrap set)

Description

Builds the confidence bounds and graphs (Bootstrap set)

Usage

BootstrapBoundsSet(
  ModelType,
  ModelBootstrap,
  NumOutPE,
  InputsForOutputs,
  Economies,
  Folder2save,
  verbose
)

Arguments

ModelType

string-vector containing the label of the model to be estimated

ModelBootstrap

list containing the complete set of model parameters after the bootstrap estimation procedure

NumOutPE

point estimate from the numerical outputs (see the outputs of the "NumOutputs" function)

InputsForOutputs

list containing the desired inputs for the construction of IRFs, GIRFs, FEVDs, and GFEVDs

Economies

string-vector containing the names of the economies which are part of the economic system

Folder2save

Folder path where the outputs will be stored.

verbose

Logical flag controlling function messaging.


Builds the time series of the risk factors that are used in the estimation of the ATSM

Description

Builds the time series of the risk factors that are used in the estimation of the ATSM

Usage

BuildATSM_RiskFactors(
  InitialSampleDate,
  FinalSampleDate,
  Yields,
  GlobalMacroFactors,
  DomMacroFactors,
  Economies,
  FactorLabels,
  ModelType,
  BS_Adj = FALSE
)

Arguments

InitialSampleDate

Sample starting date

FinalSampleDate

Sample last date

Yields

matrix (J x T), where J - the number of maturities and T - time series length

GlobalMacroFactors

time series of the global macroeconomic risk factors (G x T)

DomMacroFactors

time series of the country-specific macroeconomic risk factors for all C countries (CM x T)

Economies

string-vector containing the names of the economies which are part of the economic system

FactorLabels

string-list based which contains the labels of all variables present in the model

ModelType

string-vector containing the label of the model to be estimated

BS_Adj

adjustment of global series for sepQ model in the Bootstrap setting. Default is set to FALSE.

Value

Generates the complete set of risk factors that are used in the estimation of the ATSM


Build Confidence intervals for yield-related outputs

Description

Build Confidence intervals for yield-related outputs

Usage

BuildCI_Yields(
  NumOutBounds,
  NumOutPE,
  Lab_Int,
  ModelType,
  Economies,
  IdxResp,
  IdxShock,
  Ortho = FALSE
)

Arguments

NumOutBounds

numerical output set from the bootstrap analysis

NumOutPE

numerical output set from the point estimate analysis

Lab_Int

Label of interest. available options are "IRF" and "FEVD"

ModelType

desired model type

Economies

name of the economies forming the economic system

IdxResp

index associated with the response variable

IdxShock

index associated with the shock variable

Ortho

Option for orthogonal outputs, for JLL models. Default is FALSE.


Build the list of IRF and GIRF for both factors and bond yields

Description

Build the list of IRF and GIRF for both factors and bond yields

Usage

BuildFEVDlist(
  NumOut,
  Economies,
  ModelType,
  FEVDhoriz,
  FacDim,
  YieldsDim,
  OutputType
)

Arguments

NumOut

list of computed outputs containing the model fit, IRFs, FEVDs, GIRFs, GFEVDs and Term Premia

Economies

Economies of the economic system

ModelType

Desired model type

FEVDhoriz

time-horizon of the FEVD and GFEVD

FacDim

dimension of the risk factor vector

YieldsDim

dimension of the model set of yields

OutputType

available option are 'FEVD' and 'GFEVD'


Build the GVAR(1) from the country-specific VARX(1,1,1)

Description

Build the GVAR(1) from the country-specific VARX(1,1,1)

Usage

BuildGVAR(ParaVARX, GlobalPara, GVARinputs, DomLabels, GlobalLabels, N)

Arguments

ParaVARX

Set of VARX model parameters

GlobalPara

Set of marginal model parameters

GVARinputs

List of inputs for GVAR-based models

DomLabels

string-based vector containing label of the domestic risk factors

GlobalLabels

string-based vector containing label of the global risk factors

N

number of country-specific spanned factors (scalar)


Build the list of IRF and GIRF for both factors and bond yields

Description

Build the list of IRF and GIRF for both factors and bond yields

Usage

BuildIRFlist(NumOut, Economies, ModelType, IRFhoriz, FacDim, OutputType)

Arguments

NumOut

list of computed outputs containing the model fit, IRFs, FEVDs, GIRFs, GFEVDs and Term Premia

Economies

Economies of the economic system

ModelType

Desired model type

IRFhoriz

time-horizon of the IRF and GIRF

FacDim

dimension of the risk factor vector

OutputType

available option are 'IRF' and 'GIRF'


Build country-specific link matrices

Description

Build country-specific link matrices

Usage

BuildLinkMat(GVARinputs, N, M)

Arguments

GVARinputs

List of inputs for GVAR-based models

N

number of country-specific spanned factors (scalar)

M

number of country-specific unspanned factors (scalar)


Build the time-series of the risk factors in each bootstrap draw

Description

Build the time-series of the risk factors in each bootstrap draw

Usage

BuildRiskFactors_BS(
  ModelParaPE,
  residPdynOriginal,
  residYieOriginal,
  InputsForOutputs,
  Economies,
  ModelType,
  FactorLabels,
  GVARlist,
  JLLlist,
  WishBRW,
  BRWlist,
  nlag = 1,
  verbose
)

Arguments

ModelParaPE

List of point estimates of the model parameter

residPdynOriginal

Time-series of the residuals from the P-dynamics equation (T x F)

residYieOriginal

Time-series of the residuals from the observational equation (T x J or T x CJ)

InputsForOutputs

List containing the desired inputs for the construction of the numerical outputs.

Economies

String-vector containing the names of the economies which are part of the economic system

ModelType

Desired model to be estimated

FactorLabels

String-list based which contains the labels of all the variables present in the model

GVARlist

List of necessary inputs for the estimation of GVAR-based models

JLLlist

List of necessary inputs for the estimation of JLL-based models

WishBRW

Whether the user wishes to estimate the physical parameter model with the Bias correction model from BRW (2012) (see "Bias_Correc_VAR" function). Default is set to 0.

BRWlist

List of necessary inputs for performing the bias-corrected estimation (see "Bias_Correc_VAR" function)

nlag

Number of lags in the P-dynamics. Default is set to 1.

verbose

Logical flag controlling function messaging.


Build the time-series of bond yields for each bootstrap draw

Description

Build the time-series of bond yields for each bootstrap draw

Usage

BuildYields_BS(
  ModelParaPE,
  ModelType,
  RiskFactors_BS,
  BFull,
  BS_Set,
  Economies
)

Arguments

ModelParaPE

List of point estimates of the model parameter

ModelType

String-vector containing the label of the model to be estimated

RiskFactors_BS

Time-series of the risk factors (F x T)

BFull

B matrix of loadings

BS_Set

Set of bootstrap inputs

Economies

String-vector containing the names of the economies which are part of the economic system


Input validation for the 'FeedMat_Q' function

Description

Input validation for the 'FeedMat_Q' function

Usage

CheckInput_K1X(Yields, mat_vec, time_step)

Arguments

Yields

matrix containing country-specific yields (J x T)

mat_vec

vector of maturities expressed in years (J x 1)

time_step

time unit of the model (scalar).


Check consistence of inputs

Description

Check consistence of inputs

Usage

CheckInputsForMLE(
  t0,
  tF,
  Economies,
  DomesticMacroFac,
  GlobalMacroFac,
  UnitYields,
  DataFreq,
  Label_Single_Models,
  Label_Multi_Models,
  FactorLabels,
  GVARlist,
  ModelType
)

Arguments

t0

Sample starting date

tF

Sample last date

Economies

string-vector containing the names of the economies of the system.

DomesticMacroFac

time series of the country-specific macroeconomic risk factors for all C countries (CM x T)

GlobalMacroFac

time series of the global macroeconomic risk factors (G x T)

UnitYields

(i) "Month": if maturity of yields are expressed in months or (ii) "Year": if maturity of yields are expressed in years

DataFreq

single element character-based vector. Available options are: "Daily All Days",
"Daily Business Days", "Weekly", "Monthly", "Quarterly", "Annually"

Label_Single_Models

string-vector containing the names of the single country setups

Label_Multi_Models

string-vector containing the names of the multicountry setups

FactorLabels

string-list based which contains the labels of all variables present in the model

GVARlist

list of necessary inputs for the estimation of GVAR-based models (see "GVAR" function)

ModelType

string-vector containing the label of the model to be estimated


Check consistency of the inputs provided in GVARinputs

Description

Check consistency of the inputs provided in GVARinputs

Usage

CheckInputsGVAR(GVARinputs, N)

Arguments

GVARinputs

List of inputs for GVAR-based models

N

number of country-specific spanned factors (scalar)


Check consistency of the inputs provided in JLL-based models

Description

Check consistency of the inputs provided in JLL-based models

Usage

CheckJLLinputs(RiskFactorsNonOrtho, JLLinputs)

Arguments

RiskFactorsNonOrtho

Risk factors before the orthogonalization (FxT)

JLLinputs

List of necessary inputs to estimate JLL-based setups


Check Numerical Precision Issues of K1_root matrix

Description

Check Numerical Precision Issues of K1_root matrix

Usage

CheckNumericalPrecision(matrix_in, tolerance = 1e-10)

Arguments

matrix_in

K1_root matrix

tolerance

Numerical tolerance

Value

List with precision indicators


check how close the mean or median of the bias-corrected aproach is from the non-corrected approach

Description

check how close the mean or median of the bias-corrected aproach is from the non-corrected approach

Usage

Check_comparison_NoBC(
  K1Z_BC,
  K1Z_NoBC,
  B_check,
  RiskFactors,
  GVARinputs,
  JLLinputs,
  FactorLabels,
  Economies,
  ModelType,
  Use_Mean,
  verbose
)

Arguments

K1Z_BC

feedback matrix after the bias correction procedure

K1Z_NoBC

feedback matrix before the bias correction procedure

B_check

number of bootstrap samples used in the closeness check

RiskFactors

time series of the risk factors (F x T)

GVARinputs

inputs used in the estimation of the GVAR-based models (see "GVAR" function). Default is set to NULL

JLLinputs

inputs used in the estimation of the JLL-based models (see "JLL" function). Default is set to NULL

FactorLabels

string-list based which contains the labels of all variables present in the model

Economies

string-vector containing the names of the economies which are part of the economic system

ModelType

string-vector containing the label of the model to be estimated

Use_Mean

Choose between the mean or the median across the bootstrap iterations.

verbose

Logical flag controlling function messaging.


Check consistency of labels (economies, domestic and global variables)

Description

Check consistency of labels (economies, domestic and global variables)

Usage

Check_label_consistency(
  Economies,
  DomesticMacroFac,
  GlobalMacroFac,
  DomVarLab,
  GloVarLab
)

Arguments

Economies

string-vector containing the names of the economies which are part of the economic system

DomesticMacroFac

time series of the country-specific domestic risk factors (C(M+N) x T)

GlobalMacroFac

time series of the global risk factors (G x T)

DomVarLab

string-vector containing the names of the desired domestic risk factors

GloVarLab

string-vector containing the names of the desired global risk factors


Preliminary checks for inputs provided for the performing out-of-sample forecasting

Description

Preliminary checks for inputs provided for the performing out-of-sample forecasting

Usage

ChecksOOS(t0Forecast, t0Sample, nForecasts, ForecastType, TimeLength)

Arguments

t0Forecast

Index of the last set of observations in the information set at the first forecasting round

t0Sample

Index of the first set of observations in the information set at the first forecasting round

nForecasts

Number of forecasting sets generated

ForecastType

Forecast type. Available options are "Rolling" and "Expanding".

TimeLength

Time-series dimension of the model


Impose the zero-restrictions on the Cholesky-factorization from JLL-based models.

Description

Impose the zero-restrictions on the Cholesky-factorization from JLL-based models.

Usage

CholRestrictionsJLL(SigmaUnres, M, G, N, Economies, DomUnit)

Arguments

SigmaUnres

unrestricted variance-covariance matrix (K X K)

M

number of domestic unspanned factors per country (scalar)

G

number of global unspanned factors (scalar)

N

number of country-specific spanned factors (scalar)

Economies

string-vector containing the names of the economies which are part of the economic system

DomUnit

Name of the economy which is assigned as the dominant unit.
If no dominant unit is assigned, then this variable is defined as "none"

Value

restricted version the Cholesky factorization matrix from JLL-based models (K x K)


Clean unnecessary outputs of JLL models in the bootstrap setup

Description

Clean unnecessary outputs of JLL models in the bootstrap setup

Usage

CleanOrthoJLL_Boot(ModelBootstrap, ndraws, ModelType)

Arguments

ModelBootstrap

List of outputs to store bootstrap draws

ndraws

Total number of bootstrap draws

ModelType

A character vector indicating the model type to be estimated


Compute the confidence bounds around the P-dynamics and bond yields for FEVD and GFEVD

Description

Compute the confidence bounds around the P-dynamics and bond yields for FEVD and GFEVD

Usage

ComputeBounds_FEVDandGFEVD(
  ModelBootstrap,
  quants,
  FacDim,
  YieDim,
  ModelType,
  Economies,
  ndraws,
  Horiz
)

Arguments

ModelBootstrap

numerical output set from the bootstrap analysis

quants

quantile of the confidence bounds

FacDim

dimension of the risk factor set

YieDim

dimension of the bond yield set

ModelType

desired model type

Economies

Economies that are part of the economic system

ndraws

number of draws

Horiz

horizon of numerical outputs


Compute the confidence bounds from the model's numerical outputs

Description

Compute the confidence bounds from the model's numerical outputs

Usage

ComputeBounds_IRFandGIRF(
  ModelBootstrap,
  quants,
  FacDim,
  YieDim,
  ModelType,
  Economies,
  ndraws,
  Horiz
)

Arguments

ModelBootstrap

numerical output set from the bootstrap analysis

quants

quantile of the confidence bounds

FacDim

dimension of the risk factor set

YieDim

dimension of the bond yield set

ModelType

Desired model type

Economies

Economies that are part of the economic system

ndraws

number of draws selected

Horiz

horizon of numerical outputs


Compute FEVDs for all models

Description

Compute FEVDs for all models

Usage

ComputeFEVDs(
  SIGMA,
  K1Z,
  G0,
  BLoad,
  FactorLabels,
  FacDim,
  MatLength,
  FEVDhoriz,
  YieldsLabel,
  ModelType,
  Economy = NULL,
  CholFac_JLL = NULL,
  PI = NULL,
  Mode = FALSE
)

Arguments

SIGMA

Variance-covariance matrix

K1Z

Loading As

G0

contemporaneous terms

BLoad

Loading Bs

FactorLabels

List containing the label of factors

FacDim

Dimension of the P-dynamics

MatLength

Length of the maturity vector

FEVDhoriz

Horizon of the analysis

YieldsLabel

Label of bond yields

ModelType

Desired model type

Economy

specific economy under study

CholFac_JLL

Cholesky factorization term from JLL models

PI

matrix PI for JLL-based models

Mode

allows for the orthogonalized version in the case of JLL-based models

References


Compute GFEVDs for all models

Description

Compute GFEVDs for all models

Usage

ComputeGFEVDs(
  SIGMA,
  K1Z,
  G0,
  BLoad,
  FactorLabels,
  FacDim,
  MatLength,
  GFEVDhoriz,
  YieldsLabel,
  ModelType,
  Economy,
  PI = NULL,
  Mode = FALSE
)

Arguments

SIGMA

Variance-covariance matrix

K1Z

Loading As

G0

contemporaneous terms

BLoad

Loading Bs

FactorLabels

List containing the label of factors

FacDim

Dimension of the P-dynamics

MatLength

Length of the maturity vector

GFEVDhoriz

Horizon of the analysis

YieldsLabel

Label of bond yields

ModelType

Desired model type

Economy

specific economy under study

PI

matrix PI for JLL-based models

Mode

allows for the orthogonalized version in the case of JLL-based models

References


Compute GIRFs for all models

Description

Compute GIRFs for all models

Usage

ComputeGIRFs(
  Sigma.y,
  F1,
  BLoad,
  G0.y,
  FactorLabels,
  FacDim,
  MatLength,
  GIRFhoriz,
  YieldsLabel,
  ModelType,
  Economy = NULL,
  PI = NULL,
  Mode = FALSE
)

Arguments

Sigma.y

Variance-covariance matrix

F1

Feedback matrix

BLoad

Loading Bs

G0.y

matrix of contemporaneous terms

FactorLabels

List containing the labels of the factors

FacDim

Dimension of the P-dynamics

MatLength

Length of the maturity vector

GIRFhoriz

Horizon of the analysis

YieldsLabel

Label o yields

ModelType

desired Model type

Economy

Economy under study

PI

matrix PI for JLL-based models

Mode

allows for the orthogonalized version in the case of JLL-based models

#' @references

  • This function is partially based on the version of the "irf" function from Smith, L.V. and A. Galesi (2014). GVAR Toolbox 2.0, available at https://sites.google.com/site/gvarmodelling/gvar-toolbox.

  • Pesaran and Shin, 1998. "Generalized impulse response analysis in linear multivariate models" (Economics Letters)


Compute IRFs of all models

Description

Compute IRFs of all models

Usage

ComputeIRFs(
  SIGMA,
  K1Z,
  BLoad,
  FactorLabels,
  FacDim,
  MatLength,
  IRFhoriz,
  YieldsLabel,
  ModelType,
  Economy = NULL,
  PI = NULL,
  Mode = FALSE
)

Arguments

SIGMA

Variance-covariance matrix

K1Z

Loading As

BLoad

Loading Bs

FactorLabels

List containing the label of factors

FacDim

Dimension of the P-dynamics

MatLength

Length of the maturity vector

IRFhoriz

Horizon of the analysis

YieldsLabel

Label of bond yields

ModelType

Desired model type

Economy

specific economy under study

PI

matrix PI for JLL-based models

Mode

allows for the orthogonalized version in the case of JLL-based models


Compute the latent loading AnX and BnX

Description

Compute the latent loading AnX and BnX

Usage

Compute_BnX_AnX(mat, N, K1XQ, r0, dX, SSX, Economies, ModelType, Lab_SingleQ)

Arguments

mat

vector of maturities (J x 1). Maturities are in multiples of the discrete interval used in the model

N

number of country-specific spanned factors

K1XQ

risk neutral feedback matrix (N x N)

r0

the long run risk neutral mean of the short rate (scalar)

dX

state loadings for the one-period rate (1xN). Default is a vector of ones

SSX

the covariance matrix of the errors (N x N)

Economies

string-vector containing the names of the economies which are part of the economic system

ModelType

string-vector containing the label of the model to be estimated

Lab_SingleQ

string-vector containing the labels of the models estimated on a country-by-country basis


Compute the expected component for all models

Description

Compute the expected component for all models

Usage

Compute_EP(
  ModelPara,
  ModelType,
  UnitYields,
  matAdjUnit,
  N,
  rhoList,
  Economies,
  FactorLabels,
  WishFP = FALSE,
  matMIN = FALSE,
  matMAX = FALSE
)

Arguments

ModelPara

list of model parameter estimates

ModelType

Desired model type

UnitYields

Available options: "Month" and "Year"

matAdjUnit

Adjusted vector of matutities

N

number of country-specific spanned factors

rhoList

List of risk-neutral parameters

Economies

string-vector containing the names of the economies which are part of the economic system

FactorLabels

List of factor labels

WishFP

If users wants to compute the forward premia. Default is FALSE.

matMIN

For the forward premia, the shortest maturity of the remium of interest

matMAX

For the forward premia, the longest maturity of the remium of interest


Retrieves data from Excel and builds the database used in the model estimation

Description

Retrieves data from Excel and builds the database used in the model estimation

Usage

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
)

Arguments

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 C economies included in the system.

N

positive integer. Number of country-specific spanned factors.

FactorLabels

list. Labels for all variables present in the model, as returned by LabFac.

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.

Value

A list containing:

  1. Yields: matrix (J x Td or CJ x Td) of bond yields for all countries.

  2. RiskFactors: matrix (K x Td) of risk factors for all countries.

  3. GVARFactors: list of variables used in VARX estimation (see GVARFactors data file). NULL if not GVAR-based.

General Notation

See Also

Load_Excel_Data

Examples

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
)


Prepare the factor set for GVAR models (Bootstrap version)

Description

Prepare the factor set for GVAR models (Bootstrap version)

Usage

DataSet_BS(ModelType, RiskFactors, Wgvar, Economies, FactorLabels)

Arguments

ModelType

A character vector containing the label of the model to be estimated.

RiskFactors

A matrix of the complete set of risk factors (K x T).

Wgvar

A transition matrix from GVAR models (C x C).

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.

Value

A list containing the factor set for GVAR models.


Gather data of several countries in a list. Particularly useful for GVAR-based setups (Compute "GVARFactors")

Description

Gather data of several countries in a list. Particularly useful for GVAR-based setups (Compute "GVARFactors")

Usage

DatabasePrep(
  t_First,
  t_Last,
  Economies,
  N,
  FactorLabels,
  ModelType,
  Macro_FullData,
  Yields_FullData,
  Wgvar = NULL
)

Arguments

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 C economies included in the system.

N

positive integer. Number of country-specific spanned factors per country.

FactorLabels

list. Labels for all variables present in the model, as returned by LabFac.

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 Load_Excel_Data.

Yields_FullData

list. Full set of bond yield data, as returned by Load_Excel_Data.

Wgvar

GVAR transition matrix. For GVAR models, either a matrix (C x C) for fixed weights, or a named list of matrices for time-varying weights. Default is NULL. Required for GVAR models.

Value

List containing the risk factor set for all countries and global factors. Particularly useful for GVAR-based models.

General Notation

Examples


# 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
)


Data: domestic risk factors - Candelon and Moura (2024, JFEC)

Description

Domestic risk factors data used in Candelon and Moura (2024, JFEC)

Usage

data("DomMacro")

Format

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.

Source

Inflation

year-over-year variation from Consumer price index published by the International Monetary Fund <https://data.imf.org/en/datasets/IMF.STA:CPI>

Eonomic activity

GDP leading indicator published by the OECD <https://www.oecd.org/en/data/indicators/composite-leading-indicator-cli.html>

References

Candelon, B. and Moura, R. (2024) "A Multicountry Model of the Term Structures of Interest Rates with a GVAR". (Journal of Financial Econometrics)


Data: Risk Factors for the GVAR - Candelon and Moura (2023)

Description

Domestic risk factors data used in the GVAR models - Candelon and Moura (2023)

Usage

data("DomMacro_covid")

Format

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.

Source

Inflation

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>

Output growth

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>

CDS

5-year maturity CDS. Simulated data constructed using Bloomberg bond yield series.

COVID-19 reproduction rate

detrended R rate from the Our World in Data database <https://ourworldindata.org/coronavirus>

References

Candelon, B. and Moura, R. (2023) "Sovereign yield curves and the COVID-19 in emerging markets". (Economic Modelling)


Estimate K1h

Description

Estimate K1h

Usage

Est_K1h(horiz, min_mat, max_mat, time_step, B_coef)

Arguments

horiz

Minimum horizon observed

min_mat

shortest maturity observed

max_mat

longest maturity observed

time_step

time unit of the model (scalar)

B_coef

matrix of beta coefficients


Estimate a restricted OLS model

Description

Estimate a restricted OLS model

Usage

Est_RestOLS(LHS, RHS, Rmat)

Arguments

LHS

left hand side variables (M x T).

RHS

right hand side variables (should include the intercept, if desired) (N x T).

Rmat

matrix of constraints (M x N). Entries containing NAs are treated as free parameters.

Value

matrix of coefficient (M x N)


Estimate numerically the variance-covariance matrix from the GVAR-based models

Description

Estimate numerically the variance-covariance matrix from the GVAR-based models

Usage

EstimationSigma_GVARrest(SigmaUnres, res, IdxVarRest)

Arguments

SigmaUnres

Unrestricted variance-covariance matrix (K x K)

res

residuals from the VAR of a GVAR model (K x T)

IdxVarRest

index of the variable that is selected as strictly exogenous

Value

restricted version of the variance-covariance matrix a GVAR model (K x K)


Estimate numerically the Cholesky-factorization from the JLL-based models

Description

Estimate numerically the Cholesky-factorization from the JLL-based models

Usage

EstimationSigma_Ye(SigmaUnres, res, M, G, Economies, DomUnit)

Arguments

SigmaUnres

unrestricted variance-covariance matrix (K x K)

res

residuals from the VAR of the JLL model (K x T)

M

number of domestic unspanned factors per country (scalar)

G

number of global unspanned factors (scalar)

Economies

string-vector containing the names of the economies which are part of the economic system

DomUnit

Name of the economy which is assigned as the dominant unit.
If no dominant unit is assigned, then this variable is defined as "none"

Value

Cholesky-factorization after the maximization (K x K)


Get the expected component of all models

Description

Get the expected component of all models

Usage

ExpectedComponent(
  ModelPara,
  InputsForOutputs,
  ModelType,
  Economies,
  FactorLabels,
  WishFP = FALSE
)

Arguments

ModelPara

list of model parameter estimates

InputsForOutputs

list containing the desired horizon of analysis for the model fit, IRFs, GIRFs, FEVDs, GFEVDs, and risk premia decomposition

ModelType

desired model type

Economies

string-vector containing the names of the economies which are part of the economic system

FactorLabels

string-list based which contains all the labels of all the variables present in the model

WishFP

If users wants to compute the forward premia. Default is FALSE.


FEVDs and GFEVDs for all models

Description

FEVDs and GFEVDs for all models

Usage

FEVDandGFEVD(ModelType, ModelPara, FEVDhoriz, FactorLabels, Economies)

Arguments

ModelType

string-vector containing the label of the model to be estimated

ModelPara

list of model parameter estimates (see the "Optimization" function)

FEVDhoriz

single numerical vector containing the desired horizon of analysis for the FEVDs and GFEVDs

FactorLabels

string-list based which contains all the labels of all the variables present in the model

Economies

string-vector containing the names of the economies which are part of the economic system

Details

Structural shocks are identified via Cholesky decomposition


FEVDs and GFEVDs after bootstrap for all models

Description

FEVDs and GFEVDs after bootstrap for all models

Usage

FEVDandGFEVD_BS(ModelType, ModelParaBoot, FEVDhoriz, FactorLabels, Economies)

Arguments

ModelType

string-vector containing the label of the model to be estimated

ModelParaBoot

list of model parameter estimates (see the "Optimization" function) after a bootstrap draw

FEVDhoriz

single numerical vector containing the desired horizon of analysis for the FEVDs

FactorLabels

string-list based which contains all the labels of all the variables present in the model

Economies

string-vector containing the names of the economies which are part of the economic system


Creates the confidence bounds and the graphs of FEVDs and GFEVDs after bootstrap (all models)

Description

Creates the confidence bounds and the graphs of FEVDs and GFEVDs after bootstrap (all models)

Usage

FEVDandGFEVDbs(
  ModelType,
  ModelBootstrap,
  NumOutPE,
  InputsForOutputs,
  Economies,
  PathsGraphs,
  Folder2save,
  verbose
)

Arguments

ModelType

string-vector containing the label of the model to be estimated

ModelBootstrap

list containing the complete set of model parameters after bootstrap estimation procedure

NumOutPE

list of model parameter point estimates

InputsForOutputs

list containing the desired inputs for the construction of the outputs of interest

Economies

string-vector containing the names of the economies which are part of the economic system

PathsGraphs

path of the folder in which the graphs will be saved

Folder2save

Folder path where the outputs will be stored.

verbose

Logical flag controlling function messaging.


FEVD and GFEVD graphs for all models

Description

FEVD and GFEVD graphs for all models

Usage

FEVDandGFEVDgraphs(
  ModelType,
  NumOut,
  WishPdynamicsgraphs,
  WishYieldsgraphs,
  FEVDhoriz,
  PathsGraphs,
  OutputType,
  Economies,
  Folder2save,
  verbose
)

Arguments

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 C economies included in the system.

Folder2save

character. Folder path where the outputs will be stored.

verbose

logical. Flag controlling function messaging.

Available Methods

- '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")'.

Examples

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
)


Generates graphs for FEVDs and GFEVDs

Description

Generates graphs for FEVDs and GFEVDs

Usage

FEVDandGFEVDs_Graphs(OutputType, FEVDlist, nmVarInt, Lab_Fac, PathsGraphs)

Arguments

OutputType

available options are "FEVD", "GFEVD", "FEVD Ortho" and "GFEVD Ortho"

FEVDlist

list of FEVD and GFEVD outputs

nmVarInt

name of variable of interest. Options: "Factors" and "Yields"

Lab_Fac

label of the model factors

PathsGraphs

Path to save graphs


Compute quantiles for model P-dynamics

Description

Compute quantiles for model P-dynamics

Usage

FacQuantile_bs(
  DrawSet,
  LabIRF,
  ndraws,
  quants,
  Horiz,
  FacDim,
  DimLabelsFac,
  ModelType,
  Ortho = FALSE
)

Arguments

DrawSet

Draw-specific set

LabIRF

vector containing the labels "IRF" and "GIRF"

ndraws

number of draws

quants

quantile of the confidence bounds

Horiz

horizon of numerical outputs

FacDim

dimension of the risk factor set

DimLabelsFac

labels of the factor set

ModelType

desired model type

Ortho

Orthogonolized version for the JLL models. Default is FALSE.


Compute the confidence bounds for the model bond P-dynamics-related outputs

Description

Compute the confidence bounds for the model bond P-dynamics-related outputs

Usage

FactorBounds_FEVDandGFEVD(
  ModelBootstrap,
  quants,
  ModelType,
  ndraws,
  Horiz,
  FacDim,
  LabFEVD,
  Economies
)

Arguments

ModelBootstrap

numerical output set from the bootstrap analysis

quants

quantile of the confidence bounds

ModelType

desired model type

ndraws

number of draws

Horiz

horizon of numerical outputs

FacDim

dimension of the risk factor set

LabFEVD

vector containing the labels "FEVD" and "GFEVD"

Economies

Economies that are part of the economic system


Compute the confidence bounds for the model P-dynamics

Description

Compute the confidence bounds for the model P-dynamics

Usage

FactorBounds_IRFandGIRF(
  ModelBootstrap,
  quants,
  ModelType,
  ndraws,
  Horiz,
  FacDim,
  LabIRF,
  Economies
)

Arguments

ModelBootstrap

numerical output set from the bootstrap analysis

quants

quantile of the confidence bounds

ModelType

desired model type

ndraws

number of draws

Horiz

horizon of numerical outputs

FacDim

dimension of the risk factor set

LabIRF

vector containing the labels "IRF" and "GIRF"

Economies

Economies that are part of the economic system


Makes the pre-allocation of the factors set for JLL-based models

Description

Makes the pre-allocation of the factors set for JLL-based models

Usage

Factors_NonOrtho(NonOrthoFactors, JLLinputs, FactorLab, N)

Arguments

NonOrthoFactors

Risk factors before the orthogonalization (FxT)

JLLinputs

List of necessary inputs to estimate JLL-based setups

FactorLab

Variable labels from JLL-based models

N

number of country-specific spanned factors (scalar)


Computes an average or median feedback matrix across several bootstrap iterations

Description

Computes an average or median feedback matrix across several bootstrap iterations

Usage

FeedMat_M(
  K1Z_j,
  N_boot,
  RiskFactors,
  GVARinputs,
  JLLinputs,
  FactorLabels,
  Economies,
  ModelType,
  Use_Mean
)

Arguments

K1Z_j

Feedback matrix at the j_th iteration

N_boot

Number of bootstrap samples per iteration.

RiskFactors

A numeric matrix (T x F) representing the time series of risk factors.

GVARinputs

List. Inputs for GVAR model estimation.

JLLinputs

List. Inputs for JLL model estimation.

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.

Use_Mean

Choose between the mean or the median across the bootstrap iterations.


Get an estimate for the risk-neutral (Q) feedback matrix

Description

Get an estimate for the risk-neutral (Q) feedback matrix

Usage

FeedMat_Q(
  Yields,
  Spa_Fac,
  Economies,
  UnitYields,
  time_step,
  check_inputs = TRUE
)

Arguments

Yields

matrix of bond yields (J x T)

Spa_Fac

matrix of spanned factors (N x T)

Economies

string-vector containing the names of the economies which are part of the economic system

UnitYields

(i) "Month": if maturity of yields are expressed in months or (ii) "Year": if maturity of yields are expressed in years

time_step

time unit of the model (scalar). For instance, if data is (i) monthly, dt <- 12; (ii) quarterly, dt <- 4; (iii) yearly, dt <- 1.

check_inputs

Perform input validation. Default is TRUE.

References

Le, A., & Singleton, K. J. (2018). Small Package of Matlab Routines for Estimation of Some Term Structure Models. EABCN Training School.
This function offers an independent R implementation that is informed by the conceptual framework outlined in Le and Singleton (2018), but adapted to the present modeling context.


Compute the Feedback matrix of each bootstrap draw

Description

Compute the Feedback matrix of each bootstrap draw

Usage

FeedbackMat_BS(
  ModelType,
  RiskFactors_TS,
  FactorLabels,
  Economies,
  GVARlist,
  JLLlist,
  WishBRW,
  BRWlist,
  verbose
)

Arguments

ModelType

String-vector containing the label of the model to be estimated

RiskFactors_TS

Time-series of risk factors of the bootstrap (F x T)

FactorLabels

String-list based which contains the labels of all the variables present in the model

Economies

String-vector containing the names of the economies which are part of the economic system

GVARlist

List of necessary inputs for the estimation of GVAR-based models

JLLlist

List of necessary inputs for the estimation of JLL-based models

WishBRW

Whether the user wishes to estimate the physical parameter model with the Bias correction model from BRW (2012) (see "Bias_Correc_VAR" function). Default is set to 0.

BRWlist

List of necessary inputs for performing the bias-corrected estimation (see Bias_Correc_VAR function)

verbose

Logical flag controlling function messaging.


Set the zero-restrictions on the feedback matrix of JLL's P-dynamics

Description

Set the zero-restrictions on the feedback matrix of JLL's P-dynamics

Usage

FeedbackMatrixRestrictionsJLL(DomUnit, K, G, M, N)

Arguments

DomUnit

Name of the economy which is assigned as the dominant unit.
If no dominant unit is assigned, then this variable is defined as "none"

K

Total number of risk factors of the economic system (scalar)

G

Number of global unspanned factors (scalar)

M

Number of country-specific unspanned factors (scalar)

N

Number of country-specific spanned factors (scalar)

Value

matrix containing the restrictions of the feedback matrix (K x K)


Build subplot for fitted yields

Description

Build subplot for fitted yields

Usage

Fit_Subplot(
  YieldData,
  ModelFit,
  ModelImplied,
  MatLength,
  mat,
  Economies,
  ModelType,
  PathsGraphs
)

Arguments

YieldData

Time series of bond yields

ModelFit

Time series of fitted bond yields

ModelImplied

Time series of model-implied bond yields

MatLength

number of country-specific maturities

mat

vector of maturities

Economies

Economies of the economic system

ModelType

Desired estimated model

PathsGraphs

Path to save the graphs


Model fit graphs for all models

Description

Model fit graphs for all models

Usage

Fitgraphs(
  ModelType,
  WishFitgraphs,
  ModelPara,
  NumOut,
  Economies,
  PathsGraphs,
  Folder2save,
  verbose
)

Arguments

ModelType

character. Estimated model type.

WishFitgraphs

logical. Set TRUE to generate fit graphs, FALSE otherwise.

ModelPara

list. Model parameter estimates (see Optimization).

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.

Available Methods

- 'autoplot(object, type = "Fit")'

Examples

data("ParaSetEx")
data("NumOutEx")
ModelType <- "JPS original"
Economy <- "Brazil"
Fitgraphs(ModelType,
  WishFitgraphs = TRUE, ParaSetEx, NumOutEx, Economy, PathsGraphs = NULL,
  Folder2save = NULL, verbose = FALSE
)


Creates the folders and the path in which the graphical outputs are stored (Bootstrap version)

Description

Creates the folders and the path in which the graphical outputs are stored (Bootstrap version)

Usage

FolderCreationBoot(ModelType, Economies, Folder2save)

Arguments

ModelType

a string-vector containing the label of the model to be estimated

Economies

a string-vector containing the names of the economies which are part of the economic system

Folder2save

Folder path where the outputs will be stored.


Creates the folders and the path in which the graphical outputs are stored (point estimate version)

Description

Creates the folders and the path in which the graphical outputs are stored (point estimate version)

Usage

FolderCreationPoint(ModelType, Economies, Folder2save)

Arguments

ModelType

A character vector indicating the model type to be estimated.

Economies

A character vector containing the names of the economies included in the system.

Folder2save

Folder path where the outputs will be stored.


Creates folder to store graphs generated from the bootstrap analysis

Description

Creates folder to store graphs generated from the bootstrap analysis

Usage

FolderCreation_Boot(
  ModelType,
  LabIRF,
  Economies,
  OutType,
  Folder2save,
  Ortho = FALSE
)

Arguments

ModelType

Desired model type

LabIRF

Output types "IRF", "GIRF" and "IRF Ortho"

Economies

economies of the economic system

OutType

Available option "Factors" or "Yields

Folder2save

Folder path where the outputs will be stored.

Ortho

Option for orthogonal outputs, for JLL models. Default is FALSE.


Create folders for storing IRFs and GIRFs

Description

Create folders for storing IRFs and GIRFs

Usage

FolderPrep_FEVDs(
  OutputType,
  WishPdynamicsgraphs,
  WishYieldsgraphs,
  Economies,
  ModelType,
  Folder2Save
)

Arguments

OutputType

available options are "IRF", "GIRF", "IRF Ortho" and "GIRF Ortho"

WishPdynamicsgraphs

binary variable specifing whether the user whishes IRFs and/or GIRFs of risk factors

WishYieldsgraphs

binary variable specifing whether the user whishes IRFs and/or GIRFs of bond yields

Economies

Set of economies that are part of the economic system

ModelType

Desired modem type

Folder2Save

Folder path where the outputs will be stored.


Create folders for storing IRFs and GIRFs

Description

Create folders for storing IRFs and GIRFs

Usage

FolderPrep_IRFs(
  OutputType,
  WishPdynamicsgraphs,
  WishYieldsgraphs,
  Economies,
  ModelType,
  Folder2Save
)

Arguments

OutputType

available options are "IRF", "GIRF", "IRF Ortho" and "GIRF Ortho"

WishPdynamicsgraphs

binary variable specifing whether the user whishes IRFs and/or GIRFs of risk factors

WishYieldsgraphs

binary variable specifing whether the user whishes IRFs and/or GIRFs of bond yields

Economies

Set of economies that are part of the economic system

ModelType

Desired modem type

Folder2Save

Folder path where the outputs will be stored.


Generates forecasts of bond yields for all model types

Description

Generates forecasts of bond yields for all model types

Usage

ForecastYields(
  ModelType,
  ModelPara,
  InputsForOutputs,
  FactorLabels,
  Economies,
  JLLlist = NULL,
  GVARlist = NULL,
  WishBRW = FALSE,
  BRWlist = NULL,
  Folder2save = NULL,
  verbose = TRUE
)

Arguments

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 Optimization.

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 LabFac.

Economies

character vector. Names of the C economies included in the system.

JLLlist

list. Inputs for JLL model estimation (see JLL). Default is NULL.

GVARlist

list. Inputs for GVAR model estimation (see GVAR). Default is NULL.

WishBRW

logical. Whether to estimate the physical parameter model with bias correction (see Bias_Correc_VAR). Default is FALSE.

BRWlist

list. Inputs for bias-corrected estimation (see Bias_Correc_VAR).

Folder2save

character. Folder path where outputs will be stored. Default saves outputs in a temporary directory.

verbose

logical. Print progress messages. Default is TRUE.

Value

An object of class 'ATSMModelForecast' containing the following elements:

  1. Out-of-sample forecasts of bond yields per forecast horizon

  2. Out-of-sample forecast errors of bond yields per forecast horizon

  3. Root mean square errors per forecast horizon

Permissible options - forecast list (InputsForOutputs input)

Available Methods

- 'plot(object)'

Examples


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
)


Compute the forward premia for all models

Description

Compute the forward premia for all models

Usage

ForwardPremia(
  ModelPara,
  avexpFP,
  ModelType,
  FactorLabels,
  InputsForOutputs,
  Economies
)

Arguments

ModelPara

list of model parameter estimates

avexpFP

list containing the country-specific expected component of the forward period

ModelType

desired model type

FactorLabels

List of factor labels

InputsForOutputs

list containing the desired horizon of analysis for the model fit, IRFs, GIRFs, FEVDs, GFEVDs, and risk premia decomposition

Economies

string-vector containing the names of the economies which are part of the economic system


Use function ML to generate the outputs from a ATSM

Description

Use function ML to generate the outputs from a ATSM

Usage

FunctionML_vec(
  x,
  ML_fun,
  ListInputSet,
  ModelType,
  FactorLabels,
  Economies,
  JLLinputs,
  GVARinputs,
  WithEstimation
)

Arguments

x

vector containing all the vectorized auxiliary parameters

ML_fun

vector-valued objective function (function)

ListInputSet

variable inputs used in the optimization (see inputs from "optimization" function)

ModelType

string-vector containing the label of the model to be estimated

FactorLabels

string-list based which contains the labels of all the variables present in the model

Economies

string-vector containing the names of the economies which are part of the economic system

JLLinputs

Set of necessary inputs used in the estimation of the JLL-based models (see "JLL" function)

GVARinputs

Set of necessary inputs used in the estimation of the GVAR-based models (see "GVAR" function)

WithEstimation

if TRUE, returns only the values of the likelihood function, else generates the entire set of outputs


Estimates a GVAR(1) and VARX(1,1,1) models

Description

Estimates a GVAR(1) and VARX(1,1,1) models

Usage

GVAR(GVARinputs, N, CheckInputs = FALSE)

Arguments

GVARinputs

list. Inputs for GVAR model estimation:

  1. Economies: character vector. Contains the C names of the economies included in the system.

  2. GVARFactors: list. All variables used in the estimation of the VARX model
    (see e.g. GVARFactors file for details);

  3. VARXtype: Permissible:

    • 'unconstrained': model is estimated without constraints (each equation is estimated individually by ordinary least square);

    • 'constrained: Spanned Factors': The model is estimated with the restriction that foreign pricing factors do NOT affect (i) domestic economic variables and (ii) domestic pricing factors (estimation via restricted least squares).

    • 'constrained : [factor_name]': The model is estimated with the restriction that the specified risk factor is influenced only by its own lagged values and the lagged values of its corresponding star variables. (estimation via restricted least squares.)

  4. Wgvar: The GVAR transition matrix (C x C) used in the model solution.
    (See the output from the Transition_Matrix function.).

N

positive integer. Number of country-specific spanned factors.

CheckInputs

logical. Whether to perform a prior consistency check on the inputs provided in GVARinputs. Default is FALSE.

Value

list. Contains:

  1. 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)

  2. parameters of the GVAR:

    • F0 (K x K)

    • F1 (K x K)

    • Sigma_y (K x K)

General Notation

References

Chudik, A. and Pesaran, M. H. (2016). "Theory and Practice of GVAR modelling" (Journal of Economic Surveys)

Examples

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: Risk Factors for the GVAR - Candelon and Moura (2024, JFEC)

Description

Risk factors data used in the GVAR-ATSM from Candelon and Moura (2024, JFEC)

Usage

data("GVARFactors")

Format

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.

Source

Global unspanned factors

See data("GlobalMacro") for a detailed data description.

Domestic unspanned factors

See data("DomMacro") for a detailed data description.

Domestic spanned factors

First three principal components of each country set of bond yields. See data("Yields") for a detailed data description.

Domestic star factors

Weighted average of foreign factors. See Transition_Matrix for the computation of weights.

References

Candelon, B. and Moura, R. (2024) "A Multicountry Model of the Term Structures of Interest Rates with a GVAR". (Journal of Financial Econometrics)


Prepare risk factors for the estimation of the GVAR model

Description

Prepare risk factors for the estimation of the GVAR model

Usage

GVAR_PrepFactors(GVARinputs, DomLabels, StarLabels, GlobalLabels, N)

Arguments

GVARinputs

List of inputs for GVAR-based models

DomLabels

string-based vector containing label of the domestic risk factors

StarLabels

string-based vector containing label of the star domestic risk factors

GlobalLabels

string-based vector containing label of the global risk factors

N

number of country-specific spanned factors (scalar)


Gather several forecast dates

Description

Gather several forecast dates

Usage

Gather_Forecasts(Forecast_OneDate, Forecast_AllDates, Economies, ModelType)

Arguments

Forecast_OneDate

Bond yield forecasts for a single date

Forecast_AllDates

Bond yield forecasts for multiple dates

Economies

String-vector containing the names of the economies which are part of the economic system

ModelType

String-vector containing the label of the model to be estimated


computes the density function of a gaussian process

Description

computes the density function of a gaussian process

Usage

GaussianDensity(res, SSZ)

Arguments

res

matrix of residuals (N x T)

SSZ

covariance matrices or array of covariance matrices (N x N)

Value

y vector of density (1 x T)


Generate artificial time-series in the bootstrap setup

Description

Generate artificial time-series in the bootstrap setup

Usage

Gen_Artificial_Series(
  ModelParaPE,
  residPdynOriginal,
  residYieOriginal,
  ModelType,
  BFull,
  InputsForOutputs,
  Economies,
  FactorLabels,
  GVARlist,
  JLLlist,
  WishBRW,
  BRWlist,
  verbose,
  nlag = 1
)

Arguments

ModelParaPE

List of point estimates of the model parameter

residPdynOriginal

Time-series of the residuals from the P-dynamics equation (T x F)

residYieOriginal

Time-series of the residuals from the observational equation (T x J or T x CJ)

ModelType

Desired model to be estimated

BFull

Matrix B of loadings (CJ x F or J x F)

InputsForOutputs

List containing the desired inputs for the construction

Economies

String-vector containing the names of the economies which are part of the economic system

FactorLabels

String-list based which contains the labels of all the variables present in the model

GVARlist

List of necessary inputs for the estimation of GVAR-based models

JLLlist

List of necessary inputs for the estimation of JLL-based models

WishBRW

Whether the user wishes to estimate the physical parameter model with the Bias correction model from BRW (2012) (see "Bias_Correc_VAR" function). Default is set to 0.

BRWlist

List of necessary inputs for performing the bias-corrected estimation (see "Bias_Correc_VAR" function)

verbose

Logical flag controlling function messaging.

nlag

Number of lags in the P-dynamics. Default is set to 1.


Compute the bond yield forecast for any model type

Description

Compute the bond yield forecast for any model type

Usage

Gen_Forecast_Yields(
  K0Z,
  K1Z,
  A,
  Bfull,
  ZZsubsample,
  C,
  J,
  YieldsLabels,
  ForLabels,
  ForHoriz,
  ModelType
)

Arguments

K0Z

Intercept from the P-dynamics (F x 1)

K1Z

Feedback matrix from the P-dynamics (F x F)

A

Intercept of model-implied yields model (J x 1)

Bfull

Slope of model-implied yields model (J x N or CJ x CN)

ZZsubsample

Sub-sample of risk factors (F x t)

C

Number of countries in the economic cohort (scalar)

J

Number of country-specific bond yields

YieldsLabels

Labels of bond yields

ForLabels

Forecast labels (string-based vector)

ForHoriz

Forecast horizon (scalar)

ModelType

A string-vector containing the label of the model to be estimated


Simulate N_Boot dataset from the P-dynamics

Description

Simulate N_Boot dataset from the P-dynamics

Usage

Gen_art_series(K1Z_j, N_Boot, RFs)

Arguments

K1Z_j

Feedback matrix at the j_th iteration

N_Boot

Number of bootstrap samples per iteration.

RFs

A numeric matrix (T x F) representing the time series of risk factors.


Gathers the general inputs for model estimation

Description

Gathers the general inputs for model estimation

Usage

GeneralMLEInputs(
  Yields,
  RiskFactors,
  FactorLabels,
  mat,
  DataFrequency,
  Label_Multi_Models,
  Economies,
  ModelType,
  UnitYields
)

Arguments

Yields

matrix (CJ x T) or a list containing those matrices, where C is the number of countries, J - the number of maturities and T - time series length

RiskFactors

time series of risk factors (F x T). Could be stored in a list depending on the model

FactorLabels

string-list based which contains the labels of all variables present in the model

mat

vector of maturities (in years) used in the estimation

DataFrequency

single element character-based vector. Available options are: "Daily All Days",
"Daily Business Days", "Weekly", "Monthly", "Quarterly", "Annually"

Label_Multi_Models

string-vector containing the names of the multicountry setups

Economies

string-vector containing the names of the economies which are part of the economic system

ModelType

string-vector containing the label of the model to be estimated


Compute the auxiliary parameters a.

Description

Compute the auxiliary parameters a.

Usage

GetAuxPara(
  ParaValue,
  Const_Type_Full,
  Economies,
  FactorLabels,
  JLLinputs = NULL
)

Arguments

ParaValue

Parameter value

Const_Type_Full

character-based vector that describes the constraints. Constraints are:

  • 'Jordan' for single-country models;

  • 'Jordan; stationary' for single-country models;

  • 'Jordan MultiCountry' for multicountry models;

  • 'Jordan MultiCountry; stationary' for multicountry models;

  • 'psd' for JPS-based models;

  • 'BlockDiag' for GVAR-based models;

  • 'JLLstructure' for JLL-based models;

Economies

string-vector containing the names of the economies which are part of the economic system

FactorLabels

string-list based which contains the labels of all the variables present in the model

JLLinputs

list of necessary inputs for the estimation of JLL-based models (see "JLL" function)


Generate the variable labels of the JLL models

Description

Generate the variable labels of the JLL models

Usage

GetLabels_JLL(NonOrthoFactors, JLLinputs, G)

Arguments

NonOrthoFactors

Risk factors before the orthogonalization (FxT)

JLLinputs

List of necessary inputs to estimate JLL-based setups

G

number of global unspanned factors (scalar)


Generate the factor labels for models estimated on a country-by-country basis

Description

Generate the factor labels for models estimated on a country-by-country basis

Usage

GetLabels_sepQ(Economy, ModelType, FactorLabels)

Arguments

Economy

string containing the names of the economy to be estimated

ModelType

string-vector containing the label of the model to be estimated

FactorLabels

list containing the factor labels


Compute the parameters used in the P-dynamics of the model

Description

Compute the parameters used in the P-dynamics of the model

Usage

GetPdynPara(
  RiskFactors,
  FactorLabels,
  Economies,
  ModelType,
  BRWinputs,
  GVARinputs,
  JLLinputs,
  CheckInputs = F,
  verbose
)

Arguments

RiskFactors

time series of risk factors (F x T). Could be stored in a list depending on the model

FactorLabels

string-list based which contains the labels of all variables present in the model

Economies

string-vector containing the names of the economies which are part of the economic system

ModelType

string-vector containing the label of the model to be estimated

BRWinputs

list of necessary inputs for performing the bias-corrected estimation (see "Bias_Correc_VAR" function)

GVARinputs

list of necessary inputs for the estimation of GVAR-based models (see "GVAR" function)

JLLinputs

list of necessary inputs for the estimation of JLL-based models (see "JLL" function)

CheckInputs

Logical. Whether to perform a prior check on the consistency of the provided input list. Default is FALSE.

verbose

Logical flag controlling function messaging.


Compute P-dynamics parameters using the bias correction method from BRW (2012)

Description

Compute P-dynamics parameters using the bias correction method from BRW (2012)

Usage

GetPdynPara_BC(
  ModelType,
  BRWinputs,
  RiskFactors,
  Economies,
  FactorLabels,
  GVARinputs,
  JLLinputs,
  verbose
)

Arguments

ModelType

string-vector containing the label of the model to be estimated

BRWinputs

list of necessary inputs for performing the bias-corrected estimation (see "Bias_Correc_VAR" function)

RiskFactors

time series of risk factors (F x T). Could be stored in a list depending on the model

Economies

string-vector containing the names of the economies which are part of the economic system

FactorLabels

string-list based which contains the labels of all variables present in the model

GVARinputs

list of necessary inputs for the estimation of GVAR-based models (see "GVAR" function)

JLLinputs

list of necessary inputs for the estimation of JLL-based models (see "JLL" function)

verbose

Logical flag controlling function messaging.


Compute P-dynamics parameters without using the bias correction method from BRW (2012)

Description

Compute P-dynamics parameters without using the bias correction method from BRW (2012)

Usage

GetPdynPara_NoBC(
  ModelType,
  RiskFactors,
  Economies,
  N,
  GVARinputs,
  JLLinputs,
  CheckInpts = F
)

Arguments

ModelType

string-vector containing the label of the model to be estimated

RiskFactors

time series of risk factors (F x T). Could be stored in a list depending on the model

Economies

string-vector containing the names of the economies which are part of the economic system

N

number of country-specific spanned factors

GVARinputs

list of necessary inputs for the estimation of GVAR-based models (see "GVAR" function)

JLLinputs

list of necessary inputs for the estimation of JLL-based models (see "JLL" function)


Map auxiliary (unconstrained) parameters a to constrained parameters b

Description

Map auxiliary (unconstrained) parameters a to constrained parameters b

Usage

GetTruePara(
  ParaValue,
  Const_Type_Full,
  FactorLabels,
  Economies,
  JLLinputs = NULL,
  GVARinputs = NULL
)

Arguments

ParaValue

unconstrained auxiliary parameter

Const_Type_Full

One of the following options:

  • 'Jordan'

  • 'Jordan; stationary'

  • 'Jordan MultiCountry'

  • 'Jordan MultiCountry; stationary'

  • 'psd';

  • 'BlockDiag'

  • 'JLLstructure'

FactorLabels

string-list based which contains the labels of all the variables present in the model

Economies

string-vector containing the names of the economies which are part of the economic system

JLLinputs

Inputs used in the estimation of the JLL-based models

GVARinputs

Inputs used in the estimation of the GVAR-based models


Gather all country-specific yields in a single matrix of dimension CJ x T

Description

Gather all country-specific yields in a single matrix of dimension CJ x T

Usage

GetYields_AllCountries(ModelPara, Economies, ModelType)

Arguments

ModelPara

List of model parameter estimates

Economies

String-vector containing the names of the economies which are part of the economic system

ModelType

A string-vector containing the label of the model to be estimated


Compute the A loadings

Description

Compute the A loadings

Usage

Get_As(LoadBs, Wpca, r0, dt, Economies, ModelType)

Arguments

LoadBs

list containing the B loadings

Wpca

matrix of weights of the portfolios observed without errors (N x J or CN x J)

r0

long-run interest rate (scalar or vector with length C)

dt

time interval unit of the model (scalar). For instance, if data is (i) monthly, dt <- 12; (ii) quarterly, dt <- 4; (iii) yearly, dt <- 1

Economies

string-vector containing the names of the economies which are part of the economic system

ModelType

string-vector containing the label of the model to be estimated


Compute the B matrix of loadings

Description

Compute the B matrix of loadings

Usage

Get_BFull(ModelParaPE, FactorLabels, mat, Economies, ModelType)

Arguments

ModelParaPE

List of point estimates of the model parameter

FactorLabels

String-list based which contains the labels of all the variables present in the model

mat

Vector of bond yield maturities

Economies

String-vector containing the names of the economies which are part of the economic system

ModelType

A character vector indicating the model type to be estimated


Build the B loadings

Description

Build the B loadings

Usage

Get_Bs(mat, dt, K1XQ, SSZ, Wpca, FactorLabels, Economy, ModelType)

Arguments

mat

vector of maturities (in years) of yields used in estimation (J x 1)

dt

time interval unit of the model (scalar). For instance, if data is (i) monthly, dt <- 12; (ii) quarterly, dt <- 4; (iii) yearly, dt <- 1

K1XQ

risk-neutral feedback matrix (N x N or CN x CN)

SSZ

variance-covariance matrix (F x F)

Wpca

matrix of weights of the portfolios observed without errors (N x J or CN x J)

FactorLabels

string-list based which contains the labels of all the variables present in the model

Economy

string-vector containing the names of the economies which are part of the economic system

ModelType

string-vector containing the label of the model to be estimated


Estimate feedback matrix from several models (No bias-corrected version)

Description

Estimate feedback matrix from several models (No bias-corrected version)

Usage

Get_FeedMat_NoBC(
  RiskFactors,
  ModelType,
  Economies,
  GVARinputs,
  JLLinputs,
  FactorLabels,
  CheckInpts = FALSE
)

Arguments

RiskFactors

A numeric matrix (T x F) representing the time series of risk factors.

Economies

A character vector containing the names of the economies included in the system.

GVARinputs

List. Inputs for GVAR model estimation.

JLLinputs

List. Inputs for JLL model estimation.

FactorLabels

A list of character vectors with labels for all variables in the model.

CheckInpts

Check for the consistency of the provided inputs. Default is FALSE.


Get the intercept, feedback matrix and the variance-covariance matrix from GVAR without global factors

Description

Get the intercept, feedback matrix and the variance-covariance matrix from GVAR without global factors

Usage

Get_G0G1Sigma(ParaVARX, GVARinputs, Ai0, Ai1, Wi)

Arguments

ParaVARX

Set of VARX model parameters

GVARinputs

List of inputs for GVAR-based models

Ai0

list containing the country-specific intercepts

Ai1

list containing the country-specific feedback matrices

Wi

list containing the country-specific link matrices


Compute the feedback matrix from a GVAR model with global factors

Description

Compute the feedback matrix from a GVAR model with global factors

Usage

Get_Gy1(ParaVARX, GVARinputs, G1, Phi_w1)

Arguments

ParaVARX

List containing the set of VARX model parameters

GVARinputs

List of inputs for GVAR-based models

G1

feedback matrix from a GVAR without global variables

Phi_w1

feedback matrix from a marginal model


Compute the variance-covariance matrix after the bias correction procedure

Description

Compute the variance-covariance matrix after the bias correction procedure

Usage

Get_SSZ_BC(K1Z_BC, RiskFactors, GVARinputs, JLLinputs, FactorLabels, ModelType)

Arguments

K1Z_BC

Feedback matrix resulting from the bias-correction procedure

RiskFactors

time series of the risk factors (T x F)

GVARinputs

inputs used in the estimation of the GVAR-based models (see "GVAR" function). Default is set to NULL

JLLinputs

inputs used in the estimation of the JLL-based models (see "JLL" function). Default is set to NULL

FactorLabels

string-list based which contains the labels of all variables present in the model

ModelType

string-vector containing the label of the model to be estimated


Compute the variance-covariance matrix of the bond yields

Description

Compute the variance-covariance matrix of the bond yields

Usage

Get_SigmaYields(YieldsTS, N, mat, WpcaFull, se, ModelType)

Arguments

YieldsTS

matrix of yields used in estimation (J x T or CJ x T)

N

number of country-specific spanned factors

mat

vector of maturities (in years) of yields used in estimation (J x 1)

WpcaFull

composite matrix of weights the portfolios observed with and without errors

se

Variance of the portfolio of yields observed with error (scalar). Default is set to NULL

ModelType

string-vector containing the label of the model to be estimated


Compute Sigmas/Cholesky factorizations

Description

Compute Sigmas/Cholesky factorizations

Usage

Get_Sigma_JLL(JLLinputs, FacSet, Para_Ortho_Reg, Para_Ortho_VAR, N)

Arguments

JLLinputs

List of necessary inputs to estimate JLL-based setups

FacSet

Set of factors used in the estimation of JLL-based setups

Para_Ortho_Reg

Set of parameters obtained from the JLL regressions

Para_Ortho_VAR

Set of parameters obtained from the VAR(1) of JLL-based models

N

number of country-specific spanned factors (scalar)


Collect both the domestic and global unspanned factors of all countries in single matrices

Description

Collect both the domestic and global unspanned factors of all countries in single matrices

Usage

Get_Unspanned(ModelPara, FactorLabels, Economies, ModelType)

Arguments

ModelPara

List of model parameter estimates

FactorLabels

A string-list based which contains all the labels of all the variables present in the model

Economies

String-vector containing the names of the economies which are part of the economic system

ModelType

A string-vector containing the label of the model to be estimated


Compute the cross-section loadings of yields of a canonical A0_N model

Description

Compute the cross-section loadings of yields of a canonical A0_N model

Usage

Get__BnXAnX(mat, K1XQ, ModelType, r0 = NULL, SSX = NULL, Economies)

Arguments

mat

vector of maturities (J x 1).

K1XQ

risk-neutral feedback matrix (N x N)

ModelType

string-vector containing the label of the model to be estimated

r0

the long run risk neutral (scalar)

SSX

covariance matrix of the latent states (N x N)

Economies

string-vector containing the names of the economies which are part of the economic system

References


Obtain the country-specific a0

Description

Obtain the country-specific a0

Usage

Get_a0(GVARinputs, ParaVARX)

Arguments

GVARinputs

List of inputs for GVAR-based models

ParaVARX

List containing the set of VARX model parameters


Compute the log-likelihood function

Description

Compute the log-likelihood function

Usage

Get_llk(P, Y, Z, N, mat, We, Wpca, K0Z, K1Z, SSZ, LoadBs, LoadAs, ModelType)

Arguments

P

time-series of spanned factors (N x T or CN x T)

Y

time-series of yields (J x T or CJ x T)

Z

time-series of risk factors (F x T)

N

number of country-specific spanned factors

mat

vector of maturities (in years) of yields used in estimation (J x 1)

We

matrix of weights of the portfolios observed with errors ((J-N) x J or C(J-N) x CJ)

Wpca

matrix of weights of the portfolios observed without errors (N x J or CN x CJ)

K0Z

matrix of intercepts (P-dynamics)

K1Z

feedback matrix (P-dynamics)

SSZ

variance-covariance matrix (P-dynamics)

LoadBs

list containing the B loadings

LoadAs

list containing the A loadings

ModelType

string-vector containing the label of the model to be estimated


Compute long-run risk neutral mean (r0) for the various models

Description

Compute long-run risk neutral mean (r0) for the various models

Usage

Get_r0(Y, P, N, mat, dt, B_list, Wpca, We, Economies, ModelType)

Arguments

Y

matrix of yields used in estimation (J x T or CJ x T)

P

complete set of spanned factors (N x T or CN x T)

N

number of country-specific spanned factors

mat

vector of maturities (in years) of yields used in estimation (J x 1)

dt

time interval unit of the model (scalar). For instance, if data is (i) monthly, dt <- 12; (ii) quarterly, dt <- 4; (iii) yearly, dt <- 1.

B_list

list containing the B loadings

Wpca

matrix of weights of the portfolios observed without errors (N x J or CN x J)

We

matrix of weights of the portfolios observed with errors ((J-N) x J or C(J-N) x CJ)

Economies

string-vector containing the names of the economies which are part of the economic system

ModelType

string-vector containing the label of the model to be estimated


Get delta t

Description

Get delta t

Usage

Getdt(DataFrequency)

Arguments

DataFrequency

single element character-based vector. Available options are: "Daily All Days",
"Daily Business Days", "Weekly", "Monthly", "Quarterly", "Annually"


Data: Risk Factors - Candelon and Moura (2024, JFEC)

Description

Global risk factors data used in Candelon and Moura (2024, JFEC)

Usage

data("GlobalMacro")

Format

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.

Source

Global economic activity

Lutz Kilian’s index of global real economic activity <https://sites.google.com/site/lkilian2019/research/data-sets?authuser=0>

Global inflation

year-over-year variation of the OECD aggregated CPI containing all its state members <https://www.oecd.org/en/data/indicators/inflation-cpi.html>

References

Candelon, B. and Moura, R. (2024) "A Multicountry Model of the Term Structures of Interest Rates with a GVAR". (Journal of Financial Econometrics)


Data: Risk Factors - Candelon and Moura (2023, EM)

Description

Global risk factors data used in Candelon and Moura (2023)

Usage

data("GlobalMacro_covid")

Format

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.

Source

U.S. output growth:

OECD Weekly Tracker index <https://web-archive.oecd.org/sections/weekly-tracker-of-gdp-growth/index.htm>

China output growth:

weekly year-over-year change in the interpolated OECD leading indicator <https://www.oecd.org/en/data/indicators/composite-leading-indicator-cli.html>

S&P-500:

year-over-year variation from the Standard and Poor’s 500 stock market index. Simulated data constructed using FRED series.

References

Candelon, B. and Moura, R. (2023) "Sovereign yield curves and the COVID-19 in emerging markets". (Economic Modelling)


Generate the graphical outputs for the selected models (Point estimate)

Description

Generate the graphical outputs for the selected models (Point estimate)

Usage

GraphicalOutputs(
  ModelType,
  ModelPara,
  NumOut,
  InputsForOutputs,
  Economies,
  FactorLabels,
  Folder2save,
  verbose
)

Arguments

ModelType

A character vector indicating the model type to be estimated.

ModelPara

List of model parameter estimates (See the Optimization function)

NumOut

list of computed outputs containing the model fit, IRFs, FEVDs, GIRFs, GFEVDs and Term Premia

InputsForOutputs

list containing the desired inputs for the construction of the desired output

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.

Folder2save

Folder path where the outputs will be stored.

verbose

Logical flag controlling function messaging.


Find the indexes of zero-restrictions from the orthogonalized variance-covariance matrix from the JLL-based models

Description

Find the indexes of zero-restrictions from the orthogonalized variance-covariance matrix from the JLL-based models

Usage

IDXZeroRestrictionsJLLVarCovOrtho(M, N, G, Economies, DomUnit)

Arguments

M

number of country-specific unspanned factors (scalar)

N

number of country-specific spanned factors (scalar)

G

number of global unspanned factors (scalar)

Economies

Set of economies that are part of the economic system (string-vector)

DomUnit

Name of the economy which is assigned as the dominant unit.
If no dominant unit is assigned, then this variable is defined as "None"

Value

restricted version of the JLL of the Cholesky factorization (F x F)


IRFs and GIRFs for all models

Description

IRFs and GIRFs for all models

Usage

IRFandGIRF(ModelType, ModelPara, IRFhoriz, FactorLabels, Economies)

Arguments

ModelType

string-vector containing the label of the model to be estimated

ModelPara

list of model parameter estimates (See the "Optimization" function)

IRFhoriz

single numerical vector containing the desired horizon of analysis for the IRFs

FactorLabels

string-list based which contains the labels of all the variables present in the model

Economies

string-vector containing the names of the economies which are part of the economic system

Details

The Structural shocks from the IRFs are identified via Cholesky decomposition


IRFs and GIRFs after bootstrap for all models

Description

IRFs and GIRFs after bootstrap for all models

Usage

IRFandGIRF_BS(ModelType, ModelParaBoot, IRFhoriz, FactorLabels, Economies)

Arguments

ModelType

string-vector containing the label of the model to be estimated

ModelParaBoot

list of model parameter estimates (see the "Optimization" function) after a bootstrap draw

IRFhoriz

single numerical vector containing the desired horizon of analysis for the IRFs

FactorLabels

string-list based which contains all the labels of all the variables present in the model

Economies

string-vector containing the names of the economies which are part of the economic system


Creates the confidence bounds and the graphs of IRFs and GIRFs after bootstrap

Description

Creates the confidence bounds and the graphs of IRFs and GIRFs after bootstrap

Usage

IRFandGIRFbs(
  ModelType,
  ModelBootstrap,
  NumOutPE,
  InputsForOutputs,
  Economies,
  PathsGraphs,
  Folder2save,
  verbose
)

Arguments

ModelType

string-vector containing the label of the model to be estimated

ModelBootstrap

list containing the complete set of model parameters after bootstrap estimation procedure

NumOutPE

list of model parameter point estimates

InputsForOutputs

list containing the desired inputs for the construction of the outputs of interest

Economies

string-vector containing the names of the economies which are part of the economic system

PathsGraphs

path of the folder in which the graphs will be saved

Folder2save

Folder path where the outputs will be stored.

verbose

Logical flag controlling function messaging.


IRF and GIRF graphs for all models

Description

IRF and GIRF graphs for all models

Usage

IRFandGIRFgraphs(
  ModelType,
  NumOut,
  WishPdynamicsgraphs,
  WishYieldsgraphs,
  IRFhoriz,
  PathsGraphs,
  OutputType,
  Economies,
  Folder2save,
  verbose
)

Arguments

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 C economies included in the system.

Folder2save

character. Folder path where the outputs will be stored.

verbose

logical. Flag controlling function messaging.

Available Methods

- '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")'.

Examples

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
)


Gather data for IRFs and GIRFs grahs (version "Factors")

Description

Gather data for IRFs and GIRFs grahs (version "Factors")

Usage

IRFandGIRFs_Format_Fac(IRFFac)

Arguments

IRFFac

Data-frame with basic features of a single IRF for risk factors


Gather data for IRFs and GIRFs grahs (version "Yields")

Description

Gather data for IRFs and GIRFs grahs (version "Yields")

Usage

IRFandGIRFs_Format_Yields(IRFYields)

Arguments

IRFYields

Data-frame with basic features of a single IRF for yields


Find the indexes of the spanned factors

Description

Find the indexes of the spanned factors

Usage

IdxAllSpanned(ModelType, FactorLabels, Economies)

Arguments

ModelType

string-vector containing the label of the model to be estimated

FactorLabels

string-list based which contains the labels of all the variables present in the model

Economies

string-vector containing the names of the economies which are part of the economic system


Extract the indexes related to the spanned factors in the variance-covariance matrix

Description

Extract the indexes related to the spanned factors in the variance-covariance matrix

Usage

IdxSpanned(G, M, N, C)

Arguments

G

number of global unspanned factors (scalar)

M

number of domestic unspanned factors per country (scalar)

N

number of domestic spanned factors per country (scalar)

C

number of countries of the economic system (scalar)


Obtain the indexes of both the domestic and global unspanned factors

Description

Obtain the indexes of both the domestic and global unspanned factors

Usage

Idx_UnspanFact(RiskFactors_TS, FactorLabels, Economies)

Arguments

RiskFactors_TS

Time series of risk factors for the jointly estimated models (CJ x T)

FactorLabels

A string-list based which contains all the labels of all the variables present in the model

Economies

String-vector containing the names of the economies which are part of the economic system


Impose stationary constraint under the risk-neutral measure

Description

Impose stationary constraint under the risk-neutral measure

Usage

ImposeStat_Aux(yy, ub = 0.9999, lb = 1e-04)

Arguments

yy

numerical vector before imposing stationary constraint

ub

upper bound

lb

lower bound


Makes sure that the stationary constraint under the risk-neutral measure is preserved

Description

Makes sure that the stationary constraint under the risk-neutral measure is preserved

Usage

ImposeStat_True(params, K1Q, ub = 0.9999, lb = 1e-04)

Arguments

params

parameter of interest (scalar or matrix)

K1Q

risk-neutral feedback matrix

ub

upper bound. Default is 0.9999.

lb

lower bound. Default is 1e-4.


Example of list inputs used in the construction of several model outputs

Description

List of inputs of a JPS-based model for Brazilian data

Usage

data("InpForOutEx")

Format

list of inputs


Generates inputs necessary to build the likelihood function for the ATSM model

Description

Generates inputs necessary to build the likelihood function for the ATSM model

Usage

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
)

Arguments

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 (J x Td or CJ x Td)

GlobalMacro

numerical matrix with time series of the global risk factors (G x Td)

DomMacro

numerical matrix with time series of the country-specific risk factors for all C countries ( C X Td or CM x Td)

FactorLabels

list. Labels for all variables present in the model, as returned by LabFac.

Economies

character vector. Names of the C economies included in the system.

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 Bias_Correc_VAR). Default is FALSE.

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.

Value

An object of class 'ATSMModelInputs' containing the necessary inputs for performing the model optimization.

Permissible options for GVARlist

Permissible options for JLLlist

Permissible options for BRWlist

General Notation

Available Methods

- 'print(object)' - 'summary(object)'

Examples


# 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

Description

Collects the inputs that are used to construct the numerical and graphical outputs

Usage

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"
)

Arguments

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".

Value

List of necessary inputs to generate the graphs and outputs of the desired model.

Examples


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
)


Fit the cross-section of yields using spline

Description

Fit the cross-section of yields using spline

Usage

Intra_Yields(Yields, mat_vec, time_step)

Arguments

Yields

matrix containing country-specific yields (J x T)

mat_vec

vector of maturities expressed in years (J x 1)

time_step

time unit of the model (scalar)


Robust method for matrix inversion

Description

Robust method for matrix inversion

Usage

InvMat_Robust(M)

Arguments

M

squared matrix


Estimates the P-dynamics from JLL-based models

Description

Estimates the P-dynamics from JLL-based models

Usage

JLL(NonOrthoFactors, N, JLLinputs, CheckInputs = FALSE)

Arguments

NonOrthoFactors

numeric matrix (K x Td). Time series of risk factors before orthogonalization.

N

positive integer. Number of country-specific spanned factors.

JLLinputs

list. Necessary inputs to estimate JLL models:

  1. Economies: character vector. Set of C economies in the system.

  2. DomUnit: character. Name of the dominant economy, or "None" if not assigned (for "JLL No DomUnit" model).

  3. WishSigmas: logical. TRUE to estimate variance-covariance matrices and Cholesky factorizations; FALSE otherwise.

  4. SigmaNonOrtho: NULL or F x F matrix from non-orthogonalized dynamics.

  5. JLLModelType: character. Permissible choices: "JLL original", "JLL joint Sigma", "JLL No DomUnit".

CheckInputs

logical. Whether to perform a prior consistency check on the inputs provided in JLLinputs. Default is FALSE.

Value

List of model parameters from both the orthogonalized and non-orthogonalized versions of the JLL-based models

General Notation

References

Jotiskhatira, P. ; Le, A. and Lundblad, C. (2015). "Why do interest rates in different currencies co-move?" (Journal of Financial Economics)

Examples


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)


Main Jacobian approximation

Description

Main Jacobian approximation

Usage

Jac_approx(f, x, nlevels = 5L)

Arguments

f

function to differentiate

x

evaluation point

nlevels

depth of extrapolation. Default is 5.

References

Le, A., & Singleton, K. J. (2018). Small Package of Matlab Routines for Estimation of Some Term Structure Models. EABCN Training School.
This function offers an independent R implementation that is informed by the conceptual framework outlined in Le and Singleton (2018), but adapted to the present modeling context.


Convert a Matrix to Jordan-Like Form for Term Structure Models

Description

Convert a Matrix to Jordan-Like Form for Term Structure Models

Usage

JordanMat(matrix_in)

Arguments

matrix_in

squared matrix prior to Jordan form

Value

A matrix in a specialized block form used in term structure modeling

References


Check for JLL models for Jordan restrictions (auxiliary form)

Description

Check for JLL models for Jordan restrictions (auxiliary form)

Usage

Jordan_JLL(ParaValue, C, N)

Arguments

ParaValue

Constrained parameter value

C

number of countries of the economic system

N

number of country-specific spanned factors


Impose stationarity under the Q-measure

Description

Impose stationarity under the Q-measure

Usage

K1XQStationary(StationaryEigenvalues)

Arguments

StationaryEigenvalues

Binary variable: set "1" if the user wishes the largest eigenvalue to be strictly smaller than 1. Set "0", otherwise


Generates the labels for risk factors used in the model

Description

Generates the labels for risk factors used in the model

Usage

LabFac(N, DomVar, GlobalVar, Economies, ModelType)

Arguments

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".

Value

List containing the risk factor labels for spanned, domestic, star, and global variables, as well as tables for each country and all countries.

Examples

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)

Generate the labels of the spanned factors

Description

Generate the labels of the spanned factors

Usage

LabelsSpanned(N)

Arguments

N

number of spanned factors


Generate the labels of the star variables

Description

Generate the labels of the star variables

Usage

LabelsStar(FactorLabels)

Arguments

FactorLabels

Factor labels


Loads data sets from several papers

Description

Loads data sets from several papers

Usage

LoadData(DataPaper)

Arguments

DataPaper

Available options are BR_2017 (Bauer and Rudebusch, 2017) , CM_2023 (Candelon and Moura, 2023), CM_2024 (Candelon and Moura, 2024)

Value

Complete set of data from several papers.

References

  1. Bauer and Rudebusch (2017). "Resolving the Spanning Puzzle in Macro-Finance Term Structure Models" (Review of Finance)

  2. Candelon and Moura (2023). "Sovereign yield curves and the COVID-19 in emerging markets" (Economic Modelling)

  3. Candelon and Moura (2024). "A Multicountry Model of the Term Structures of Interest Rates with a GVAR" (Journal of Financial Econometrics)

Examples

# Example 1:
LoadData("BR_2017")

# Example 2:
LoadData("CM_2023")

# Example 3:
LoadData("CM_2024")


Read data from Excel files and return a named list of data frames

Description

Read data from Excel files and return a named list of data frames

Usage

Load_Excel_Data(ExcelFilePath)

Arguments

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.

Details

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.

Value

Named list of data frames, one for each sheet in the Excel file. The names of the list elements correspond to the sheet names.

Examples

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"))
}

Compute the maximum likelihood function of all models

Description

Compute the maximum likelihood function of all models

Usage

MLEdensity(
  K1XQ,
  r0,
  SSZ,
  K0Z,
  K1Z,
  se,
  Gy.0,
  mat,
  Y,
  Z,
  P,
  Wpca,
  We,
  WpcaFull,
  dt,
  Economies,
  FactorLabels,
  ModelType,
  GVARinputs = NULL,
  JLLinputs = NULL,
  BS_outputs = FALSE,
  ExportListOut = TRUE
)

Arguments

K1XQ

risk-neutral feedback matrix (N x N or CN x CN)

r0

long-run interest rate (scalar or vector with length C)

SSZ

variance-covariance matrix (F x F)

K0Z

intercept from the P-dynamics (F x 1)

K1Z

feedback matrix from the P-dynamics (F x F)

se

Variance of the portfolio of yields observed with error (scalar). Default is set to NULL.

Gy.0

matrix of contemporaneous terms from the P-dynamics (F x F)

mat

vector of maturities (in years) of yields used in estimation (J x 1)

Y

matrix of yields used in estimation (J x T or CJ x T)

Z

complete set of spanned and unspanned factors (F x T)

P

complete set of spanned factors (N x T or CN x T)

Wpca

matrix of weights of the portfolios observed without errors (N x J or CN x J)

We

matrix of weights of the portfolios observed with errors ((J-N) x J or C(J-N) x CJ)

WpcaFull

composite matrix of weights the portfolios observed with and without errors

dt

time interval unit of the model (scalar). For instance, if data is (i) monthly, dt <- 12; (ii) quarterly, dt <- 4; (iii) yearly, dt <- 1.

Economies

string-vector containing the names of the economies which are part of the economic system

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

GVARinputs

if the model chosen is the "GVAR single" or "GVAR multi", the "GVARinputs" should be specified (see "GVAR" function)

JLLinputs

if the model chosen is JLL-based. "JLLinputs" should contain (i) DomUnit, (ii) WishSigmas, (iii) SigmaNonOrtho, (iv) JLLModelType (See JLL function)

BS_outputs

Generates simplified output list in the bootstrap setting. Default is set to FALSE.

ExportListOut

export the complete ATSM outputs. Default is TRUE.

References


Set up the vector-valued objective function (Point estimate)

Description

Set up the vector-valued objective function (Point estimate)

Usage

MLFunction(
  MLEinputs,
  Economies,
  DataFrequency,
  FactorLabels,
  ModelType,
  BS_outType = FALSE
)

Arguments

MLEinputs

Set of inputs that are necessary to the log-likelihood function

Economies

string-vector containing the names of the economies which are part of the economic system

DataFrequency

character-based vector: "Daily All Days", "Daily Business Days", "Weekly", "Monthly", "Quarterly", "Annually"

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

BS_outType

Generates simplified output list in the bootstrap setting. Default is set to FALSE.

Value

objective function


Prevents algorithm to end up in ill-defined likelihood

Description

Prevents algorithm to end up in ill-defined likelihood

Usage

ML_stable(par, MLvec)

Arguments

par

vector of parameters

MLvec

objective function


Mean of the llk function used in the estimation of the selected ATSM

Description

Mean of the llk function used in the estimation of the selected ATSM

Usage

MLtemporary(xtemp, scaling_vector, MLvec)

Arguments

xtemp

temporary vector of parameters to be estimated numerically

scaling_vector

scaling factor

MLvec

log-likelihood function


Estimate the marginal model for the global factors

Description

Estimate the marginal model for the global factors

Usage

MarginalModelPara(GVARinputs)

Arguments

GVARinputs

List of inputs for GVAR-based models


Adjust vector of maturities

Description

Adjust vector of maturities

Usage

MatAdjusted(mat, UnitYields)

Arguments

mat

vector of maturities (J x 1)

UnitYields

Available options: "Month" and "Year"


Create a vector of numerical maturities in years

Description

Create a vector of numerical maturities in years

Usage

Maturities(DataYields, Economies, UnitYields)

Arguments

DataYields

matrix containing all yields of the system (JxT,if the model is single-country-based or CJxT if the model is multy-country-based)

Economies

vector containing names of all the economies of the system

UnitYields

(i) "Month": if maturity of yields are expressed in months or (ii) "Year": if maturity of yields are expressed in years

Value

Vector containing all observed maturities expressed in years


Limit the number of categories in FEVDs and GFEVDs graphs by merging small groups into other

Description

Limit the number of categories in FEVDs and GFEVDs graphs by merging small groups into other

Usage

MergeFEVD_graphs(FEVDlist, Threshold = 0.05)

Arguments

FEVDlist

list of FEVD and GFEVD outputs

Threshold

Threshold for merging factors. Default is 0.05.


Overview of Datasets Included in the MultiATSM Package

Description

The package includes several pre-processed datasets used for estimation and replication examples:

Details

GlobalMacro

Global macro-financial risk factors, namely global economic activity and global inflation.

GlobalMacro_covid

Global macro-financial risk factors, namely the output growth rate from the U.S. and China and the S&P 500 index.

DomMacro

Domestic macroeconomic risk factors, namely economic activity and inflation.

DomMacro_covid

Domestic macroeconomic risk factors, namely otput growth, inflation, CDS and the COVID-19 reproduction rate

TradeFlows

Bilateral trade flow series used in GVAR examples as a proxy measure of cross-country conectdness.

TradeFlows_covid

Bilateral trade flow series used in GVAR examples as a proxy measure of cross-country conectdness.

Yields

Monthly series of bond yields by maturity for multiple economies.

Yields_covid

Weekly series of sovereign bond yields by maturity for multiple economies.

RiskFacFull

Full set of risk factors (global and domestic) data used throughout the package

GVARFactors

List of risk factors used in the estimation of GVAR models.

BR_jps_out

Replications of the JPS outputs by Bauer and Rudebusch (2017)

InpForOutEx

List of inputs for an illustrative JPS model with Brazilian data

ParaSetEx

List of set of parameterafter optimization for an illustrative JPS model with Brazilian data

NumOutEx

List of numerical outputs for an illustrative JPS model with Brazilian data

Out_Example

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.

References

  1. Candelon, B. and Moura, R. (2023) "Sovereign yield curves and the COVID-19 in emerging markets". (Economic Modelling)

  2. Candelon, B. and Moura, R. (2024) "A Multicountry Model of the Term Structures of Interest Rates with a GVAR". (Journal of Financial Econometrics)


Obtain the non-orthogonalized model parameters

Description

Obtain the non-orthogonalized model parameters

Usage

NoOrthoVAR_JLL(Para_Ortho_Reg, Para_Ortho_VAR)

Arguments

Para_Ortho_Reg

Set of parameters obtained from the JLL regressions

Para_Ortho_VAR

Set of parameters obtained from the VAR(1) of JLL-based models


Example of computed numerical outputs

Description

Numerical outputs for JPS-based model using Brazilian data

Usage

data("NumOutEx")

Format

list of inputs and outputs

PC var explained

variance explained per spanned factor

Fit

model fit of bond yields

IRF

Impulse response function

FEVD

Forecast error variance decomposition

GIRF

Generalized impulse response function

GFEVD

Generalized Forecast error variance decomposition

TermPremiaDecomp

Term Premia decomposition


Constructs the model numerical outputs (model fit, IRFs, GIRFs, FEVDs, GFEVDs, and term premia)

Description

Constructs the model numerical outputs (model fit, IRFs, GIRFs, FEVDs, GFEVDs, and term premia)

Usage

NumOutputs(
  ModelType,
  ModelPara,
  InputsForOutputs,
  FactorLabels,
  Economies,
  Folder2save = NULL,
  verbose = TRUE
)

Arguments

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 Optimization

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 LabFac.

Economies

character vector. Names of the C economies included in the system.

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.

Details

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.

Value

An object of class 'ATSMNumOutputs' containing the following keys elements:

  1. Model parameter estimates

  2. Model fit of bond yields

  3. IRFs

  4. FEVDs

  5. GIRFs

  6. GFEVDs

  7. Bond yield decomposition

Available methods

- 'autoplot(object, type)'

References

Pesaran, H. Hashem, and Shin, Yongcheol. "Generalized impulse response analysis in linear multivariate models." Economics letters 58.1 (1998): 17-29.

Examples

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
)


Numerical outputs (IRFs, GIRFs, FEVD, and GFEVD) for bootstrap

Description

Numerical outputs (IRFs, GIRFs, FEVD, and GFEVD) for bootstrap

Usage

NumOutputs_Bootstrap(
  ModelType,
  ModelParaBoot,
  InputsForOutputs,
  FactorLabels,
  Economies
)

Arguments

ModelType

A character vector indicating the model type to be estimated.

ModelParaBoot

A list of model parameter estimates (see the "Optimization" function) after a bootstrap draw

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.


Perform out-of-sample forecast of bond yields

Description

Perform out-of-sample forecast of bond yields

Usage

OOS_Forecast(
  ForHoriz,
  t_Last,
  ModelParaList,
  FactorLabels,
  Yields_FullSample,
  Economies,
  ModelType
)

Arguments

ForHoriz

Forecast horizon-ahead (scalar)

t_Last

Index of the last set of observations in the information set at a given forecasting round

ModelParaList

List of model parameter estimates

FactorLabels

A string-list based which contains all the labels of all the variables present in the model

Yields_FullSample

Time-series of bond yields, complete set (J x T or CJ x T)

Economies

String-vector containing the names of the economies which are part of the economic system

ModelType

A string-vector containing the label of the model to be estimated


Prepare outputs to export after the model optimization

Description

Prepare outputs to export after the model optimization

Usage

OptOutputs(
  Y,
  Z,
  mat,
  N,
  dt,
  Wpca,
  K1XQ,
  SSZ,
  LoadAs,
  LoadBs,
  r0,
  se,
  K0Z,
  K1Z,
  Gy.0,
  VarYields,
  y,
  GVARinputs,
  JLLinputs,
  Economies,
  ModelType,
  BS_out = FALSE
)

Arguments

Y

matrix of yields used in estimation (J x T or CJ x T)

Z

complete set of spanned and unspanned factors (F x T)

mat

vector of maturities (in years) of yields used in estimation (J x 1)

N

number of country-specific spanned factors

dt

time interval unit of the model (scalar)

Wpca

matrix of weights of the portfolios observed without errors (N x J or CN x J)

K1XQ

risk-neutral feedback matrix (N x N or CN x CN)

SSZ

variance-covariance matrix (F x F)

LoadAs

list containing the A loadings

LoadBs

list containing the B loadings

r0

long-run interest rate (scalar or vector with length C)

se

Variance of the portfolio of yields observed with error (scalar).

K0Z

intercept from the P-dynamics (F x 1)

K1Z

feedback matrix from the P-dynamics (F x F)

Gy.0

matrix of contemporaneous terms from the P-dynamics (F x F)

VarYields

variance-covariance matrix of the bond yields

y

likelihood of each time series (Tx1)

GVARinputs

List of inputs from GVAR models

JLLinputs

List of inputs from JLL models

Economies

string containing the names of the economy to be estimated

ModelType

string-vector containing the label of the model to be estimated

BS_out

Bootstrap output. Default is FALSE.


Perform the optimization of the log-likelihood function of the chosen ATSM

Description

Perform the optimization of the log-likelihood function of the chosen ATSM

Usage

Optimization(
  MLEinputs,
  StatQ,
  DataFreq,
  FactorLabels,
  Economies,
  ModelType,
  tol = 1e-04,
  EstType = c("BFGS", "Nelder-Mead"),
  TimeCount = TRUE,
  BS_outputs = FALSE,
  verbose = TRUE
)

Arguments

MLEinputs

list. Contains the inputs for building the log-likelihood function (see InputsForOpt).

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 LabFac.

Economies

character vector. Names of the C 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".

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.

Value

An object of class 'ATSMModelOutputs' containing model outputs after the optimization of the chosen ATSM specification.

Available Methods

- 'summary(object)'

References

Examples

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)


Optimization routine for the entire selected ATSM

Description

Optimization routine for the entire selected ATSM

Usage

OptimizationSetup_ATSM(x0, MLvec, EstType, tol = 1e-04, verbose = FALSE)

Arguments

x0

List containing features for estimation of the risk-neutral parameters.

MLvec

Log-likelihood function

EstType

Estimation type. Available options: "BFGS" and "Nelder-Mead".

tol

convergence tolerance (scalar). Default value is set as 1e-4.

verbose

Logical flag controlling function messaging.


Perform the minimization of ML function

Description

Perform the minimization of ML function

Usage

Optimization_PE(
  ML_fun,
  ListInputSet,
  FactorLabels,
  Economies,
  ModelType,
  JLLinputs = NULL,
  GVARinputs = NULL,
  tol = 1e-04,
  EstType,
  TimeCount = TRUE,
  verbose
)

Arguments

ML_fun

vector-valued objective ML function

ListInputSet

list containing :

  1. a starting value for K1XQ and/or SSZ

  2. a variable label among the following:

    • 'Jordan' or 'Jordan; stationary' for single countries setups or 'Jordan MultiCountry' or 'Jordan MultiCountry; stationary'. All cases related to the computation of a K1XQ parameter;

    • 'psd': PSD matrix, used for JPS-based models. It relates to the SSZ parameter;

    • 'BlockDiag': block diagonal matrix, used for JPS-based models. It relates to the SSZ parameter.

    • 'JLLstructure': to impose the zero-restrictions on the SSZ term along the lines of the JLL models

FactorLabels

list. Labels for all variables present in the model, as returned by LabFac.

Economies

character vector. Names of the C 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".

JLLinputs

List. Inputs for JLL model estimation (see JLL). Default is NULL.

GVARinputs

List. Inputs for GVAR model estimation (see GVAR). Default is NULL.

tol

convergence tolerance (scalar). Default value is 1e-4.

EstType

Available options are"BFGS" and/or "Nelder-Mead".

TimeCount

computes the required time for estimation of the model. Default is TRUE.

verbose

Logical flag controlling function messaging.


Compute the time elapsed in the numerical optimization

Description

Compute the time elapsed in the numerical optimization

Usage

Optimization_Time(start_time, verbose)

Arguments

start_time

Starting time

verbose

Logical flag controlling function messaging.


Get coefficients from the orthogonalized regressions

Description

Get coefficients from the orthogonalized regressions

Usage

OrthoReg_JLL(JLLinputs, N, FacSet, FactorLab_NonOrth, FactorLab_JLL)

Arguments

JLLinputs

List of necessary inputs to estimate JLL-based setups

N

number of country-specific spanned factors (scalar)

FacSet

Set of factors used in the estimation of JLL-based setups

FactorLab_NonOrth

Variable labels of the non-orthogonalized risk factors

FactorLab_JLL

Variable labels of the orthogonalized risk factors


VAR(1) with orthogonalized factors (JLL models)

Description

VAR(1) with orthogonalized factors (JLL models)

Usage

OrthoVAR_JLL(NonOrthoFactors, JLLinputs, Ortho_Set, FactLabels, N)

Arguments

NonOrthoFactors

Risk factors before the orthogonalization (FxT)

JLLinputs

List of necessary inputs to estimate JLL-based setups

Ortho_Set

Set of orthogonalized risk factors

FactLabels

Variable labels of the orthogonalized risk factors

N

number of country-specific spanned factors (scalar)


Complete list of several outputs from an ATSM

Description

Example for illustration used in the package vignette

Usage

data("Out_Example")

Format

several model classes

ModelParaList

List of parameter estimates of the selected ATSM

ATSMinputs

General inputs from an ATSM

Forecasts

List of forecast outputs

NumOut

List of numerical outputs

Bootstrap

List of set of outputs after bootstrap


Numerical outputs (variance explained, model fit, IRFs, GIRFs, FEVDs, GFEVDs, and risk premia decomposition) for all models

Description

Numerical outputs (variance explained, model fit, IRFs, GIRFs, FEVDs, GFEVDs, and risk premia decomposition) for all models

Usage

OutputConstruction(
  ModelType,
  ModelPara,
  InputsForOutputs,
  FactorLabels,
  Economies,
  verbose = TRUE
)

Arguments

ModelType

string-vector containing the label of the model to be estimated

ModelPara

list of model parameter estimates (See the "Optimization" function)

InputsForOutputs

list containing the desired horizon of analysis for the model fit, IRFs, GIRFs, FEVDs, GFEVDs, and risk premia decomposition

FactorLabels

string-list based which contains all the labels of all the variables present in the model

Economies

string-vector containing the names of the economies which are part of the economic system

verbose

Logical flag controlling function messaging. Default is TRUE.


Prepares inputs to export

Description

Prepares inputs to export

Usage

Outputs2exportMLE(
  Label_Multi_Models,
  Economies,
  RiskFactors,
  Yields,
  mat,
  ModelInputsGen,
  ModelInputsSpec,
  PdynPara,
  ModelType
)

Arguments

Label_Multi_Models

string-vector containing the names of the multicountry setups

Economies

string-vector containing the names of the economies which are part of the economic system

RiskFactors

time series of risk factors (F x T). Could be stored in a list depending on the model

Yields

matrix (CJ x T) or a list containing those matrices, where C is the number of countries, J - the number of maturities and T - time series length

mat

vector of maturities (in years) used in the estimation

ModelInputsGen

List of generic inputs

ModelInputsSpec

List of specific inputs

PdynPara

Model parameters estimated in the P-dynamics the

ModelType

string-vector containing the label of the model to be estimated


Create the variable labels used in the estimation

Description

Create the variable labels used in the estimation

Usage

ParaLabelsOpt(ModelType, WishStationarityQ, MLEinputs, BS_outputs = FALSE)

Arguments

ModelType

a string-vector containing the label of the model to be estimated

WishStationarityQ

User must set TRUE is she wishes to impose the largest eigenvalue under the Q to be strictly smaller than 1. Otherwise set FALSE

MLEinputs

Set of inputs that are necessary to the log-likelihood function

BS_outputs

Generates simplified output list in the bootstrap setting. Default is set to FALSE.


Example of parameter set after optimization

Description

JPS-based model for Brazilian data

Usage

data("ParaSetEx")

Format

list of inputs and outputs

Inupts

general model inputs

ModEst

model parameters estimates (JPS form)


Compute some key parameters from the P-dynamics (Bootstrap set)

Description

Compute some key parameters from the P-dynamics (Bootstrap set)

Usage

PdynResid_BS(ModelType, Economies, ModelPara_PE)

Arguments

ModelType

A character vector containing the label of the model to be estimated

Economies

A character vector containing the names of the economies included in the system.

ModelPara_PE

Point estimate from the model parameters


Compute the root mean square error for all models

Description

Compute the root mean square error for all models

Usage

RMSE(ForecastOutputs)

Arguments

ForecastOutputs

List of country-specific forecasts


Perform a linear regression using demeaned variables

Description

Perform a linear regression using demeaned variables

Usage

Reg_demean(LHS, RHS)

Arguments

LHS

Left-hand side variables

RHS

Right-hand side variables

Value

Beta coefficients


Exclude series that contain NAs

Description

Exclude series that contain NAs

Usage

RemoveNA(YieldsData, MacroData, Economies)

Arguments

YieldsData

List of country-specific bond yields

MacroData

List of country-specific and global economic variables

Economies

string-vector containing the names of the economies which are part of the economic system

Value

return the time series data that were not initially composed by NAs.


Compute the residuals from the original model

Description

Compute the residuals from the original model

Usage

ResampleResiduals_BS(
  residPdynOriginal,
  residYieOriginal,
  InputsForOutputs,
  ModelType,
  nlag = 1
)

Arguments

residPdynOriginal

Time-series of the residuals from the P-dynamics equation (T x F)

residYieOriginal

Time-series of the residuals from the observational equation (T x J or T x CJ)

InputsForOutputs

List containing the desired inputs for the construction of the numerical outputs.

ModelType

A character vector indicating the model type to be estimated

nlag

Number of lags in the P-dynamics. Default is set to 1.


Data: Full set of risk factors - Candelon and Moura (2024, JFEC)

Description

Full set of risk factors data used in Candelon and Moura (2024, JFEC)

Usage

data("RiskFacFull")

Format

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.

Source

Global unspanned factor

See data("GlobalMacro") for a detailed data description.

Domestic unspanned factor

See data("DomMacro") for a detailed data description.

Domestic spanned factor

First three principal components of each country set of bond yields. See data("Yields") for a detailed data description.

References

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

Description

Spanned and unspanned factors plot

Usage

RiskFactorsGraphs(
  ModelType,
  WishRFgraphs,
  ModelOutputs,
  Economies,
  FactorLabels,
  Folder2save,
  verbose
)

Arguments

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 Optimization).

Economies

character vector. Names of the C economies included in the system.

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.

Available Methods

- 'autoplot(object, type = "RiskFactors")'

Examples

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
)


Builds the complete set of time series of the risk factors (spanned and unspanned)

Description

Builds the complete set of time series of the risk factors (spanned and unspanned)

Usage

RiskFactorsPrep(
  FactorSet,
  Economies,
  FactorLabels,
  Initial_Date,
  Final_Date,
  DataFrequency
)

Arguments

FactorSet

Factor set list (see e.g. "GVARFactors" data file)

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.

Initial_Date

Start date of the sample period in the format yyyy-mm-dd

Final_Date

End date of the sample period in the format yyyy-mm-dd

DataFrequency

A character vector specifying the data frequency. Available options: "Daily All Days", "Daily Business Days", "Weekly", "Monthly", "Quarterly", "Annually".

Value

Risk factors used in the estimation of the desired ATSM


Compute the root of the eigenvalue of K1h

Description

Compute the root of the eigenvalue of K1h

Usage

RootEigen(K1_h, horiz, N)

Arguments

K1_h

K1_h squared matrix

horiz

Minimum horizon observed

N

number of country-specific spanned factors


Rotate latent states to observed ones

Description

Rotate latent states to observed ones

Usage

Rotate_Lat_Obs(X_List, U1, U0)

Arguments

X_List

list of risk-neutral parameters: (i) intercept (A_X); slope (B_X) and volatility matrix (SS_X)

U1

rotation matrix (N x N)

U0

rotation vector (N x 1)


Stochastic approximation algorithm

Description

Stochastic approximation algorithm

Usage

SA_algorithm(
  K1Z_NoBC,
  RiskFactors,
  BRWlist,
  GVARinputs,
  JLLinputs,
  FactorLabels,
  Economies,
  ModelType,
  verbose
)

Arguments

K1Z_NoBC

feedback matrix before bias-correction

RiskFactors

A numeric matrix (T x F) representing the time series of risk factors.

BRWlist

A list containing the necessary inputs for the BRW model estimation

GVARinputs

List. Inputs for GVAR model estimation.

JLLinputs

List. Inputs for JLL model estimation.

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.

verbose

verbose Logical flag controlling function messaging.


Computes the country-specific spanned factors

Description

Computes the country-specific spanned factors

Usage

Spanned_Factors(Yields, Economies, N)

Arguments

Yields

matrix (J x Td). Bond yields for all countries.

Economies

character vector. Names of the C economies included in the system.

N

integer. Desired number of country-specific spanned factors (maximum allowed is N = J).

Value

matrix. Contains the N spanned factors for all countries in the system (CJ x Td).

General Notation

Examples

data(Yields)
Economies <- c("China", "Brazil", "Mexico", "Uruguay")
N <- 3
SpaFact_TS <- Spanned_Factors(Yields, Economies, N)


Concatenate the model-specific inputs in a list

Description

Concatenate the model-specific inputs in a list

Usage

SpecificMLEInputs(
  ModelType,
  Economies,
  RiskFactors,
  FactorLabels,
  GVARlist = NULL,
  JLLlist = NULL,
  WishBRW = 0,
  BRWlist = NULL
)

Arguments

ModelType

string-vector containing the label of the model to be estimated

Economies

string-vector containing the names of the economies of the system

RiskFactors

time series of risk factors (F x T)

FactorLabels

string-list based which contains the labels of all the variables present in the model

GVARlist

A list of required inputs to estimate the GVAR-based setups:

  1. VARXtype string-vector containing the VARX feature (see "GVAR" function) (GVAR-based models)

  2. t_First_Wgvar Sample starting date (year) (GVAR-based models)

  3. t_Last_Wgvar Sample last date (year) (GVAR-based models)

  4. W_type Criterion used in the computation of the star variables (see "Transition_Matrix" function) (GVAR-based models)

JLLlist

A list of required inputs to estimate the JLL-based setups:

  1. DomUnit name of the economy which is assigned as the dominant unit (JLL-based models)

  2. WishSigmas equal to "1" if one wishes the variance-covariance matrices and the Cholesky factorizations (JLL-based models)

  3. SigmaNonOrtho NULL or some F x F matrix from the non-orthogonalized dynamics (JLL-based models)

WishBRW

Whether the user wishes to estimate the physical parameter model with the Bias correction model from BRW (2012) (see "Bias_Correc_VAR" function).
Default is set to 0.

BRWlist

A list of required inputs to estimate the bias corrected setups of the type of BRW:

  1. BiasCorrection binary variable. it takes value equal to 1 if the user whishes the estimates to be bias-corrected and 0, otherwise. (BRW model)

  2. flag_mean flag whether mean- (TRUE) or median- (FALSE) unbiased estimation is desired

  3. gamma adjustment parameter (BRW model)

  4. N_iter number of iterations (BRW model)

  5. N_burn number of burn-in iterations (BRW model)

  6. B number of bootstrap samples (BRW model)

  7. checkBRW flag whether the user wishes to perform the closeness check (BRW model)

  8. B_check number of bootstrap samples for closeness check


Term Premia decomposition graphs for all models

Description

Term Premia decomposition graphs for all models

Usage

TPDecompGraph(
  ModelType,
  NumOut,
  ModelPara,
  WishRPgraphs,
  UnitYields,
  Economies,
  PathsGraphs,
  Folder2Save,
  verbose
)

Arguments

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 Optimization).

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 C economies included in the system.

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.

Available Methods

- 'autoplot(object, type = "TermPremia")'

Examples

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
)


Compute the term premia

Description

Compute the term premia

Usage

TermPremia(ModelPara, avexp, ModelType, Economies)

Arguments

ModelPara

list of model parameter estimates

avexp

list containing the country-specific pure expected component

ModelType

desired model type

Economies

string-vector containing the names of the economies which are part of the economic system


Decomposition of yields into the average of expected future short-term interest rate and risk premia for all models

Description

Decomposition of yields into the average of expected future short-term interest rate and risk premia for all models

Usage

TermPremiaDecomp(
  ModelPara,
  FactorLabels,
  ModelType,
  InputsForOutputs,
  Economies
)

Arguments

ModelPara

list of model parameter estimates (see the "Optimization" function)

FactorLabels

string-list based which contains all the labels of all the variables present in the model

ModelType

string-vector containing the label of the model to be estimated

InputsForOutputs

list containing the desired horizon of analysis for the model fit, IRFs, GIRFs, FEVDs, GFEVDs, and risk premia decomposition

Economies

string-vector containing the names of the economies which are part of the economic system


Compute the star variables with time-varying weights

Description

Compute the star variables with time-varying weights

Usage

TimeVarWeights_GVAR(
  RiskFactors,
  Economies,
  RiskFactors_List,
  ListFactors,
  Wgvar,
  FactorLabels
)

Arguments

RiskFactors

A matrix of the complete set of risk factors (F x T).

Economies

A character vector containing the names of the economies included in the system.

RiskFactors_List

List of domestic risk factors (both spanned and unspanned)

ListFactors

List of risk factors

Wgvar

List of transition matrices

FactorLabels

A list of character vectors with labels for all variables in the model.


Data: Trade Flows - Candelon and Moura (2024, JFEC)

Description

Trade Flows data used in Candelon and Moura (2024, JFEC)

Usage

data("TradeFlows")

Format

A list. Contains bilateral trade flow data for Brazil, China, Mexico, and Uruguay, covering the sample period from 1948 to 2019.

Source

International Monetary Fund - International Trade in Goods (IMTS) <https://data.imf.org/en/datasets/IMF.STA:IMTS>

References

Candelon, B. and Moura, R. (2024) "A Multicountry Model of the Term Structures of Interest Rates with a GVAR". (Journal of Financial Econometrics)


Data: Trade Flows - Candelon and Moura (2023, EM)

Description

Trade Flows data used in Candelon and Moura (2023, EM)

Usage

data("TradeFlows_covid")

Format

A list. Contains bilateral trade flow data for Brazil, India, Mexico, and Russia, covering the sample period from 1948 to 2020.

Source

International Monetary Fund - International Trade in Goods (IMTS) <https://data.imf.org/en/datasets/IMF.STA:IMTS>

References

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

Description

Computes the transition matrix required in the estimation of the GVAR model

Usage

Transition_Matrix(t_First, t_Last, Economies, type, DataConnectedness)

Arguments

t_First

character. Sample starting date (format: yyyy).

t_Last

character. Sample ending date (format: yyyy).

Economies

character vector. Names of the C economies included in the system.

type

character. Method for computing interdependence. Possible options:

  • "Time-varying": Computes time-varying interdependence and returns weight matrices for each year.

  • "Sample Mean": Returns a single weight matrix with average weights over the sample period.

  • Specific year (e.g., "1998", "2005"): Computes time-invariant interdependence for the specified year.

DataConnectedness

list or data frame. Data used to compute the transition matrix (e.g., trade flows).

Details

If there is missing data for any country in a particular year, the transition matrix will include only NAs.

Value

matrix or list of matrices. Time-varying or time-invariant transition matrix depending on 'type'.

Examples

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)


Transformation of the block diagonal parameters (true form)

Description

Transformation of the block diagonal parameters (true form)

Usage

True_BlockDiag(ParaValue, Const_Type, FactorLabels, Economies, GVARinputs)

Arguments

ParaValue

Constrained parameter

Const_Type

Type of constraint

FactorLabels

string-list based which contains the labels of all the variables present in the model

Economies

string-vector containing the names of the economies which are part of the economic system

GVARinputs

Inputs used in the estimation of the GVAR-based models


Transformation of the JLL-related parameters (true form)

Description

Transformation of the JLL-related parameters (true form)

Usage

True_JLLstruct(ParaValue, Const_Type, FactorLabels, Economies, JLLinputs)

Arguments

ParaValue

Constrained parameter value

Const_Type

Type of constraint

FactorLabels

string-list based which contains the labels of all the variables present in the model

Economies

string-vector containing the names of the economies which are part of the economic system

JLLinputs

Inputs used in the estimation of the JLL-based models


Transformation of the Jordan-related parameters (True form)

Description

Transformation of the Jordan-related parameters (True form)

Usage

True_Jordan(ParaValue, Const_Type, FactorLabels, Economies)

Arguments

ParaValue

Constrained parameter

Const_Type

Type of constraint

FactorLabels

string-list based which contains the labels of all the variables present in the model

Economies

string-vector containing the names of the economies which are part of the economic system


Transformation of a PSD matrix (true form)

Description

Transformation of a PSD matrix (true form)

Usage

True_PSD(ParaValue, Const_Type)

Arguments

ParaValue

Constrained parameter value

Const_Type

Type of constraint


True function for a single-country specification

Description

True function for a single-country specification

Usage

True_jordan_OneCountry(ParaValue, stationary = FALSE)

Arguments

ParaValue

Constrained parameter

stationary

impose stationarity. Default is FALSE

References

Le, A., & Singleton, K. J. (2018). Small Package of Matlab Routines for Estimation of Some Term Structure Models. EABCN Training School.
This function offers an independent R implementation that is informed by the conceptual framework outlined in Le and Singleton (2018), but adapted to the present modeling context.


Update parameters in the optimization process

Description

Update parameters in the optimization process

Usage

Update_ParaList(
  x,
  ModelType,
  FactorLabels,
  Economies,
  JLLinputs = NULL,
  GVARinputs = NULL,
  ListInputSet
)

Arguments

x

vector containing all the vectorized auxiliary parameters

ModelType

string-vector containing the label of the model to be estimated

FactorLabels

string-list based which contains the labels of all the variables present in the model

Economies

string-vector containing the names of the economies which are part of the economic system

JLLinputs

Set of necessary inputs used in the estimation of the JLL-based models

GVARinputs

Set of necessary inputs used in the estimation of the GVAR-based models

ListInputSet

variable inputs used in the optimization (see "Optimization" function)


Update the variance-covariance matrix from the "JLL joint Sigma" model. Necessary for optimization

Description

Update the variance-covariance matrix from the "JLL joint Sigma" model. Necessary for optimization

Usage

Update_SSZ_JLL(SSZ, Z, N, JLLinputs)

Arguments

SSZ

Variance-covariance matrix from JLL model

Z

complete set of spanned and unspanned factors (F x T)

N

number of country-specific spanned factors

JLLinputs

List of inputs from JLL models


Estimates a standard VAR(1)

Description

Estimates a standard VAR(1)

Usage

VAR(RiskFactors, VARtype, Bcon_Mat = NULL)

Arguments

RiskFactors

numeric matrix (K x Td). Time series of risk factors.

VARtype

character. Permissible choices: "unconstrained" or "constrained".

Bcon_Mat

matrix (K x K + 1). Constraints matrix (includes intercept). Entries containing NAs are treated as free parameters. Default is NULL.

Value

list. Contains:

General Notation

Examples

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)


Estimate a VARX(1,1,1)

Description

Estimate a VARX(1,1,1)

Usage

VARX(GVARinputs, Factors_GVAR, DomLabels, StarLabels, GlobalLabels, N)

Arguments

GVARinputs

List of inputs for GVAR-based models

Factors_GVAR

list containing the set of eisk factors used in the estimation of the VARX models

DomLabels

string-based vector containing label of the domestic risk factors

StarLabels

string-based vector containing label of the star domestic risk factors

GlobalLabels

string-based vector containing label of the global risk factors

N

number of country-specific spanned factors (scalar)


Percentage explained by the spanned factors of the variations in the set of observed yields for all models

Description

Percentage explained by the spanned factors of the variations in the set of observed yields for all models

Usage

VarianceExplained(ModelType, ModelPara, FactorLabels, Economies)

Arguments

ModelType

string-vector containing the label of the model to be estimated

ModelPara

List of model parameter estimates (see the "Optimization" function)

FactorLabels

string-list based which contains all the labels of all the variables present in the model

Economies

string-vector containing the names of the economies which are part of the economic system


Extract graphs of interest (bootstrap version)

Description

Extract graphs of interest (bootstrap version)

Usage

WishGraphs_FEVDandGFEVD_Boot(InputsForOutputs, ModelType)

Arguments

InputsForOutputs

list containing the desired inputs for the construction of IRFs, GIRFs, FEVDs, and GFEVDs

ModelType

desired model type


Extract graphs of interest (bootstrap version)

Description

Extract graphs of interest (bootstrap version)

Usage

WishGraphs_IRFandGIRF_Boot(InputsForOutputs, ModelType)

Arguments

InputsForOutputs

list containing the desired inputs for the construction of IRFs, GIRFs, FEVDs, and GFEVDs

ModelType

desired model type


Extract list of desired graph features (IRFs anc GIRFs)

Description

Extract list of desired graph features (IRFs anc GIRFs)

Usage

Wished_Graphs_FEVDandGFEVD(InputsForOutputs, OutType, ModelType)

Arguments

InputsForOutputs

List of inputs for outputs

OutType

Output types "FEVD", "GFEVD" and "FEVD Ortho"

ModelType

desired model type


Extract list of desired graph features (IRFs anc GIRFs)

Description

Extract list of desired graph features (IRFs anc GIRFs)

Usage

Wished_Graphs_IRFandGIRF(InputsForOutputs, OutType, ModelType)

Arguments

InputsForOutputs

List of inputs for outputs

OutType

Output types "IRF", "GIRF" and "IRF Ortho"

ModelType

desired model type


Model-implied yields (cross-section)

Description

Model-implied yields (cross-section)

Usage

Y_Fit(ALoad, BLoad, Spa_TS, MatLength, TDim, YieldLab)

Arguments

ALoad

A loadings

BLoad

B loadings

Spa_TS

time series of spanned factors

MatLength

length of the vector of maturities

TDim

Time-series dimension

YieldLab

Label of yields


Model-implied yields (P-dynamics)

Description

Model-implied yields (P-dynamics)

Usage

Y_ModImp(ALoad, BLoad, K0Z, K1Z, PdynFact, MatLength, TDim, YieldLab)

Arguments

ALoad

A loadings

BLoad

B loadings

K0Z

intercept from the P-dynamics

K1Z

feedback matrix from the P-dynamics

PdynFact

time series of the risk-factors spanned factors

MatLength

length of the vector of maturities

TDim

Time-series dimension

YieldLab

Label of yields


Compute the confidence bounds for the model bond yield-related outputs

Description

Compute the confidence bounds for the model bond yield-related outputs

Usage

YieldBounds_FEVDandGFEVD(
  ModelBootstrap,
  quants,
  ModelType,
  ndraws,
  Horiz,
  FacDim,
  YieDim,
  LabFEVD,
  Economies
)

Arguments

ModelBootstrap

numerical output set from the bootstrap analysis

quants

quantile of the confidence bounds

ModelType

desired model type

ndraws

number of draws

Horiz

horizon of numerical outputs

FacDim

dimension of the risk factor set

YieDim

dimension of the bond yield set

LabFEVD

vector containing the labels "FEVD" and "GFEVD"

Economies

Economies that are part of the economic system


Compute the confidence bounds for the model bond yield-related outputs

Description

Compute the confidence bounds for the model bond yield-related outputs

Usage

YieldBounds_IRFandGIRF(
  ModelBootstrap,
  quants,
  ModelType,
  ndraws,
  Horiz,
  FacDim,
  YieDim,
  LabIRF,
  Economies
)

Arguments

ModelBootstrap

numerical output set from the bootstrap analysis

quants

quantile of the confidence bounds

ModelType

desired model type

ndraws

number of draws

Horiz

horizon of numerical outputs

FacDim

dimension of the risk factor set

YieDim

dimension of the bond yield set

LabIRF

vector containing the labels "IRF" and "GIRF"

Economies

Economies that are part of the economic system


Compile the bond yield forecast for any model type

Description

Compile the bond yield forecast for any model type

Usage

YieldFor(
  ModelParaList,
  ForHoriz,
  Economies,
  FactorLabels,
  ForLabels,
  ModelType
)

Arguments

ModelParaList

List of model parameter estimates

ForHoriz

Forecast horizon (scalar)

Economies

String-vector containing the names of the economies which are part of the economic system

FactorLabels

A string-list based which contains all the labels of all the variables present in the model

ForLabels

Forecast labels (string-based vector)

ModelType

A string-vector containing the label of the model to be estimated


Compute quantiles for model bond yield-related outputs

Description

Compute quantiles for model bond yield-related outputs

Usage

YieldQuantile_bs(
  DrawSet,
  LabIRF,
  ndraws,
  quants,
  Horiz,
  FacDim,
  YieDim,
  LabelsYies,
  ModelType,
  Ortho = FALSE
)

Arguments

DrawSet

Draw-specific set

LabIRF

vector containing the labels "IRF" and "GIRF"

ndraws

number of draws

quants

quantile of the confidence bounds

Horiz

horizon of numerical outputs

FacDim

dimension of the risk factor set

YieDim

dimension of the bond yield set

LabelsYies

labels of the factor set

ModelType

desired model type

Ortho

Orthogonolized version for the JLL models. Default is FALSE.


Data: bond yield data - Candelon and Moura (2024, JFEC)

Description

Yields data used in Candelon and Moura (2024, JFEC)

Usage

data("Yields")

Format

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.

Source

Brazil

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/>

China

Government bond yield data in domestic currency. Simulated data constructed using Bloomberg bond yield series.

Mexico

Government bond yield data in domestic currency. Simulated data constructed using Bloomberg bond yield series.

Uruguay

Government bond yield data in US dollars <https://web.bevsa.com.uy/CurvasVectorPrecios/CurvasIndices/CUD.aspx>.

References

Candelon, B. and Moura, R. (2024) "A Multicountry Model of the Term Structures of Interest Rates with a GVAR". (Journal of Financial Econometrics)


Computes two measures of model fit for bond yields (all models)

Description

Computes two measures of model fit for bond yields (all models)

Usage

YieldsFit(ModelType, ModelPara, FactorLabels, Economies)

Arguments

ModelType

a string-vector containing the label of the model to be estimated

ModelPara

List of model parameter estimates (See the "Optimization" function)

FactorLabels

a string-list based which contains the labels of all the variables present in the model

Economies

a string-vector containing the names of the economies which are part of the economic system

Details

"Model-implied yields" is the measure of fit based exclusively on the risk-neutral parameters, whereas the "Model-Fit" takes into account both the risk-neutral and the physical parameters.

References

See, for instance, Jotiskhatira, Le and Lundblad (2015). "Why do interest rates in different currencies co-move?" (Journal of Financial Economics)


Fit yields for all maturities of interest

Description

Fit yields for all maturities of interest

Usage

YieldsFitAll(MatInt, ModelPara, FactorLabels, ModelType, Economies, YLab)

Arguments

MatInt

numerical vector containing the fit maturities of interest

ModelPara

List of model parameter estimates (See the "Optimization" function)

FactorLabels

a string-list based which contains all the labels of all the variables present in the model

ModelType

a string-vector containing the label of the model to be estimated

Economies

a string-vector containing the names of the economies which are part of the economic system

YLab

Label of yields ("Months" or "Yields")


Data: Yields - Candelon and Moura (2023)

Description

Bond yield data used in Candelon and Moura (2023)

Usage

data("Yields_covid")

Format

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.

Source

Simulated data constructed using Bloomberg bond yield series.

References

Candelon, B. and Moura, R. (2023) "Sovereign yield curves and the COVID-19 in emerging markets". (Economic Modelling)


Adjust delta for numerical differentiation

Description

Adjust delta for numerical differentiation

Usage

adjust_delta(f, x, delta, i, fx0, direction)

Arguments

f

function which contains vector (J x T) valued function handle

x

parameter values

delta

initial delta value

i

index of the parameter being adjusted

fx0

initial function value

direction

direction of adjustment (1 for positive, -1 for negative)

Value

adjusted delta value


Autoplot generic function

Description

Autoplot generic function

Usage

autoplot(x, ...)

Arguments

x

Object to plot

...

Additional arguments passed to methods


Autoplot method for ATSMModelBoot objects

Description

Autoplot method for ATSMModelBoot objects

Usage

## S3 method for class 'ATSMModelBoot'
autoplot(x, NumOutPE, type, ...)

Arguments

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

Description

Autoplot method for ATSMNumOutputs objects

Usage

## S3 method for class 'ATSMNumOutputs'
autoplot(x, type, ...)

Arguments

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)


Check for presence of NAs and infinite in numeric variables

Description

Check for presence of NAs and infinite in numeric variables

Usage

check_numeric(x, name)

Arguments

x

variable to be tested (numeric)

name

variable labels


Build the log-likelihood function of the P-dynamics from the JLL-based models

Description

Build the log-likelihood function of the P-dynamics from the JLL-based models

Usage

llk_JLL_Sigma(VecPara, res, IdxNONzero, K)

Arguments

VecPara

vector that contains all the non-zero entries of the lower-triangular part of the Cholesky factorization

res

residuals from the VAR of the JLL model (K x T)

IdxNONzero

vector that contains indexes of the matrix of the non-zero entries of the Cholesky factorization

K

dimensions of the variance-covariance matrix (scalar)

Value

value of the log-likelihood function (scalar)


Computes the PCA weights for a single country

Description

Computes the PCA weights for a single country

Usage

pca_weights_one_country(Yields, Economy)

Arguments

Yields

matrix (J x Td). Bond yields for a single country.

Economy

character. Name of the economy.

Value

matrix (J x J). Eigenvectors of the variance-covariance matrix of yields.

General Notation

Examples

data(Yields)
Economy <- "Mexico"
pca_weights <- pca_weights_one_country(Yields, Economy)


Plot method for ATSMModelForecast objects

Description

Plot method for ATSMModelForecast objects

Usage

## S3 method for class 'ATSMModelForecast'
plot(x, ...)

Arguments

x

An object of class ATSMModelForecast

...

Additional arguments (not used)


Exponential transformation

Description

Exponential transformation

Usage

pos_map(x)

Arguments

x

scalar (numeric)


Print method for ATSMModelInputs objects

Description

Print method for ATSMModelInputs objects

Usage

## S3 method for class 'ATSMModelInputs'
print(x, ...)

Arguments

x

An object of class 'ATSMModelInputs'

...

Additional arguments (not used)


Compute the residuals from the observational equation

Description

Compute the residuals from the observational equation

Usage

residY_original(ModelParaPE, BFull, ModelType, Economies)

Arguments

ModelParaPE

List of point estimates of the model parameter

BFull

Matrix B of loadings (CJ x F or J x F)

ModelType

A character vector indicating the model type to be estimated

Economies

String-vector containing the names of the economies which are part of the economic system


Compute risk-neutral intercept and slope

Description

Compute risk-neutral intercept and slope

Usage

rhoParas(ModelPara, N, ModelType, Economies)

Arguments

ModelPara

list of model parameter estimates

N

number of country-specific spanned factors

ModelType

desired model type

Economies

string-vector containing the names of the economies which are part of the economic system


Richardson extrapolation

Description

Richardson extrapolation

Usage

richardson_diff(f, x, i, h, fx0, nlevels = 5L)

Arguments

f

function to differentiate

x

evaluation point

i

coordinate index

h

base step size

fx0

f(x), precomputed

nlevels

depth of extrapolation. Default is 5


Safe matrix inversion with conditioning check

Description

Safe matrix inversion with conditioning check

Usage

safe_solve(A, B = NULL, reg = 1e-12, rcond_tol = 1e-12, verbose = FALSE)

Arguments

A

matrix

B

matrix

reg

Numeric scalar (default: 1e-12). Small ridge term added to the diagonal of A when the system is ill-conditioned.

rcond_tol

Numeric, default = 1e-12. Tolerance threshold for the reciprocal condition number.

verbose

Logical flag controlling function messaging.


Scaling vector computation

Description

Scaling vector computation

Usage

scaling_from_jacobian(J)

Arguments

J

jacobian approximation term


Shrinking the largest eigenvalue

Description

Shrinking the largest eigenvalue

Usage

shrink_FeedMat_BC(K1Z_BC, K1Z_NoBC, ev_restr)

Arguments

K1Z_BC

VAR (1) bias-corrected feedback matrix from Bauer, Rudebusch and, Wu (2012)

K1Z_NoBC

VAR (1) with no bias-corrected feedback matrix from the selected ATSM

ev_restr

maximum eigenvalue desired in the feedback matrix after the adjustment


Summary method for ATSMModelInputs objects

Description

Summary method for ATSMModelInputs objects

Usage

## S3 method for class 'ATSMModelInputs'
summary(object, ...)

Arguments

object

An object of class 'ATSMModelInputs'

...

Additional arguments (not used)


Summary method for ATSMModelOutputs objects

Description

Summary method for ATSMModelOutputs objects

Usage

## S3 method for class 'ATSMModelOutputs'
summary(object, ...)

Arguments

object

An object of class 'ATSMModelOutputs'

...

Additional arguments (not used)


Check default value

Description

Check default value

Usage

withDefault(value, default)

Arguments

value

parameter to be checked

default

default value