Package 'MultiATSM'

Title: Multicountry Term Structure of Interest Rates Models
Description: Package for estimating, analyzing, and forecasting multi-country macro-finance affine term structure models (ATSMs). All setups build on the single-country unspanned macroeconomic risk framework from Joslin, Priebsch, and Singleton (2014, JF) <doi:10.1111/jofi.12131>. Multicountry extensions by Jotikasthira, Le, and Lundblad (2015, JFE) <doi:10.1016/j.jfineco.2014.09.004>, Candelon and Moura (2023, EM) <doi:10.1016/j.econmod.2023.106453>, and Candelon and Moura (2024, JFEC) <doi:10.1093/jjfinec/nbae008> are also available. The package also provides tools for bias correction as in Bauer Rudebusch and Wu (2012, JBES) <doi:10.1080/07350015.2012.693855>, bootstrap analysis, and several graphical/numerical outputs.
Authors: Rubens Moura [aut, cre]
Maintainer: Rubens Moura <[email protected]>
License: GPL-2 | GPL-3
Version: 1.5.1-1
Built: 2026-05-28 06:51:29 UTC
Source: https://github.com/rubensmoura87/multiatsm

Help Index


Autoplot generic function

Description

Autoplot generic function

Usage

autoplot(x, ...)

Arguments

x

Object to plot

...

Additional arguments passed to methods


Autoplot method for ATSMModelBoot objects

Description

Autoplot method for ATSMModelBoot objects

Usage

## S3 method for class 'ATSMModelBoot'
autoplot(x, NumOutPE, type, ...)

Arguments

x

An object of class 'ATSMModelBoot'

NumOutPE

An object of class 'ATSMNumOutputs': point estimates of the numerical outputs

type

Plot type: one of "IRF", "FEVD", "GIRF", "GFEVD" (each must be suffixed with "_Factors" or "_Yields"). For JLL-based models, an additional "_Ortho" suffix produces orthogonalized outputs. All inputs must end by "_Boot" as a reference to the bootstrap procedure.

...

Additional arguments (not used)


Autoplot method for ATSMNumOutputs objects

Description

Autoplot method for ATSMNumOutputs objects

Usage

## S3 method for class 'ATSMNumOutputs'
autoplot(x, type, ...)

Arguments

x

An object of class 'ATSMNumOutputs'

type

Plot type: "RiskFactors", "Fit", "TermPremia", or one of "IRF", "FEVD", "GIRF", "GFEVD" (each must be suffixed with "_Factors" or "_Yields"). For JLL-based models, an additional "_Ortho" suffix produces orthogonalized outputs.

...

Additional arguments (not used)


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

Description

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

Usage

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

Arguments

ModelType

character. Model type to be estimated. Permissible choices: "JPS original", "JPS global", "GVAR single", "JPS multi", "GVAR multi", "JLL original", "JLL No DomUnit", "JLL joint Sigma".

BRWinputs

list. Contains the necessary inputs for the BRW model estimation:

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

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

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

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

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

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

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

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

RiskFactors

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

Economies

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

FactorLabels

list. Labels for all variables in the model.

GVARinputs

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

JLLinputs

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

verbose

logical. Flag controlling function messaging. Default TRUE.

Value

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

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

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

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

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

General Notation

  • Td denotes the model time series dimension.

  • C number of countries in the system.

  • K denotes the total number of risk factors.

References

Bauer, Rudebusch and, Wu (2012). "Correcting Estimation Bias in Dynamic Term Structure Models"
This function offers an independent R implementation that is informed by the conceptual framework outlined in Bauer, Rudebusch and Wu (2012), but adapted to the present modeling context. Related Matlab routines are available on Cynthia Wu's website (https://sites.google.com/view/jingcynthiawu/).

Examples

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

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

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

BRWpara <- Bias_Correc_VAR(ModelType, BRWinputs, Factors, Economies, FactorLabels, verbose = FALSE)

Generates the bootstrap-related outputs

Description

Generates the bootstrap-related outputs

Usage

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

Arguments

ModelType

character. Model type to be estimated. Permissible choices: "JPS original", "JPS global", "GVAR single", "JPS multi", "GVAR multi", "JLL original", "JLL No DomUnit", "JLL joint Sigma".

ModelParaPE

list. Point estimates of the model parameters. See outputs from Optimization.

NumOutPE

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

Economies

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

InputsForOutputs

list. Inputs for generating IRFs, GIRFs, FEVDs, GFEVDs, and Term Premia.

FactorLabels

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

JLLlist

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

GVARlist

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

WishBC

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

BRWlist

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

Folder2save

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

verbose

logical. Print progress messages. Default is TRUE.

Value

An object of class 'ATSMModelBoot' containing:

  • List of model parameters for each draw

  • List of numerical outputs (IRFs, GIRFs, FEVDs, GFEVDs) for each draw

  • Confidence bounds for the chosen level of significance

Permissible options - Bootstrap list in InputsForOutputs

  • methodBS : "bs" (standard bootstrap), "wild" (wild bootstrap), "block" (block bootstrap)

  • BlockLength : required input for the block bootstrap method. Block length must be larger than 0 and smallar than the model time series dimension (Td).

  • ndraws: number of draws. Must be a positive integer.

  • pctg : confidence level. Must be a positive integer. Common choices are: 68, 90 and 95.

Available methods

- autoplot(object, NumOutPE, type)

Examples

data("ParaSetEx")
data("InpForOutEx")
data("NumOutEx")
ModelType <- "JPS original"
Economy <- "Brazil"
FacLab <- LabFac(N = 1, DomVar = "Eco_Act", GlobalVar = "Gl_Eco_Act", Economy, ModelType)

# Adjust Forecasting setting
InpForOutEx[[ModelType]]$Bootstrap <- list(
  WishBootstrap = 1, methodBS = "bs", BlockLength = 4,
  ndraws = 5, pctg = 95
)

Boot <- Bootstrap(ModelType, ParaSetEx, NumOutEx, Economy, InpForOutEx, FacLab,
  JLLlist = NULL,
  GVARlist = NULL, WishBC = FALSE, BRWlist = NULL, Folder2save = NULL, verbose = FALSE
)

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

Description

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

Usage

data("BR_jps_out")

Format

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

est.llk

summary list of log-likelihood estimations

M.o

time series of unspanned factors

pars

additional summary list of log-likelihood estimations

W

Weight matrix that results from principal components analysis

Y

time series of bond yields

N

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

R

total number of spanned factor of the model

References

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


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

Description

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

Usage

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

Arguments

t_First

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

t_Last

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

Economies

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

N

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

FactorLabels

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

ModelType

character. Model type to be estimated. Permissible choices: "JPS original", "JPS global", "GVAR single", "JPS multi", "GVAR multi", "JLL original", "JLL No DomUnit", "JLL joint Sigma".

Macro_FullData

list. Full set of macroeconomic data, as returned by Load_Excel_Data.

Yields_FullData

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

Wgvar

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

Value

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

General Notation

  • C: number of countries in the system.

  • N: number of country-specific spanned factors.

Examples

# Load data from excel
macro_data <- Load_Excel_Data(system.file("extdata", "MacroData.xlsx", package = "MultiATSM"))
yields_data <- Load_Excel_Data(system.file("extdata", "YieldsData.xlsx", package = "MultiATSM"))
trade_data <- Load_Excel_Data(system.file("extdata", "TradeData.xlsx", package = "MultiATSM"))

# Adjust trade data
trade_data <- lapply(trade_data, function(df) {
  countries <- df[[1]]
  df <- as.data.frame(df[-1])
  rownames(df) <- countries
  df
})

# Define features of interest
ModelType <- "GVAR multi"
Economies <- c("China", "Uruguay", "Russia")
GlobalVar <- c("GBC", "CPI_OECD")
DomVar <- c("Eco_Act", "Inflation")
N <- 3
t0 <- "2006-09-01"
tF <- "2019-01-01"


# Compute some inputs
FactorLabels <- LabFac(N, DomVar, GlobalVar, Economies, ModelType)
Wgvar <- Transition_Matrix(
  t_First = "2006", t_Last = "2019", Economies,
  type = "Sample Mean", trade_data
)

# Compute GVARFactors
GVARFactors <- DatabasePrep(
  t0, tF, Economies, N, FactorLabels, ModelType, macro_data,
  yields_data, Wgvar
)

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

Description

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

Usage

DataForEstimation(
  t0,
  tF,
  Economies,
  N,
  FactorLabels,
  ModelType,
  DataFrequency,
  Macro_FullData,
  Yields_FullData,
  DataConnect = NULL,
  W_type = NULL,
  t_First_Wgvar = NULL,
  t_Last_Wgvar = NULL
)

Arguments

t0

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

tF

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

Economies

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

N

positive integer. Number of country-specific spanned factors.

FactorLabels

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

ModelType

character. Model type to be estimated. Permissible choices: "JPS original", "JPS global", "GVAR single", "JPS multi", "GVAR multi", "JLL original", "JLL No DomUnit", "JLL joint Sigma".

DataFrequency

character. Data frequency. Permissible choices: "Daily All Days", "Daily Business Days", "Weekly", "Monthly", "Quarterly", "Annually".

Macro_FullData

list. Full set of macroeconomic data.

Yields_FullData

list. Full set of bond yield data.

DataConnect

list. Data for computing bilateral connectedness measures. Default is NULL. Required for GVAR-based models.

W_type

character. Weight matrix type. Permissible choices: "Full Sample" (all years), "Sample Mean" (average over sample), or a specific year (e.g. "1998", "2005"). Default is NULL.

t_First_Wgvar

character. First year for weight matrix computation. Default is NULL.

t_Last_Wgvar

character. Last year for weight matrix computation. Default is NULL.

Value

A list containing:

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

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

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

General Notation

  • Td: model time series dimension.

  • C: number of countries in the system.

  • N: number of country-specific spanned factors.

  • K: total number of risk factors.

  • J: number of bond yields per country used in estimation.

See Also

Load_Excel_Data

Examples

DomVar <- c("Eco_Act", "Inflation")
GlobalVar <- c("GBC", "CPI_OECD")
t0 <- "2006-09-01"
tF <- "2019-01-01"
Economies <- c("China", "Brazil", "Mexico", "Uruguay", "Russia")
N <- 2
ModelType <- "JPS original"
FactorLabels <- LabFac(N, DomVar, GlobalVar, Economies, ModelType)
DataFrequency <- "Monthly"
MacroData <- Load_Excel_Data(system.file("extdata", "MacroData.xlsx", package = "MultiATSM"))
YieldData <- Load_Excel_Data(system.file("extdata", "YieldsData.xlsx", package = "MultiATSM"))
DataModel <- DataForEstimation(
  t0, tF, Economies, N, FactorLabels, ModelType, DataFrequency,
  MacroData, YieldData
)

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

Description

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

Usage

data("DomMacro")

Format

A matrix of country-specific risk factors (inflation and economic activity growth) for Brazil, China, Mexico, and Uruguay. The data have monthly frequency and span the period from June/2004 to January/2020.

Source

Inflation

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

Eonomic activity

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

References

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


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

Description

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

Usage

data("DomMacro_covid")

Format

A matrix of country-specific risk factors (inflation, output growth, CDS, and COVID-19 reproduction rate) for Brazil, India, Mexico, and Russia. The data have weekly frequency and span the period from March 22, 2020, to September 26, 2021.

Source

Inflation

Monthly CPI (from OECD) interpolated to daily data (spline), converted to weekly year-over-year changes, and detrended <https://www.oecd.org/en/data/indicators/inflation-cpi.html>

Output growth

Detrended weekly estimate of GDP year-over-year growth derived from the OECD Weekly Tracker index <https://web-archive.oecd.org/sections/weekly-tracker-of-gdp-growth/index.htm>

CDS

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

COVID-19 reproduction rate

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

References

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


FEVD and GFEVD graphs for all models

Description

FEVD and GFEVD graphs for all models

Usage

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

Arguments

ModelType

character. Estimated model type. Permissible choices: "JPS original", "JPS global", "GVAR single", "JPS multi", "GVAR multi", "JLL original", "JLL No DomUnit", "JLL joint Sigma".

NumOut

list. Computed outputs containing model fit, IRFs, FEVDs, GIRFs, GFEVDs and Term premia.

WishPdynamicsgraphs

logical. Set TRUE to generate risk factor graphs, FALSE otherwise.

WishYieldsgraphs

logical. Set TRUE to generate bond yield graphs, FALSE otherwise.

FEVDhoriz

integer. Desired horizon of analysis for the FEVDs.

PathsGraphs

character. Path of the folder in which the graphs will be saved.

OutputType

character. Available options: "FEVD", "GFEVD", "FEVD Ortho", "GFEVD Ortho".

Economies

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

Folder2save

character. Folder path where the outputs will be stored.

verbose

logical. Flag controlling function messaging.

Available Methods

- 'autoplot(object, type = "FEVD_Factor")', 'autoplot(object, type = "FEVD_Yields")', 'autoplot(object, type = "GFEVD_Yields")', 'autoplot(object, type = "GFEVD_Yields")'. For JLL-based models: 'autoplot(object, type = "FEVD_Factor-_Ortho")',
'autoplot(object, type = "FEVD_Yields_Ortho")', 'autoplot(object, type = "GFEVD_Yields_Ortho")', 'autoplot(object, type = "GFEVD_Yields_Ortho")'.

Examples

data("NumOutEx")
ModelType <- "JPS original"
Economy <- "Brazil"
FEVDhoriz <- 20
FEVDandGFEVDgraphs(ModelType, NumOutEx,
  WishPdynamicsgraphs = FALSE, WishYieldsgraphs = TRUE, FEVDhoriz,
  PathsGraphs = NULL, OutputType = "FEVD", Economy,
  Folder2save = NULL, verbose = FALSE
)

Model fit graphs for all models

Description

Model fit graphs for all models

Usage

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

Arguments

ModelType

character. Estimated model type.

WishFitgraphs

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

ModelPara

list. Model parameter estimates (see Optimization).

NumOut

list. Outputs containing model fit, IRFs, FEVDs, GIRFs, GFEVDs and Term premia.

Economies

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

PathsGraphs

character. Path of the folder in which the graphs will be saved.

Folder2save

character. Desired folder path to save outputs.

verbose

logical. Flag controlling function messaging.

Available Methods

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

Examples

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

Generates forecasts of bond yields for all model types

Description

Generates forecasts of bond yields for all model types

Usage

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

Arguments

ModelType

character. Model type to be estimated. Permissible choices: "JPS original", "JPS global", "GVAR single", "JPS multi", "GVAR multi", "JLL original", "JLL No DomUnit", "JLL joint Sigma".

ModelPara

list. Point estimates of the model parameters. See outputs from Optimization.

InputsForOutputs

list. Inputs for generating IRFs, GIRFs, FEVDs, GFEVDs, and Term Premia.

FactorLabels

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

Economies

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

JLLlist

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

GVARlist

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

WishBRW

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

BRWlist

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

Folder2save

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

verbose

logical. Print progress messages. Default is TRUE.

Value

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

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

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

  3. Root mean square errors per forecast horizon

Permissible options - forecast list (InputsForOutputs input)

  • ForHoriz: forecast horizon. Must be a positive integer.

  • t0Sample: initial sample date. Must be a positive integer smaller than the time series dimension of the model (Td)

  • t0Forecast: last sample date for the first forecast. Note that Td > t0Forecast + ForHoriz.

  • ForType: "Rolling" (rolling window forecast) or "Expanding" (for expanding window forecast)

Available Methods

- 'plot(object)'

Examples

data("ParaSetEx")
data("InpForOutEx")
# Adjust inputs according to the loaded features
ModelType <- "JPS original"
Economy <- "Brazil"
FacLab <- LabFac(N = 1, DomVar = "Eco_Act", GlobalVar = "Gl_Eco_Act", Economy, ModelType)
 # Adjust Forecasting setting
InpForOutEx[[ModelType]]$Forecasting <- list(
  WishForecast = 1, ForHoriz = 12, t0Sample = 1,
  t0Forecast = 143, ForType = "Expanding"
)

Forecast <- ForecastYields(ModelType, ParaSetEx, InpForOutEx, FacLab, Economy,
  WishBRW = FALSE, verbose = TRUE
)

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

Description

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

Usage

data("GlobalMacro")

Format

A matrix containing the time series of global risk factors, namely global economic activity and global inflation. The data have monthly frequency and span the period from June/2004 to January/2020.

Source

Global economic activity

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

Global inflation

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

References

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


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

Description

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

Usage

data("GlobalMacro_covid")

Format

A matrix containing the time series of global risk factors, namely the year-over-year growth rates of U.S. and Chinese output, and the S&P 500 index. The data have weekly frequency and span the period from March 22, 2020, to September 26, 2021.

Source

U.S. output growth:

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

China output growth:

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

S&P-500:

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

References

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


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

Description

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

Usage

GVAR(GVARinputs, N, CheckInputs = FALSE)

Arguments

GVARinputs

list. Inputs for GVAR model estimation:

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

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

  3. VARXtype: Permissible:

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

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

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

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

N

positive integer. Number of country-specific spanned factors.

CheckInputs

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

Value

list. Contains:

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

    • intercept (M + N x 1)

    • phi_1 (M + N x M + N)

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

    • phi_g (M + N x M + N)

    • Sigma (M + N x G)

  2. parameters of the GVAR:

    • F0 (K x K)

    • F1 (K x K)

    • Sigma_y (K x K)

General Notation

  • C: number of countries in the system

  • G: number of global unspanned factors

  • M: number of country-specific unspanned factors

  • N: number of country-specific spanned factors

  • K: total number of risk factors (K = C x (N + M) + G)

References

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

Examples

data(GVARFactors)

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

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

GVARPara <- GVAR(GVARinputs, N)

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

Description

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

Usage

data("GVARFactors")

Format

List of risk factors organized for GVAR estimation. It includes global unspanned factors (economic activity, inflation) and domestic factors—both unspanned (economic activity, inflation) and spanned (level, slope, curvature) with their starred counterparts. The dataset covers Brazil, China, Mexico, and Uruguay at a monthly frequency from June 2004 to January 2020.

Source

Global unspanned factors

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

Domestic unspanned factors

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

Domestic spanned factors

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

Domestic star factors

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

References

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


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

Description

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

Usage

data("InpForOutEx")

Format

list of inputs


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

Description

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

Usage

InputsForOpt(
  InitialSampleDate,
  FinalSampleDate,
  ModelType,
  Yields,
  GlobalMacro,
  DomMacro,
  FactorLabels,
  Economies,
  DataFrequency,
  GVARlist = NULL,
  JLLlist = NULL,
  WishBRW = FALSE,
  BRWlist = NULL,
  UnitYields = "Month",
  CheckInputs = TRUE,
  BS_Adj = FALSE,
  verbose = TRUE
)

Arguments

InitialSampleDate

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

FinalSampleDate

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

ModelType

character. Model type to be estimated. Permissible choices: "JPS original", "JPS global", "GVAR single", "JPS multi", "GVAR multi", "JLL original", "JLL No DomUnit", "JLL joint Sigma".

Yields

numerical matrix with time series of yields (J x Td or CJ x Td)

GlobalMacro

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

DomMacro

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

FactorLabels

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

Economies

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

DataFrequency

character. Data frequency. Permissible choices: "Daily All Days", "Daily Business Days", "Weekly", "Monthly", "Quarterly", "Annually".

GVARlist

list. Inputs for GVAR model estimation. See details below.

JLLlist

list. Inputs for JLL model estimation. See details below.

WishBRW

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

BRWlist

list. Inputs for bias-corrected estimation.

UnitYields

character. Maturity unit of yields. Permissible choices: "Month" or "Year". Default is "Month".

CheckInputs

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

BS_Adj

logical. Whether to adjust the global series for the sepQ models in the Bootstrap setting. Default is FALSE.

verbose

logical. Print progress messages. Default is TRUE.

Value

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

Permissible options for GVARlist

  • VARXtype: "unconstrained" or "constrained"

  • W_type: "Time-varying" or "Sample Mean"

  • t_First_Wgvar, t_Last_Wgvar: year as character

Permissible options for JLLlist

  • DomUnit: name of the dominant economy or None

  • WishSigmas: TRUE (estimate variance-covariance matrices) or FALSE

  • SigmaNonOrtho: NULL or K x K matrix

Permissible options for BRWlist

  • BiasCorrection: TRUE (bias-corrected) or FALSE

  • flag_mean: TRUE (mean) or FALSE (median)

  • gamma: numeric adjustment parameter

  • N_iter: number of iterations

  • N_burn: number of burn-in iterations

  • B: number of bootstrap samples

  • checkBRW: TRUE or FALSE

  • B_check: number of bootstrap samples for closeness check

General Notation

  • Td model time series dimension.

  • C number of countries in the system.

  • G number of global unspanned factors.

  • M number of country-specific unspanned factors.

  • K total number of risk factors.

  • J number of bond yields per country used in estimation.

Available Methods

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

Examples

# Example 1:
data(GlobalMacro)
data(DomMacro)
data(Yields)

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

DataFreq <- "Monthly"

ATSMInputs <- InputsForOpt(t0, tF, ModelType, Yields, GlobalMacro, DomMacro,
  FactorLabels, Economies, DataFreq,
  CheckInputs = FALSE, verbose = FALSE
)

# Example 2:
LoadData("CM_2024")

ModelType <- "GVAR multi"

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

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

ATSMInputs <- InputsForOpt(t0, tF, ModelType, Yields, GlobalMacro, DomMacro,
  FactorLabels, Economies, DataFreq, GVARlist,
  CheckInputs = FALSE, verbose = FALSE
)

# Example 3:
LoadData("CM_2024")

ModelType <- "JLL original"

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

JLLinputs <- list(DomUnit = "China")

DataFrequency <- "Monthly"

ATSMInputs <- InputsForOpt(t0, tF, ModelType, Yields, GlobalMacro, DomMacro,
  FactorLabels, Economies, DataFreq,
  JLLlist = JLLinputs,
  CheckInputs = FALSE, verbose = FALSE
)

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

Description

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

Usage

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

Arguments

ModelType

character. Model type to be estimated. Permissible choices: "JPS original", "JPS global", "GVAR single", "JPS multi", "GVAR multi", "JLL original", "JLL No DomUnit", "JLL joint Sigma".

Horiz

numeric scalar. Desired analysis horizon for the outputs.

ListOutputWished

character vector. Desired graphical outputs. Available options: "RiskFactors", "Fit", "IRF", "FEVD", "GIRF", "GFEVD", "TermPremia", "ForwardPremia".

OutputLabel

character. Name of the output label to be stored.

WishStationarityQ

logical. Whether to impose that the largest eigenvalue under Q is strictly smaller than 1. TRUE to impose.

DataFrequency

character. Data frequency. Permissible choices: "Daily All Days", "Daily Business Days", "Weekly", "Monthly", "Quarterly", "Annually".

WishGraphYields

logical. Whether to generate graphs for yields. Default is FALSE.

WishGraphRiskFactors

logical. Whether to generate graphs for risk factors. Default is FALSE.

WishOrthoJLLgraphs

logical. Whether to generate orthogonalized JLL-based graphs. Default is FALSE.

WishForwardPremia

logical. Whether to generate forward premia graphs. Default is FALSE.

LimFP

numeric vector. Maturities associated with the start and end dates of the loan.

WishBootstrap

logical. Whether to perform bootstrap-based estimation. Default is FALSE.

ListBoot

list. Contains bootstrap settings: methodBS ("bs", "wild", "block"), BlockLength (numeric), ndraws (numeric), pctg (numeric).

WishForecast

logical. Whether to generate forecasts. Default is FALSE.

ListForecast

list. Contains forecast settings: ForHoriz (numeric), t0Sample (numeric), t0Forecast (numeric), ForType ("Rolling", "Expanding").

UnitYields

character. Maturity unit of yields. Options: "Month" or "Year". Default is "Month".

Value

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

Examples

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

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

IRF and GIRF graphs for all models

Description

IRF and GIRF graphs for all models

Usage

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

Arguments

ModelType

character. Estimated model type.Permissible choices: "JPS original", "JPS global", "GVAR single", "JPS multi", "GVAR multi", "JLL original", "JLL No DomUnit", "JLL joint Sigma".

NumOut

list. Computed outputs containing model fit, IRFs, FEVDs, GIRFs, GFEVDs and term premia.

WishPdynamicsgraphs

logical. Set TRUE to generate risk factor graphs, FALSE otherwise.

WishYieldsgraphs

logical. Set TRUE to generate bond yield graphs, FALSE otherwise.

IRFhoriz

integer. Desired horizon of analysis for the IRFs.

PathsGraphs

character. Path of the folder in which the graphs will be saved.

OutputType

character. Available options: "IRF", "GIRF", "IRF Ortho", "GIRF Ortho".

Economies

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

Folder2save

character. Folder path where the outputs will be stored.

verbose

logical. Flag controlling function messaging.

Available Methods

- 'autoplot(object, type = "IRF_Factor")', 'autoplot(object, type = "IRF_Yields")', 'autoplot(object, type = "GIRF_Yields")', 'autoplot(object, type = "GIRF_Yields")'. For JLL-based models: 'autoplot(object, type = "IRF_Factor-_Ortho")',
'autoplot(object, type = "IRF_Yields_Ortho")', 'autoplot(object, type = "GIRF_Yields_Ortho")', 'autoplot(object, type = "GIRF_Yields_Ortho")'.

Examples

data("NumOutEx")
ModelType <- "JPS original"
Economy <- "Brazil"
IRFhoriz <- 20
irf_Out <- IRFandGIRFgraphs(ModelType, NumOutEx,
  WishPdynamicsgraphs = FALSE, WishYieldsgraphs = TRUE, IRFhoriz,
  PathsGraphs = NULL, OutputType = "GIRF", Economy, Folder2save = NULL,
  verbose = FALSE
)

Estimates the P-dynamics from JLL-based models

Description

Estimates the P-dynamics from JLL-based models

Usage

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

Arguments

NonOrthoFactors

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

N

positive integer. Number of country-specific spanned factors.

JLLinputs

list. Necessary inputs to estimate JLL models:

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

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

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

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

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

CheckInputs

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

Value

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

General Notation

  • Td: model time series dimension

  • C number of countries in the system.

  • K: total number of risk factors

References

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

Examples

data(RiskFacFull)
RF_TS <- RiskFacFull
N <- 3
JLLinputs <- list(
  Economies = c("China", "Brazil", "Mexico", "Uruguay"), DomUnit = "China",
  WishSigmas = TRUE, SigmaNonOrtho = NULL, JLLModelType = "JLL original"
)
JLLPara <- JLL(RF_TS, N, JLLinputs)

Generates the labels for risk factors used in the model

Description

Generates the labels for risk factors used in the model

Usage

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

Arguments

N

positive integer. Number of country-specific spanned factors. Must be between 1 and 8.

DomVar

character vector. Names of the domestic variables.

GlobalVar

character vector. Names of the global variables.

Economies

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

ModelType

character. Model type to be estimated. Permissible choices: "JPS original", "JPS global", "GVAR single", "JPS multi", "GVAR multi", "JLL original", "JLL No DomUnit", "JLL joint Sigma".

Value

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

Examples

N <- 2
DomVar <- c("inflation", "Output gap")
GlobalVar <- "Commodity Prices"
Economies <- c("U.S.", "Canada", "Germany", "Japan")
ModelType <- "JPS original"
VarLabels <- LabFac(N, DomVar, GlobalVar, Economies, ModelType)

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

Description

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

Usage

Load_Excel_Data(ExcelFilePath)

Arguments

ExcelFilePath

character. Path to the Excel file (.xlsx) to load. Must be a valid file path. The file can contain multiple sheets; each sheet will be loaded as a separate data frame in the output list.

Details

Uses the readxl package to read all sheets from the specified Excel file. Each sheet is returned as a data frame. The output is a named list, with names matching the sheet names in the Excel file.

Value

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

Examples

if (!requireNamespace("readxl", quietly = TRUE)) {
  stop(
    "Please install package \"readxl\" to use this feature.",
    call. = FALSE
  )

  Load_Excel_Data(system.file("extdata", "MacroData.xlsx", package = "MultiATSM"))
  Load_Excel_Data(system.file("extdata", "YieldsData.xlsx", package = "MultiATSM"))
}

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

ATSM Package

Description

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

Author(s)

Rubens Moura [email protected]


Overview of Datasets Included in the MultiATSM Package

Description

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

Details

GlobalMacro

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

GlobalMacro_covid

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

DomMacro

Domestic macroeconomic risk factors, namely economic activity and inflation.

DomMacro_covid

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

TradeFlows

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

TradeFlows_covid

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

Yields

Monthly series of bond yields by maturity for multiple economies.

Yields_covid

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

RiskFacFull

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

GVARFactors

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

BR_jps_out

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

InpForOutEx

List of inputs for an illustrative JPS model with Brazilian data

ParaSetEx

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

NumOutEx

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

Out_Example

re-loaded examaple of a complete list of several model outputs. Used in the package vignette.

Each dataset is documented separately using '?GlobalMacro', '?DomMacro', '?TradeFlows', '?Yields', etc. Datasets ending with the suffix _covid are based on those used in Candelon and Moura (2023) and cover Brazil, India, Mexico, and Russia. The remaining datasets correspond to Candelon and Moura (2024) and include Brazil, China, Mexico, and Uruguay.

References

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

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


Example of computed numerical outputs

Description

Numerical outputs for JPS-based model using Brazilian data

Usage

data("NumOutEx")

Format

list of inputs and outputs

PC var explained

variance explained per spanned factor

Fit

model fit of bond yields

IRF

Impulse response function

FEVD

Forecast error variance decomposition

GIRF

Generalized impulse response function

GFEVD

Generalized Forecast error variance decomposition

TermPremiaDecomp

Term Premia decomposition


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

Description

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

Usage

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

Arguments

ModelType

character. Model type to be estimated. Permissible choices: "JPS original", "JPS global", "GVAR single", "JPS multi", "GVAR multi", "JLL original", "JLL No DomUnit", "JLL joint Sigma".

ModelPara

list. Point estimates of the model parameters. See outputs from Optimization

InputsForOutputs

list. Inputs for generating IRFs, GIRFs, FEVDs, GFEVDs, and Term Premia.

FactorLabels

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

Economies

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

Folder2save

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

verbose

Logical flag controlling function messaging. Default is TRUE.

Details

Both IRFs and FEVDs are computed using the Cholesky decomposition method. The risk factors are ordered as follows: (i) global unspanned factors, and (ii) domestic unspanned and spanned factors for each country. The order of countries follows the sequence defined in the Economies vector.

Value

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

  1. Model parameter estimates

  2. Model fit of bond yields

  3. IRFs

  4. FEVDs

  5. GIRFs

  6. GFEVDs

  7. Bond yield decomposition

Available methods

- 'autoplot(object, type)'

References

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

Examples

data("ParaSetEx")
data("InpForOutEx")
# Adjust inputs according to the loaded features
ModelType <- "JPS original"
Economy <- "Brazil"
FacLab <- LabFac(N = 1, DomVar = "Eco_Act", GlobalVar = "Gl_Eco_Act", Economy, ModelType)

NumOut <- NumOutputs(ModelType, ParaSetEx, InpForOutEx, FacLab, Economy,
  Folder2save = NULL, verbose = FALSE
)

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

Description

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

Usage

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

Arguments

MLEinputs

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

StatQ

A logical value indicating whether to impose that the largest eigenvalue under Q is strictly smaller than 1. Set TRUE to impose this restriction.

DataFreq

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

FactorLabels

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

Economies

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

ModelType

character. Model type to be estimated. Permissible choices: "JPS original", "JPS global", "GVAR single", "JPS multi", "GVAR multi", "JLL original", "JLL No DomUnit", "JLL joint Sigma".

tol

numeric. Convergence tolerance. The default is 1e-4.

EstType

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

TimeCount

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

BS_outputs

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

verbose

Logical flag controlling function messaging. Default is TRUE.

Value

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

Available Methods

- 'summary(object)'

References

  • Candelon, C. and Moura, R. (2024). “A Multicountry Model of the Term Structures of Interest Rates with a GVAR.” Journal of Financial Econometrics 22 (5): 1558–87.

  • Jotikasthira, C; Le, A. and Lundblad, C (2015). “Why Do Term Structures in Different Currencies Co-Move?” Journal of Financial Economics 115: 58–83.

  • Joslin, S,; Priebsch, M. and Singleton, K. (2014). “Risk Premiums in Dynamic Term Structure Models with Unspanned Macro Risks.” Journal of Finance 69 (3): 1197–1233.

  • Joslin, S., Singleton, K. and Zhu, H. (2011). "A new perspective on Gaussian dynamic term structure models". The Review of Financial Studies.

  • Le, A. and Singleton, K. (2018). "A Small Package of Matlab Routines for the Estimation of Some Term Structure Models." Euro Area Business Cycle Network Training School - Term Structure Modelling.

Examples

LoadData("CM_2024")
ModelType <- "JPS original"
Economy <- "Brazil"
t0 <- "01-05-2007" # Initial Sample Date (Format: "dd-mm-yyyy")
tF <- "01-12-2018" # Final Sample Date (Format: "dd-mm-yyyy")
N <- 1
GlobalVar <- "Gl_Eco_Act" # Global Variables
DomVar <- "Eco_Act" # Domestic Variables
DataFreq <- "Monthly"
StatQ <- FALSE

FacLab <- LabFac(N, DomVar, GlobalVar, Economy, ModelType)
ATSMInputs <- InputsForOpt(t0, tF, ModelType, Yields, GlobalMacro, DomMacro,
  FacLab, Economy, DataFreq,
  CheckInputs = FALSE, verbose = FALSE
)

OptPara <- Optimization(ATSMInputs, StatQ, DataFreq, FacLab, Economy, ModelType, verbose = FALSE)

Complete list of several outputs from an ATSM

Description

Example for illustration used in the package vignette

Usage

data("Out_Example")

Format

several model classes

ModelParaList

List of parameter estimates of the selected ATSM

ATSMinputs

General inputs from an ATSM

Forecasts

List of forecast outputs

NumOut

List of numerical outputs

Bootstrap

List of set of outputs after bootstrap


Example of parameter set after optimization

Description

JPS-based model for Brazilian data

Usage

data("ParaSetEx")

Format

list of inputs and outputs

Inupts

general model inputs

ModEst

model parameters estimates (JPS form)


Computes the PCA weights for a single country

Description

Computes the PCA weights for a single country

Usage

pca_weights_one_country(Yields, Economy)

Arguments

Yields

matrix (J x Td). Bond yields for a single country.

Economy

character. Name of the economy.

Value

matrix (J x J). Eigenvectors of the variance-covariance matrix of yields.

General Notation

  • Td: model time series dimension

  • J: number of bond yields per country used in estimation

Examples

data(Yields)
Economy <- "Mexico"
pca_weights <- pca_weights_one_country(Yields, Economy)

Plot method for ATSMModelForecast objects

Description

Plot method for ATSMModelForecast objects

Usage

## S3 method for class 'ATSMModelForecast'
plot(x, ...)

Arguments

x

An object of class ATSMModelForecast

...

Additional arguments (not used)


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)


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

Description

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

Usage

data("RiskFacFull")

Format

matrix containing the full risk factors: (i) global unspanned factors (global economic activity and global inflation); (ii) domestic unspanned factors (economic activity and inflation); and (iii) domestic spanned factors (level, slope, and curvature). Economic system is formed by Brazil, China, Mexico and Uruguay. The data have monthly frequency and span the period from June/2004 to January/2020.

Source

Global unspanned factor

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

Domestic unspanned factor

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

Domestic spanned factor

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

References

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


Spanned and unspanned factors plot

Description

Spanned and unspanned factors plot

Usage

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

Arguments

ModelType

character. Estimated model type. Permissible choices: "JPS original", "JPS global", "GVAR single", "JPS multi", "GVAR multi", "JLL original", "JLL No DomUnit", "JLL joint Sigma".

WishRFgraphs

logical. Set TRUE to generate graphs, FALSE otherwise.

ModelOutputs

list. Model parameter estimates (see Optimization).

Economies

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

FactorLabels

list. Labels for all variables in the model.

Folder2save

character. Folder path where the outputs will be stored.

verbose

logical. Flag controlling function messaging.

Available Methods

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

Examples

data("ParaSetEx")
# Adapt factor labels according to the example
ModelType <- "JPS original"
Economy <- "Brazil"
FacLab <- LabFac(N = 1, DomVar = "Eco_Act", GlobalVar = "Gl_Eco_Act", Economy, ModelType)

RiskFactorsGraphs(ModelType,
  WishRFgraphs = FALSE, ParaSetEx, Economy, FacLab,
  Folder2save = NULL, verbose = FALSE
)

Computes the country-specific spanned factors

Description

Computes the country-specific spanned factors

Usage

Spanned_Factors(Yields, Economies, N)

Arguments

Yields

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

Economies

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

N

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

Value

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

General Notation

  • Td: model time series dimension

  • C: number of countries in the system

  • N: number of country-specific spanned factors

  • J: number of bond yields per country used in estimation

Examples

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

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)


Term Premia decomposition graphs for all models

Description

Term Premia decomposition graphs for all models

Usage

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

Arguments

ModelType

character. Estimated model type. Permissible choices: "JPS original", "JPS global", "GVAR single", "JPS multi", "GVAR multi", "JLL original", "JLL No DomUnit", "JLL joint Sigma".

NumOut

list. Computed outputs containing model fit, IRFs, FEVDs, GIRFs, GFEVDs and risk premia.

ModelPara

list. Model parameter estimates (see Optimization).

WishRPgraphs

logical. Set TRUE to generate term premia graphs, FALSE otherwise.

UnitYields

character. "Month" if yields are in months, "Year" if in years.

Economies

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

PathsGraphs

character. Path of the folder in which the graphs will be saved.

Folder2Save

character. Folder path where the outputs will be stored.

verbose

logical. Flag controlling function messaging.

Available Methods

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

Examples

data("ParaSetEx")
data("NumOutEx")
ModelType <- "JPS original"
Economy <- "Brazil"
UnitYields <- "Month"
TPDecompGraph(ModelType, NumOutEx, ParaSetEx,
  WishRPgraphs = FALSE, UnitYields, Economy,
  PathsGraphs = NULL, Folder2Save = NULL, verbose = FALSE
)

Data: Trade Flows - Candelon and Moura (2024, JFEC)

Description

Trade Flows data used in Candelon and Moura (2024, JFEC)

Usage

data("TradeFlows")

Format

A list. Contains bilateral trade flow data for Brazil, China, Mexico, and Uruguay, covering the sample period from 1948 to 2019.

Source

International Monetary Fund - International Trade in Goods (IMTS) <https://data.imf.org/en/datasets/IMF.STA:IMTS>

References

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


Data: Trade Flows - Candelon and Moura (2023, EM)

Description

Trade Flows data used in Candelon and Moura (2023, EM)

Usage

data("TradeFlows_covid")

Format

A list. Contains bilateral trade flow data for Brazil, India, Mexico, and Russia, covering the sample period from 1948 to 2020.

Source

International Monetary Fund - International Trade in Goods (IMTS) <https://data.imf.org/en/datasets/IMF.STA:IMTS>

References

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


Computes the transition matrix required in the estimation of the GVAR model

Description

Computes the transition matrix required in the estimation of the GVAR model

Usage

Transition_Matrix(t_First, t_Last, Economies, type, DataConnectedness)

Arguments

t_First

character. Sample starting date (format: yyyy).

t_Last

character. Sample ending date (format: yyyy).

Economies

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

type

character. Method for computing interdependence. Possible options:

  • "Time-varying": Computes time-varying interdependence and returns weight matrices for each year.

  • "Sample Mean": Returns a single weight matrix with average weights over the sample period.

  • Specific year (e.g., "1998", "2005"): Computes time-invariant interdependence for the specified year.

DataConnectedness

list or data frame. Data used to compute the transition matrix (e.g., trade flows).

Details

If there is missing data for any country in a particular year, the transition matrix will include only NAs.

Value

matrix or list of matrices. Time-varying or time-invariant transition matrix depending on 'type'.

Examples

t_First <- "2006"
t_Last <- "2019"
Economies <- c("China", "Brazil", "Mexico", "Uruguay")
type <- "Sample Mean"
# Load data if Connectedness data from excel, otherwise use pre-saved data
GetExcelData <- FALSE

if (GetExcelData) {
  if (!requireNamespace("readxl", quietly = TRUE)) {
    stop(
      "Please install package \"readxl\" to use this feature.",
      call. = FALSE
    )
    DataPath <- system.file("extdata", "TradeData.xlsx", package = "MultiATSM")
    tab_names_Trade <- readxl::excel_sheets(DataPath)
    list_all_Trade <- suppressMessages(lapply(tab_names_Trade, function(x) {
      readxl::read_excel(path = DataPath, sheet = x)
    }))
    names(list_all_Trade) <- tab_names_Trade

    L <- length(list_all_Trade)

    for (i in 1:L) {
      Countries <- list_all_Trade[[i]][[1]]
      list_all_Trade[[i]] <- as.data.frame(list_all_Trade[[i]][, -1])
      rownames(list_all_Trade[[i]]) <- Countries
    }

    DataConnectedness <- list_all_Trade
  }
} else {
  data(TradeFlows)
  DataConnectedness <- TradeFlows
}

W_mat <- Transition_Matrix(t_First, t_Last, Economies, type, DataConnectedness)

Estimates a standard VAR(1)

Description

Estimates a standard VAR(1)

Usage

VAR(RiskFactors, VARtype, Bcon_Mat = NULL)

Arguments

RiskFactors

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

VARtype

character. Permissible choices: "unconstrained" or "constrained".

Bcon_Mat

matrix (K x K + 1). Constraints matrix (includes intercept). Entries containing NAs are treated as free parameters. Default is NULL.

Value

list. Contains:

  • intercept (K x 1)

  • feedback matrix (K x K)

  • variance-covariance matrix (K x K) of a VAR(1)

General Notation

  • Td: model time series dimension

  • N: number of country-specific spanned factors

  • K: total number of risk factors

Examples

data(RiskFacFull)
# Example 1: unconstrained case
VAR_para1 <- VAR(RiskFacFull, VARtype = "unconstrained")

# Example 2: constrained case
K <- nrow(RiskFacFull)
Bcon_Mat <- matrix(0, nrow = K, ncol = K + 1)
Bcon_Mat[, 1:3] <- NaN
VAR_para2 <- VAR(RiskFacFull, VARtype = "constrained", Bcon_Mat)

Data: bond yield data - Candelon and Moura (2024, JFEC)

Description

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

Usage

data("Yields")

Format

A matrix containing bond yields with maturities of 3, 6, 12, 36, 60, and 120 months for Brazil, China, Mexico, and Uruguay. The data are at monthly frequency and cover the period from June 2004, to January 2020.

Source

Brazil

Swap fixed-DI contracts (derivative securities indexed to the interbank loan rates). <https://www.b3.com.br/pt_br/market-data-e-indices/servicos-de-dados/market-data/consultas/mercado-de-derivativos/precos-referenciais/taxas-referenciais-bm-fbovespa/>

China

Government bond yield data in domestic currency. Simulated data constructed using Bloomberg bond yield series.

Mexico

Government bond yield data in domestic currency. Simulated data constructed using Bloomberg bond yield series.

Uruguay

Government bond yield data in US dollars <https://web.bevsa.com.uy/CurvasVectorPrecios/CurvasIndices/CUD.aspx>.

References

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


Data: Yields - Candelon and Moura (2023)

Description

Bond yield data used in Candelon and Moura (2023)

Usage

data("Yields_covid")

Format

A matrix containing Government bond yields with maturities of 12, 24, 36, 60, and 120 months for Brazil, India, Mexico, and Russia. The data are at weekly frequency and cover the period from March 22, 2020, to September 26, 2021.

Source

Simulated data constructed using Bloomberg bond yield series.

References

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