Type: Package
Title: Multicountry Term Structure of Interest Rates Models
Version: 1.3.1
Date: 2025-05-11
Description: Estimation routines for several classes of affine term structure of interest rates models. All the models are based on the single-country unspanned macroeconomic risk framework from Joslin, Priebsch, and Singleton (2014, JF) <doi:10.1111/jofi.12131>. Multicountry extensions such as the ones of Jotikasthira, Le, and Lundblad (2015, JFE) <doi:10.1016/j.jfineco.2014.09.004>, Candelon and Moura (2023, EM) <doi:10.1016/j.econmod.2023.106453>, and Candelon and Moura (2024, JFEC) <doi:10.1093/jjfinec/nbae008> are also available.
License: GPL-2 | GPL-3
Encoding: UTF-8
RoxygenNote: 7.2.3
Imports: ggplot2
Suggests: readxl, cowplot, magic, reshape2, pracma, knitr, rmarkdown, bookdown, kableExtra, neldermead, magrittr, hablar
Depends: R (≥ 4.3.0)
VignetteBuilder: knitr
URL: https://github.com/rubensmoura87/MultiATSM
BugReports: https://github.com/rubensmoura87/MultiATSM/issues
NeedsCompilation: no
Packaged: 2025-05-11 03:23:38 UTC; rmoura
Author: Rubens Moura ORCID iD [aut, cre]
Maintainer: Rubens Moura <rubens.gtmoura@gmail.com>
Repository: CRAN
Date/Publication: 2025-05-11 04:40:02 UTC

ATSM Package

Description

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

Author(s)

Rubens Moura rubens.gtmoura@gmail.com


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

A0N__BnAn(mat, K1XQ, ModelType, dX = NULL, r0 = NULL, SSX = NULL, Economies)

Arguments

mat

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

K1XQ

risk-neutral feedback matrix (N x N)

ModelType

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

dX

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

r0

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

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

Value

List containing:

References


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 bounded parameters (auxiliary form)

Description

Transformation of the bounded parameters (auxiliary form)

Usage

Aux_BoundDiag(ParaValue, Const_Type, lb, ub)

Arguments

ParaValue

Constrained parameter value

Const_Type

Type of constraint

lb

lower bound

ub

upper bound


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


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

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,
  N,
  Economies,
  FactorLabels,
  GVARinputs = NULL,
  JLLinputs = NULL,
  ev_restr = 1,
  nargout = 4
)

Arguments

ModelType

A character vector indicating the model type to be estimated.

BRWinputs

A list containing the necessary inputs for the BRW model estimation:

  1. flag_mean: Logical. Determines whether mean- (TRUE) or median- (FALSE) unbiased estimation is desired. Default is TRUE.

  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 5,000.

  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 OLS 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 100,000.

RiskFactors

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

N

Integer. Number of country-specific spanned factors.

Economies

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

FactorLabels

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

GVARinputs

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

JLLinputs

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

ev_restr

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

nargout

Integer. Number of elements in the output list. Default is 4.

Value

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

  1. Phi_tilde: estimated coefficient matrix (F x F);

  2. mu_tilde: estimated intercept (F x 1);

  3. V_tilde: estimated variance-covariance matrix (F x F);

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

  5. Phi_sample: sample estimated variance-covariance matrix used in the checks (F x F x B_check) - this output is reported if nargout is 5.

References

Bauer, Rudebusch and, Wu (2012). "Correcting Estimation Bias in Dynamic Term Structure Models"
This function is based on the est_unb_var Matlab function available at Cynthia Wu's website (https://sites.google.com/view/jingcynthiawu/).

Examples


data(CM_Factors)
Factors <- t(RiskFactors[1:7,])

BRWinputs <- list(flag_mean = TRUE, gamma = 0.4, N_iter = 1000, N_burn = 100,
                  B = 10, check = 1, B_check = 5000)

Economies <- "China"
N <- 3
ModelType <- "JPS original"
FactorLabels <- NULL

BRWpara <- Bias_Correc_VAR(ModelType, BRWinputs, Factors, N, Economies, FactorLabels)



Generates the 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,
  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" and "FEVD"

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,
  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" or "FEVD"

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 grahs

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 = NULL,
  GVARlist = NULL,
  WishBC = 0,
  BRWlist = NULL
)

Arguments

ModelType

A character vector indicating the model type to be estimated.

ModelParaPE

A list containing the point estimates of the model parameters. For details, refer to the outputs from the Optimization function.

NumOutPE

The point estimate derived from numerical outputs. See the outputs from the NumOutputs function for further information.

Economies

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

InputsForOutputs

A list containing the necessary inputs for generating IRFs, GIRFs, FEVDs, GFEVDs and Term Premia.

FactorLabels

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

JLLlist

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

GVARlist

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

WishBC

Whether to estimate the physical parameter model with bias correction, based on the method by Bauer, Rudebusch and Wu (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).

Value

List containing the following elements:

References

This function is a modified and extended version of the VARirbound function from "A toolbox for VAR analysis" by Ambrogio Cesa-Bianchi (https://github.com/ambropo/VAR-Toolbox)

Examples

# See an example of implementation in the vignette file of this package (Section 4).


Builds the confidence bounds and graphs (Bootstrap set)

Description

Builds the confidence bounds and graphs (Bootstrap set)

Usage

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

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


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
)

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.


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


Obtain the auxiliary values corresponding to each parameter, its size and its name

Description

Obtain the auxiliary values corresponding to each parameter, its size and its name

Usage

Build_xvec(ListInputSet, Economies, FactorLabels, JLLinputs = NULL)

Arguments

ListInputSet

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

Economies

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

FactorLabels

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

JLLinputs

Necessary inputs for the estimation of the JLL-based models

References

This function is a based on the "getx" function by Le and Singleton (2018).
"A Small Package of Matlab Routines for the Estimation of Some Term Structure Models."
(Euro Area Business Cycle Network Training School - Term Structure Modelling).


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 whether mean/median of OLS is close to actual OLS estimates

Description

check whether mean/median of OLS is close to actual OLS estimates

Usage

Check_comparison__OLS(
  theta_tilde,
  theta_OLS,
  B_check,
  RiskFactors,
  N,
  GVARinputs,
  JLLinputs,
  FactorLabels,
  Economies,
  ModelType
)

Arguments

theta_tilde

feedback matrix after the bias correction procedure

theta_OLS

feedback matrix obtained by OLS estimation (without bias correction)

B_check

number of bootstrap samples used in the closeness check

RiskFactors

time series of the risk factors (F x T)

N

number of country-specific spanned factors (scalar)

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


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 a 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


Convert a generic matrix to its Jordan form

Description

Convert a generic matrix to its Jordan form

Usage

Convert2JordanForm(K1XQ)

Arguments

K1XQ

squared matrix in non-Jordan form

Details

this Jordan matrix form handles real, complex and repeated eigenvalues.

Value

squared matrix in Jordam form

References

This function is based on the "Convert2JordanForm" function by Le and Singleton (2018).
"A Small Package of Matlab Routines for the Estimation of Some Term Structure Models."
(Euro Area Business Cycle Network Training School - Term Structure Modelling). Available at: https://cepr.org/40029


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

Description

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

Usage

DataForEstimation(
  t0,
  tF,
  Economies,
  N,
  FactorLabels,
  ModelType,
  DataFrequency,
  W_type = NULL,
  t_First_Wgvar = NULL,
  t_Last_Wgvar = NULL,
  DataPathMacro = NULL,
  DataPathYields = NULL,
  DataPathTrade = NULL
)

Arguments

t0

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

tF

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

Economies

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

N

Integer. Number of country-specific spanned factors.

FactorLabels

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

ModelType

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

DataFrequency

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

W_type

Three possibilities:

  • Full Sample: if one wishes ALL weight matrices of each year from which data is available (it may extrapolate the sample period);

  • Sample Mean: if one wishes a SINGLE weight matrix containing the average of weights over of the entire sample period;

  • Some year in particular (e.g. "1998", "2005" ...).

t_First_Wgvar

Sample starting date (year)

t_Last_Wgvar

Sample last date (year)

DataPathMacro

Path of the Excel file containing the macroeconomic data (if any). The default is linked to the excel file present in the package.

DataPathYields

Path of the Excel file containing the yields data (if any). The default is linked to the excel file present in the package.

DataPathTrade

Path of the Excel file containing the trade data (if any). The default is linked to the excel file present in the package.

Value

A list containing the

  1. time series of the complete set of bond yields (matrix, J x T or CJ x T);

  2. time series of the complete set risk factors (matrix, K x T);

  3. 'GVARFactors': list of all variables that are used in the estimation of the VARX
    (see e.g. CM_Factors_GVAR file). If the estimated model type is not GVAR-based, then returns NULL.

See Also

InputsForOpt

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"

DataModel <- DataForEstimation(t0, tF, Economies, N, FactorLabels, ModelType, DataFrequency)


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,
  Wgvar = NULL,
  DataPathMacro = NULL,
  DataPathYields = NULL
)

Arguments

t_First

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

t_Last

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

Economies

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

N

Integer. Number of country-specific spanned factors.

FactorLabels

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

ModelType

A character vector indicating the model type to be estimated.

Wgvar

GVAR transition matrix of size C x C, applicable if a GVAR-type model is selected. Default is NULL.

DataPathMacro

File path to the Excel file containing macroeconomic data, if provided. The default path points to the Excel file available within the package.

DataPathYields

File path to the Excel file containing yields data, if provided. The default path points to the Excel file available within the package

Value

List containing the risk factor set used in the estimation of the GVAR-based models

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 <- 3
ModelType <- "GVAR multi"
FactorLabels <-  LabFac(N, DomVar, GlobalVar, Economies, ModelType)
Wgvar <- Transition_Matrix(t_First = "2006", t_Last= "2019", Economies, type = "Sample Mean")


GVARFactors <- DatabasePrep(t0, tF, Economies, N, FactorLabels, ModelType, Wgvar)



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

Description

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

Usage

data("CM_DomMacro_2023")

Format

list containing the variables used in the GVAR models

References

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


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

Description

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

Usage

data("CM_DomMacroFactors")

Format

matrix containing the risk factors of the models

References

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


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
)

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


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
)

Arguments

ModelType

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

NumOut

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

WishPdynamicsgraphs

binary variable: set 1, if the user wishes graphs to be generated; or set 0, otherwise

WishYieldsgraphs

binary variable: set 1, if the user wishes graphs to be generated; or set 0, otherwise

FEVDhoriz

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

PathsGraphs

Path of the folder in which the graphs will be saved

OutputType

Available options are 'FEVD' and 'GFEVD'

Economies

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


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


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

FF(x0, FFvectorized)

Arguments

x0

vector of parameters to be estimated numerically

FFvectorized

log-likelihood 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

FFtemporary(xtemp, scaling_vector, FFvectorized)

Arguments

xtemp

temporary vector of parameters to be estimated numerically

scaling_vector

scaling factor

FFvectorized

log-likelihood function


Performs state rotations

Description

Performs state rotations

Usage

FMN__Rotate(y0, U1, U0)

Arguments

y0

list of model parameters as described below

U1

matrix (N x N)

U0

vector (N x 1). Optional. Default: vector of zeros.

Details

This function performs a rotation from a model with Z as states to one with S = U0 + U1*Z as states.
Specifically, each model is characterized by the following inputs organized in a list of variables:
(i) K0: intercepts (N x 1);
(ii) K1: feedback matrix (N x N*p);
(iii) SS: volatility matrices (N x N*(M+1))
More specifically, the state Z follows the dynamics:
Z_t = N(K0 + K1 [Z_{t-1}; Z_{t-2}; ...], SSi[ , , 1] + sum_{i=1}^M SSi[ , ,i+1] where SSi <- array(SS, c(N, N, M+1))

Value

y1 - list of outputs after the transformation, the structure parallels that of y0

References

#' This function is modified version of the "FMN__Rotate" function by Le and Singleton (2018).
"A Small Package of Matlab Routines for the Estimation of Some Term Structure Models."
(Euro Area Business Cycle Network Training School - Term Structure Modelling). Available at: https://cepr.org/40029


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


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

Description

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

Usage

data("CM_Factors_GVAR")

Format

list containing the variables used in the GVAR models

References

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


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)


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
)

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)


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)

Arguments

ModelType

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

WishFitgraphs

binary variable: set 1, if the user wishes graphs to be generated; or set 0, otherwise

ModelPara

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

NumOut

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

Economies

a 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


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)

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


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)

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.


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, 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

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
)

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


Create folders for storing IRFs and GIRFs

Description

Create folders for storing IRFs and GIRFs

Usage

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

Arguments

OutputType

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

WishPdynamicsgraphs

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

WishYieldsgraphs

binary variable specifying 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


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,
  BRWlist = NULL
)

Arguments

ModelType

A character vector indicating the model type to be estimated.

ModelPara

A list containing the point estimates of the model parameters. For details, refer to the outputs from the Optimization function.

InputsForOutputs

A list containing the necessary inputs for generating IRFs, GIRFs, FEVDs, GFEVDs and Term Premia.

FactorLabels

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

Economies

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

JLLlist

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

GVARlist

A list containing the necessary inputs for the estimation of GVAR-based models (see the GVAR function).

WishBRW

Whether to estimate the physical parameter model with bias correction, based on the method by Bauer, Rudebusch and Wu (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).

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

Available Methods

- 'plot(object)'

Examples

# See an example of implementation in the vignette file of this package (Section 4).


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


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

Description

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

Usage

Functionf(
  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

Examples

# See examples in the vignette file of this package (Section 4).


Use function f to generate the outputs from a ATSM

Description

Use function f to generate the outputs from a ATSM

Usage

Functionf_vectorized(
  x,
  sizex,
  f,
  con,
  ListInputSet,
  ModelType,
  FactorLabels,
  Economies,
  JLLinputs,
  GVARinputs,
  WithEstimation
)

Arguments

x

vector containing all the vectorized auxiliary parameters

sizex

matrix (6x2) containing the size information of all parameters

f

vector-valued objective function (function)

con

if con = 'concentration', then set the value of the parameter whose name contains @ to empty

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

References

This function is modified version of the "f_with_vectorized_parameters" function by Le and Singleton (2018).
"A Small Package of Matlab Routines for the Estimation of Some Term Structure Models."
(Euro Area Business Cycle Network Training School - Term Structure Modelling). Available at: https://cepr.org/40029


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

Description

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

Usage

GVAR(GVARinputs, N, CheckInputs = FALSE)

Arguments

GVARinputs

List of inputs for GVAR model estimation:

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

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

  3. VARXtype: A character vector with three possible options:

    • '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.
      (Equations are estimated using 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. (Equations are estimated using 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

Integer. Number of country-specific spanned factors.

CheckInputs

A logical flag to indicate whether to perform a prior consistency check on the inputs provided in GVARinputs. The default is set to FALSE

Value

A list containing

  1. parameters of the country-specific VARX(1,1,1)

    • intercept (M+Nx1);

    • phi_1 (M+N x M+N);

    • phi_1^star (M+N x M+N);

    • phi_g (M+N x M+N);

    • Sigma (M+N x G)

  2. parameters of the GVAR.

    • F0 (F X 1);

    • F1 (F x F);

    • Sigma_y (F x F)

References

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

Examples

data(CM_Factors_GVAR)

GVARinputs <- list( Economies = c("China", "Brazil", "Mexico", "Uruguay"),
                    GVARFactors = FactorsGVAR, VARXtype = "unconstrained")

GVARinputs$Wgvar <- matrix( c(0, 0.83, 0.86, 0.38,
                              0.65, 0, 0.13, 0.55,
                              0.32, 0.12, 0, 0.07,
                              0.03, 0.05, 0.01, 0), nrow = 4, ncol = 4)
N <- 3

GVARPara <- GVAR(GVARinputs, N)


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, SS, invSS, logabsdetSS)

Arguments

res

matrix of residuals (N x T)

SS

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

invSS

Inverse of SS (N x N) or (N x N x T) - optional input

logabsdetSS

log(abs(|SS|)) (1 x T) - optional input

Value

y vector of density (1 x T)

References

This function is based on the "Gaussian" function by Le and Singleton (2018).
"A Small Package of Matlab Routines for the Estimation of Some Term Structure Models."
(Euro Area Business Cycle Network Training School - Term Structure Modelling). Available at: https://cepr.org/40029


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

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


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
)

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


Map constrained parameters b to unconstrained auxiliary parameters a.

Description

Map constrained parameters b to unconstrained auxiliary parameters a.

Usage

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

Arguments

ParaValue

Constrained parameter

Const_Type_Full

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

  • 'Jordan';

  • 'Jordan; stationary'

  • 'Jordan MultiCountry'

  • 'Jordan MultiCountry; stationary'

  • 'stationary'

  • 'psd'

  • 'BlockDiag'

  • 'bounded'

  • 'diag'

  • 'JLLstructure'

lb

lower bounds (a scalar or a matrix) of ParaValue (for the bounded case).

ub

upper bounds (a scalar or a matrix) of ParaValue (for the bounded case).

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)

Value

unconstrained auxiliary matrix.

References

This function is a modified and extended version of the "true2aux" function by Le and Singleton (2018).
"A Small Package of Matlab Routines for the Estimation of Some Term Structure Models."
(Euro Area Business Cycle Network Training School - Term Structure Modelling). Available at: https://cepr.org/40029


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
)

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.


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
)

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)


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,
  lb,
  ub,
  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'

  • 'bounded'

  • 'diag'

  • 'JLLstructure'

lb

lower bounds of b (if option 'bounded' is chosen)

ub

upper bounds of b (if option 'bounded' is chosen)

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

References

This function is a modified and extended of the "aux2true" function by Le and Singleton (2018).
"A Small Package of Matlab Routines for the Estimation of Some Term Structure Models."
(Euro Area Business Cycle Network Training School - Term Structure Modelling). Available at: https://cepr.org/40029


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


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 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 variance-covariance matrix after the bias correction procedure

Description

Compute the variance-covariance matrix after the bias correction procedure

Usage

Get_V_tilde_BC(
  Phi_tilde,
  N,
  RiskFactors,
  GVARinputs,
  JLLinputs,
  FactorLabels,
  ModelType
)

Arguments

Phi_tilde

Feedback matrix resulting from the bias-correction procedure

N

number of country-specific spanned factors (scalar)

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


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 r0 for the various models

Description

Compute 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 (2023)

Description

Risk factors data used in Candelon and Moura (2023)

Usage

data("CM_GlobalMacro_2023")

Format

matrix containing the risk factors of the models

References

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


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

Description

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

Usage

data("CM_GlobalMacroFactors")

Format

matrix containing the risk factors of the models

References

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


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
)

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.


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
)

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


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
)

Arguments

ModelType

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

NumOut

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

WishPdynamicsgraphs

binary variable: set 1, if the user wishes graphs to be generated; or set 0, otherwise

WishYieldsgraphs

binary variable: set 1, if the user wishes graphs to be generated; or set 0, otherwise

IRFhoriz

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

PathsGraphs

Path of the folder in which the graphs will be saved

OutputType

Available options are 'IRF' and 'GIRF'

Economies

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


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)

Arguments

yy

numerical vector before imposing stationary constraint


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(x, K1Q)

Arguments

x

parameter of interest (scalar or matrix)

K1Q

risk-neutral feedback matrix


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
)

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

A character vector indicating the model type to be estimated. Available options: "JPS original", "JPS global", "GVAR single", "JPS multi", "GVAR multi", "JLL original", "JLL No DomUnit", "JLL joint Sigma".

Yields

A numerical matrix with time series of yields (JxT or CJ x T)

GlobalMacro

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

DomMacro

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

FactorLabels

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

Economies

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

DataFrequency

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

GVARlist

A list containing the necessary inputs for the estimation of GVAR-based models

JLLlist

A list of necessary inputs for the estimation of JLL-based models. If the chosen model is "JLL original" or "JLL joint Sigma", then a dominant unit economy must be chosen. Otherwise, this list must be set as 'None'.

WishBRW

Logical. Whether to estimate the physical parameter model with bias correction, based on the method by Bauer, Rudebusch and Wu (2012). Default is FALSE.

BRWlist

List of necessary inputs for performing the bias-corrected estimation.

UnitYields

A character string indicating the maturity unit of yields. Options are: "Month" for yields expressed in months, or "Year" for yields expressed in years. 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.

Value

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

Available Methods

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

Examples


# Example 1:
data(CM_GlobalMacroFactors)
data(CM_DomMacroFactors)
data(CM_Yields)

ModelType <- "JPS original"
Economies <- "Mexico"
t0 <- "01-05-2007" # Initial Sample Date (Format: "dd-mm-yyyy")
tF <- "01-12-2018" # Final Sample Date (Format: "dd-mm-yyyy")
N <- 3
GlobalVar <- c("Gl_Eco_Act") # Global Variables
DomVar <- c("Eco_Act") # Domestic Variables
FactorLabels <- LabFac(N, DomVar, GlobalVar, Economies, ModelType)

DataFreq <- "Monthly"

ATSMInputs <- InputsForOpt(t0, tF, ModelType, Yields, GlobalMacroVar, DomesticMacroVar,
                             FactorLabels, Economies, DataFreq, CheckInputs = FALSE)

# Example 2:
LoadData("CM_2024")

ModelType <- "GVAR multi"

Economies <- c("China", "Brazil", "Mexico", "Uruguay")
t0 <- "01-05-2007" # InitialSampleDate (Format: "dd-mm-yyyy")
tF <- "01-12-2019" # FinalSampleDate (Format: "dd-mm-yyyy")
N <- 2
GlobalVar <- c("Gl_Eco_Act", "Gl_Inflation") # Global Variables
DomVar <- c("Inflation") # Domestic Variables
FactorLabels <- LabFac(N, DomVar, GlobalVar, Economies, ModelType)

DataFreq <- "Monthly"
GVARlist <- list(VARXtype = "unconstrained", W_type = "Sample Mean",
                 t_First_Wgvar = "2007", t_Last_Wgvar = "2019")

ATSMInputs <- InputsForOpt(t0, tF, ModelType, Yields, GlobalMacroVar, DomesticMacroVar,
                           FactorLabels, Economies, DataFreq, GVARlist, CheckInputs = FALSE)

# Example 3:
if (requireNamespace('neldermead', quietly = TRUE)) {
LoadData("CM_2024")

ModelType <- "JLL original"

Economies <- c("China", "Brazil", "Uruguay")
t0 <- "01-05-2007" # InitialSampleDate (Format: "dd-mm-yyyy")
tF <- "01-12-2019" # FinalSampleDate (Format: "dd-mm-yyyy")
N <- 2
GlobalVar <- c("Gl_Eco_Act", "Gl_Inflation") # Global Variables
DomVar <- c("Eco_Act", "Inflation") # Domestic Variables
FactorLabels <- LabFac(N, DomVar, GlobalVar, Economies, ModelType)

JLLinputs <- list(DomUnit = "China")

DataFrequency <- "Monthly"

ATSMInputs <- InputsForOpt(t0, tF, ModelType, Yields, GlobalMacroVar, DomesticMacroVar,
                           FactorLabels, Economies, DataFreq, JLLlist = JLLinputs,
                           CheckInputs = FALSE)
} else {
 message("skipping functionality due to missing Suggested dependency")
}


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

Description

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

Usage

InputsForOutputs(
  ModelType,
  Horiz,
  ListOutputWished,
  OutputLabel,
  WishStationarityQ,
  DataFrequency,
  WishGraphYields = 0,
  WishGraphRiskFactors = 0,
  WishOrthoJLLgraphs = 0,
  WishForwardPremia = 0,
  LimFP = NULL,
  WishBootstrap = 0,
  ListBoot = NULL,
  WishForecast = 0,
  ListForecast = NULL,
  UnitYields = "Month"
)

Arguments

ModelType

A character vector indicating the model type to be estimated.

Horiz

A numeric scalar specifying the desired analysis horizon for the outputs.

ListOutputWished

A list of desired graphical outputs. Available options are: "Fit", "IRF", "FEVD", "GIRF", "GFEVD", "TermPremia".

OutputLabel

A string for the name of the output label to be stored.

WishStationarityQ

A binary variable (1 or 0) indicating whether to impose that the largest eigenvalue under Q is strictly smaller than 1. Set to 1 to impose the restriction, or 0 otherwise.

DataFrequency

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

WishGraphYields

A binary variable (1 or 0) indicating whether the user wishes to generate graphs for yields. Default is 0.

WishGraphRiskFactors

A binary variable (1 or 0) indicating whether the user wishes to generate graphs for risk factors. Default is 0.

WishOrthoJLLgraphs

A binary variable (1 or 0) indicating whether the user wishes to generate orthogonalized JLL-based graphs. Default is 0.

WishForwardPremia

A binary variable (1 or 0) indicating whether the user wishes to generate forward premia graphs. Default is 0.

LimFP

A numeric vector containing the maturities associated with the start and end dates of the loan.

WishBootstrap

A binary variable (1 or 0) indicating whether the user wishes to perform bootstrap-based estimation. Default is 0.

ListBoot

A List containing the following four elements:

  1. methodBS: Desired bootstrap method: (a) 'bs' for standard residual bootstrap, (b) 'wild' for wild bootstrap, or (c) 'block' for block bootstrap.

  2. BlockLength: If block bootstrap is chosen, specify the block length (numeric scalar).

  3. ndraws: Number of bootstrap draws.

  4. pctg: Confidence level expressed in basis points (numeric vector).

WishForecast

A binary variable (1 or 0) indicating whether the user wishes to generate forecasts. Default is 0.

ListForecast

A list containing the following three elements:

  1. ForHoriz: forecast horizon;

  2. t0Sample: Index of the first variable in the information set.

  3. t0Forecast: Index of the first forecast cut-off date.

  4. ForType: A string specifying the desired forecast type. Available options are: "Rolling" or "Expanding".

UnitYields

A character string indicating the maturity unit of yields. Options are: (i) "Month" for yields expressed in months, or (ii) "Year" for yields expressed in years. Default is "Month".

Value

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

Examples


ModelType <- "JPS original"
Horiz <- 100
DesiredOutputGraphs <- c("Fit", "GIRF", "GFEVD")
OutputLabel <- "Test"
WishStationarityQ <- 1
WishGraphRiskFac <- 0
WishGraphYields <- 1

InputsList <- InputsForOutputs(ModelType, Horiz, DesiredOutputGraphs, OutputLabel,
                              WishStationarityQ, WishGraphYields, WishGraphRiskFac)

Estimates the P-dynamics from JLL-based models

Description

Estimates the P-dynamics from JLL-based models

Usage

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

Arguments

NonOrthoFactors

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

N

Integer. Number of country-specific spanned factors.

JLLinputs

List of necessary inputs to estimate JLL models:

  1. Economies: set of economies that are part of the economic system (string-vector)

  2. DomUnit: A string specifying the name of the economy assigned as the dominant unit.
    If no dominant unit is assigned, set this variable to "None".

  3. WishSigmas: Set to "1" if the user wishes to estimate the variance-covariance matrices and Cholesky factorizations
    (this can take a long time). Set to "0" if not.

  4. SigmaNonOrtho: A NULL value or an F x F matrix from the non-orthogonalized dynamics.

  5. JLLModelType: A string specifying the type of JLL model. Available options are: "JLL original", "JLL joint Sigma", or "JLL No DomUnit".

CheckInputs

A logical flag to indicate whether to perform a prior consistency check on the inputs provided in JLLinputs. The default is set to FALSE

Value

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

References

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

Examples


data(CM_Factors)
RF_TS <- RiskFactors
N <- 3

JLLinputs <- list(Economies = c("China", "Brazil", "Mexico", "Uruguay"), DomUnit = "China",
                  WishSigmas = 1, SigmaNonOrtho = NULL, JLLModelType = "JLL original")

JLLPara <- JLL(RF_TS, N, JLLinputs)


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 factors

Description

Generates the labels factors

Usage

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

Arguments

N

Integer. Number of country-specific spanned factors.

DomVar

A character vector containing the names of the domestic variables.

GlobalVar

A character vector containing the names of the global variables.

Economies

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

ModelType

A character vector indicating the model type to be estimated.

Value

List containing the risk factor labels

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



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,
  nargout
)

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.

nargout

if nargout == 1: provides only the values of the likelihood; if nargout == 2: complete ATSM outputs

References

This function is modified version of the "A0N_MLEdensity_WOE" function by Le and Singleton (2018).
"A Small Package of Matlab Routines for the Estimation of Some Term Structure Models."
(Euro Area Business Cycle Network Training School - Term Structure Modelling). Available at: https://cepr.org/40029


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


Replications of the JPS (2014) outputs by the MultiATSM package

Description

Unspanned macro risk model outputs by the MultiATSM package

Usage

data("JPSrep")

Format

list of inputs and outputs

inputs

general model inputs

ests

model parameters estimates (JPS form)

llk

log-likelihood of the observations

rot

model parameters estimates (rotation form)


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


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

Description

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

Usage

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

Arguments

ModelType

A character vector indicating the model type to be estimated.

ModelPara

A list containing the point estimates of the model parameters. For details, refer to the outputs from the Optimization function.

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.

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

List of the model numerical outputs, namely

  1. Model fit of bond yields

  2. IRFs

  3. FEVDs

  4. GIRFs

  5. GFEVDs

  6. Bond yield decomposition

References

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

Examples

# See an example of implementation in the vignette file of this package (Section 4).


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,
  TimeCount = TRUE,
  BS_outputs = FALSE
)

Arguments

MLEinputs

A list containing the necessary inputs for building the log-likelihood function (see InputsForOpt function).

StatQ

A binary variable (1 or 0) indicating whether to impose that the largest eigenvalue under Q is strictly smaller than 1. Set to 1 to impose the restriction, or 0 otherwise.

DataFreq

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

FactorLabels

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

Economies

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

ModelType

A character vector indicating the model type to be estimated.

tol

Convergence tolerance (scalar). The default is 1e-4.

TimeCount

Logical. If TRUE, computes the time required for model estimation. Default is TRUE.

BS_outputs

Logical. If TRUE, generates a simplified output list in the bootstrap setting. Default is FALSE.

Value

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

Available Methods

- 'summary(object)'

References

This function is partially adapted from the LS__opt function by Le and Singleton (2018).
"A Small Package of Matlab Routines for the Estimation of Some Term Structure Models."
(Euro Area Business Cycle Network Training School - Term Structure Modelling). Available at: https://cepr.org/40029

Examples

# See examples in the vignette file of this package (Section 4).


Optimization routine for the entire selected ATSM

Description

Optimization routine for the entire selected ATSM

Usage

OptimizationSetup_ATSM(AuxVecSet, FFvec, EstType, tol = 1e-04)

Arguments

AuxVecSet

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

FFvec

Log-likelihood function

EstType

Estimation type

tol

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


Peform the minimization of mean(f)

Description

Peform the minimization of mean(f)

Usage

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

Arguments

f

vector-valued objective function (function)

ListInputSet

list contain starting values and constraints: for each input argument K (of f), we need four inputs that look like:

  1. a starting value: K0

  2. a variable label ('K0') followed by a ':' followed by a type of constraint. The constraint can be:

    • 'bounded': bounded matrix;

    • 'Jordan' or 'Jordan MultiCountry': a matrix of Jordan type;

    • 'psd': psd matrix;

    • 'stationary': largest eigenvalue of the risk-neutral feedback matrix is strictly smaller than 1;

    • 'diag' or 'BlockDiag': a diagonal or block diagonal matrix.

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

  3. a lower bound lb (lb <- NULL -> no lower bound)

  4. an upper bound ub (ub <- NULL -> no upper bound)

  5. Specification of the optimization settings:

    • 'iter off': hide the printouts of the numerical optimization routines;

    • 'fminunc only': only uses fminunc for the optimization;

    • ”fminsearch only': only uses fminsearch for the optimization.

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.

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.

TimeCount

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

References

This function is a conceptually based on the "LS__opt" function by Le and Singleton (2018).
"A Small Package of Matlab Routines for the Estimation of Some Term Structure Models."
(Euro Area Business Cycle Network Training School - Term Structure Modelling). Available at: https://cepr.org/40029

Examples

#' # See an example of implementation in the vignette file of this package (Section 4).




Compute the time elapsed in the numerical optimization

Description

Compute the time elapsed in the numerical optimization

Usage

Optimization_Time(start_time)

Arguments

start_time

Starting time


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


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
)

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


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


Update the list of parameters

Description

Update the list of parameters

Usage

ParaATSM_opt_ALL(Update_Temp, FF_opt, AuxVecSet_opt, ParaLabels)

Arguments

Update_Temp

List of model parameter features updated

FF_opt

llk after optimization

AuxVecSet_opt

List containing features for estimation of several parameters after optimization

ParaLabels

Several variable labels


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 "1" is she wishes to impose the largest eigenvalue under the Q to be strictly smaller than 1. Otherwise set "0"

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.

Value

list containing starting values and constraints: for each input argument K (of f), we need four inputs that look like:

  1. a starting value: K0

  2. a variable label ('K0') followed by a ':' followed by a type of constraint. The constraint can be:

    • 'bounded': bounded matrix;

    • 'Jordan' or 'Jordan MultiCountry': a matrix of Jordan type;

    • 'psd': psd matrix;

    • 'stationary': largest eigenvalue of the risk-neutral feedback matrix is strictly smaller than 1;

    • 'diag' or 'BlockDiag': a diagonal or block diagonal matrix.

    • 'JLLstructure': to impose the zero-restrictions on the variance-voriance matrix along the lines of the JLL models

  3. a lower bound lb (lb <- NULL -> no lower bound)

  4. an upper bound ub (ub <- NULL -> no upper bound)

  5. Specification of the optimization settings:

    • 'iter off': hide the printouts of the numerical optimization routines;

    • 'fminunc only': only uses fminunc for the optimization;

    • ”fminsearch only': only uses fminsearch for the optimization.


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


Estimate the risk-neutral feedbak matrix K1Q using linear regressions

Description

Estimate the risk-neutral feedbak matrix K1Q using linear regressions

Usage

Reg_K1Q(Y, mat, Z, dt, type)

Arguments

Y

matrix of yields used in estimation (J x T)

mat

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

Z

pricing factors (can be yields-based or non-yields/macro variables) (N x T)

dt

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

type

'Jordan' -> K1Q will be of the Jordan type

Value

Risk neutral feedback matrix K1Q.

References

This function is modified version of the "Reg_K1Q" function by Le and Singleton (2018).
"A Small Package of Matlab Routines for the Estimation of Some Term Structure Models."
(Euro Area Business Cycle Network Training School - Term Structure Modelling). Available at: https://cepr.org/40029


Restricted OLS regression

Description

Restricted OLS regression

Usage

Reg__OLSconstrained(Y, X, Bcon, G = NULL)

Arguments

Y

left hand side variables (M x T)

X

regressors (i.e. N-1 variables + the intercept) (N x T)

Bcon

constraints matrix (M x N). If Bcon(i,j) = nan –> B(i,j) is a free parameter

G

weighting matrix (psd) - (M x M). Default is set to be identity

Details

Estimate of B is obtained by minimizing the objective: sum_t (Y_t-B X_t)' G^(-1) (Y_t-B*X_t) subject to the constraint that B = Bcon for all non-nan entries of Bcon

Value

matrix of coefficient (M x N)

References

This function is based on the "Reg__OLSconstrained" function by Le and Singleton (2018). "A Small Package of Matlab Routines for the Estimation of Some Term Structure Models." (Euro Area Business Cycle Network Training School - Term Structure Modelling). Available at: https://cepr.org/40029


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

Description

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

Usage

data("CM_Factors")

Format

matrix containing the risk factors of the models

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, ModelOutputs, Economies, FactorLabels)

Arguments

ModelType

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

ModelOutputs

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

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


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


Computes the country-specific spanned factors

Description

Computes the country-specific spanned factors

Usage

Spanned_Factors(Yields, Economies, N)

Arguments

Yields

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

Economies

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

N

Scalar representing the desired number of country-specific spanned factors (maximum allowed is N = J).

Value

Matrix containing the N spanned factors for all the countries of the system (CJ x T)

Examples

data(CM_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,
  DataPathTrade = 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

DataPathTrade

path of the Excel file containing the data (if any)


Generates the star variables necessary for the GVAR estimation

Description

Generates the star variables necessary for the GVAR estimation

Usage

StarFactors(RiskFactors, Economies, W)

Arguments

RiskFactors

time series of the risk factors (F x T)

Economies

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

W

GVAR transition matrix (C x C)

Value

List containg the star factors of each country of the economic system

Examples

data(CM_Factors)
Economies <- c("China", "Brazil", "Mexico", "Uruguay")
Wgvar <- matrix( c(0, 0.83, 0.86, 0.38, 0.65, 0, 0.13, 0.55,
         0.32, 0.12, 0, 0.07, 0.03, 0.05, 0.01, 0), nrow = 4, ncol = 4,
         dimnames = list(Economies, Economies))
SF <- StarFactors(RiskFactors, Economies, Wgvar)


Term Premia decomposition graphs for all models

Description

Term Premia decomposition graphs for all models

Usage

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

Arguments

ModelType

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

NumOut

list of computed outputs containing the model fit, IRFs, FEVDs, GIRFs, GFEVDs and Risk premia

ModelPara

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

WishRPgraphs

binary variable: set 1, if the user wishes graphs to be generated; or set 0, otherwise

UnitYields

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

Economies

a 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


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

Format

list containing the bilateral trade flows

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)

Description

Trade Flows data used in Candelon and Moura (2023)

Usage

data("CM_Trade")

Format

list containing the bilateral trade flows

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 = NULL,
  DataPath = NULL
)

Arguments

t_First

Sample starting date (in the format: yyyy).

t_Last

Sample ending date (in the format: yyyy).

Economies

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

type

A character string indicating the method for computing interdependence. Possible options include:

  • Time-varying: Computes time-varying interdependence and returns the weight matrices for each year based on available data (may extrapolate the sample period).

  • Sample Mean: Returns a single weight matrix containing the average weights over the entire sample period, suitable for time-invariant interdependence.

  • A specific year (e.g., "1998", "2005"): Used to compute time-invariant interdependence for the specified year.

DataConnectedness

Data used to compute the transition matrix. Default is set to NULL.

DataPath

Path to the Excel file containing the data (if applicable). The default is linked to the Excel file available in the package.

Details

If there is missing data for any country of the system for that particularly year, then the transition matrix will include only NAs.

Value

matrix or list of matrices

Examples

data(CM_Trade)

t_First <- "2006"
t_Last <-  "2019"
Economies <- c("China", "Brazil", "Mexico", "Uruguay")
type <- "Sample Mean"
W_mat <- Transition_Matrix(t_First, t_Last, Economies, type, DataConnectedness = TradeFlows)


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 bounded parameters (True form)

Description

Transformation of the bounded parameters (True form)

Usage

True_BoundDiag(ParaValue, Const_Type, lb, ub)

Arguments

ParaValue

Constrained parameter value

Const_Type

Type of constraint

lb

lower bound

ub

upper bound


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


converts the vectorized auxiliary parameter vector x to the parameters that go directly into the likelihood function.

Description

converts the vectorized auxiliary parameter vector x to the parameters that go directly into the likelihood function.

Usage

Update_ParaList(
  x,
  sizex,
  con,
  FactorLabels,
  Economies,
  JLLinputs = NULL,
  GVARinputs = NULL,
  ListInputSet
)

Arguments

x

vector containing all the vectorized auxiliary parameters

sizex

matrix (6x2) containing the size information of all parameters

con

if con = 'concentration', then set the value of the parameter whose name contains @ to empty

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)

Value

same form as the list of parameters, except now the parameters are updated with the values provided by the auxiliary x. Importantly, by construction, all the constraints on the underlying parameters are satisfied.

References

This function is a modified version of the "update_para" function by Le and Singleton (2018).
"A Small Package of Matlab Routines for the Estimation of Some Term Structure Models."
(Euro Area Business Cycle Network Training School - Term Structure Modelling). Available at: https://cepr.org/40029


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 = NULL)

Arguments

RiskFactors

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

VARtype

String vector with two possible values: 'unconstrained' or 'constrained'.

Bcon

Constraints matrix (F+1 x N), which includes an intercept. If Bcon(i,j) = NA, then B(i,j) is treated as a free parameter.
Default is set to NULL.

Value

intercept, feedback matrix and the variance-covariance matrix of a VAR(1)

Examples

data("CM_Factors")
# Example 1: unconstrained case
VAR(RiskFactors, VARtype= 'unconstrained')

# Example 2: constrained case
K <- nrow(RiskFactors)
Bcon <- matrix(0, nrow = K, ncol = K+1)
Bcon[ , 1:3] <- NaN
VAR(RiskFactors, VARtype= 'constrained', Bcon)


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: Yields - Candelon and Moura (2024, JFEC)

Description

Yields data used in Candelon and Moura (2024, JFEC)

Bond yield data used in Candelon and Moura (2023)

Usage

data("CM_Yields")

data("CM_Yields_2023")

Format

matrix containing the Yields of the models

matrix containing the Yields of the models

References

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

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


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


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


Transform a number bounded between a lower bound and upper bound to x by:

Description

Transform a number bounded between a lower bound and upper bound to x by:

Usage

bound2x(y, lb, ub)

Arguments

y

Number to be transformed (scalar)

lb

lower bound (scalar)

ub

upper bound (scalar)

References

This function is based on the "bound2x" function by Le and Singleton (2018).
"A Small Package of Matlab Routines for the Estimation of Some Term Structure Models."
(Euro Area Business Cycle Network Training School - Term Structure Modelling). Available at: https://cepr.org/40029


Computes numerical first order derivative of f(x)

Description

Computes numerical first order derivative of f(x)

Usage

df__dx(f, x)

Arguments

f

function which contains vector (J x T) valued function handle

x

parameter values

Value

transformed matrix (MN x JT)

References

This function is based on the "df__dx" function by Le and Singleton (2018).
"A Small Package of Matlab Routines for the Estimation of Some Term Structure Models."
(Euro Area Business Cycle Network Training School - Term Structure Modelling). Available at: https://cepr.org/40029


Estimate a VAR(1) - suited to Bauer, Rudebusch and Wu (2012) methodology

Description

Estimate a VAR(1) - suited to Bauer, Rudebusch and Wu (2012) methodology

Usage

estVARbrw(
  RiskFactors,
  ModelType,
  N,
  GVARinputs,
  JLLinputs,
  FactorLabels,
  Economies,
  demean = FALSE,
  intercept = TRUE
)

Arguments

RiskFactors

time series of the risk factors (T x F)

ModelType

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

N

number of country-specific spanned factors (scalar)

GVARinputs

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

JLLinputs

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

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

demean

demean the data before estimation. Default is set to FALSE

intercept

Include intercept in the VAR model. Default is set to TRUE

Value

list containing VAR(1) parameters #'

  1. Gamma_hat: feedback matrix (F X F)

  2. alpha_hat: intercept (F x 1)

#'@references Bauer, Rudebusch and, Wu (2012). "Correcting Estimation Bias in Dynamic Term Structure Models".
This function is similar to the "estVAR" Matlab function available at Cynthia Wu's website (https://sites.google.com/view/jingcynthiawu/).


Generate M data sets from VAR(1) model

Description

Generate M data sets from VAR(1) model

Usage

genVARbrw(Phi, M, RiskFactors)

Arguments

Phi

feedback matrix (F x F)

M

number of Monte Carlo replications

RiskFactors

time series of the risk factors (T x F)

References

Bauer, Rudebusch and, Wu (2012). "Correcting Estimation Bias in Dynamic Term Structure Models".
This function is based on to the"genVAR" Matlab function available at Cynthia Wu's website (https://sites.google.com/view/jingcynthiawu/).


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)


Find mean or median of OLS when DGP is VAR(1)

Description

Find mean or median of OLS when DGP is VAR(1)

Usage

m_var(
  theta,
  M,
  RiskFactors,
  N,
  GVARinputs,
  JLLinputs,
  FactorLabels,
  Economies,
  ModelType,
  flag_mean = TRUE
)

Arguments

theta

parameters from the feedback matrix in vector form

M

number of Monte Carlo replications

RiskFactors

time series of the risk factors (T x F)

N

number of country-specific spanned factors (scalar)

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

flag_mean

flag whether mean- (TRUE) or median- (FALSE) unbiased estimation is desired. Default is set to TRUE

References

Bauer, Rudebusch and, Wu (2012). "Correcting Estimation Bias in Dynamic Term Structure Models".
This function is similar to the "m_var" Matlab function available at Cynthia Wu's website (https://sites.google.com/view/jingcynthiawu/).


Efficient computation of matrix product for arrays

Description

Efficient computation of matrix product for arrays

Usage

mult__prod(a, b)

Arguments

a

array

b

array

References

This function is a simplified version of the "mult__prod" function by Le and Singleton (2018).
"A Small Package of Matlab Routines for the Estimation of Some Term Structure Models."
(Euro Area Business Cycle Network Training School - Term Structure Modelling). Available at: https://cepr.org/40029


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

A matrix of bond yields (J x T) for a single country, where J is the number of maturities and T is the time series length.

Economy

A character string indicating the name of the economy.

Value

A matrix (J x J) that corresponds to the eigenvectors of the variance-covariance matrix of yields

Examples

data(CM_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)


Transform a positive number y to back to x by:

Description

Transform a positive number y to back to x by:

Usage

pos2x(y)

Arguments

y

scalar

References

This function is based on the "pos2x" function by Le and Singleton (2018).
"A Small Package of Matlab Routines for the Estimation of Some Term Structure Models."
(Euro Area Business Cycle Network Training School - Term Structure Modelling). Available at: https://cepr.org/40029


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


Killan's VAR stationarity adjustment

Description

Killan's VAR stationarity adjustment

Usage

shrink_Phi(Phi_tilde, Phi_hat, ev_restr)

Arguments

Phi_tilde

VAR (1) bias-corrected feedback matrix from Bauer, Rudebusch and, Wu (2012)

Phi_hat

unrestricted VAR(1) feedback matrix

ev_restr

maximum eigenvalue desired in the feedback matrix after the adjustement

Value

stationary VAR(1)

References

Bauer, Rudebusch and, Wu (2012). "Correcting Estimation Bias in Dynamic Term Structure Models".
This function is an adapted version of the"shrink_Phi" Matlab function available at Cynthia Wu's website (https://sites.google.com/view/jingcynthiawu/).


Compute the square root of a matrix

Description

Compute the square root of a matrix

Usage

sqrtm_robust(m)

Arguments

m

squared matrix (KxK)

Value

squared matrix x (KxK) such that x

References

#' This function is a modified version of the "sqrtm_robust" function by Le and Singleton (2018).
"A Small Package of Matlab Routines for the Estimation of Some Term Structure Models."
(Euro Area Business Cycle Network Training School - Term Structure Modelling). Available at: https://cepr.org/40029


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)


Transform x to a number bounded btw lb and ub by:

Description

Transform x to a number bounded btw lb and ub by:

Usage

x2bound(x, lb, ub, nargout)

Arguments

x

number to be transformed (scalar)

lb

lower bound (scalar)

ub

upper bound (scalar)

nargout

"1" or "2" (scalar)

References

This function is based on the "x2bound" function by Le and Singleton (2018).
"A Small Package of Matlab Routines for the Estimation of Some Term Structure Models."
(Euro Area Business Cycle Network Training School - Term Structure Modelling). Available at: https://cepr.org/40029


Transform x to a positive number by: y = log(e^x + 1)

Description

Transform x to a positive number by: y = log(e^x + 1)

Usage

x2pos(x, nargout)

Arguments

x

scalar or vector

nargout

1 or 2

References

This function is based on the "x2pos" function by Le and Singleton (2018).
"A Small Package of Matlab Routines for the Estimation of Some Term Structure Models."
(Euro Area Business Cycle Network Training School - Term Structure Modelling) Available at: https://cepr.org/40029