Learn R Programming

Overview

MultiATSM is an R package for estimating, analyzing, and forecasting multi-country macro-finance affine term structure models (ATSMs). The package implements a variety of models, including JPS, GVAR, and JLL frameworks (see complete references below), and provides tools for bias correction, bootstrap analysis, and graphical/numerical outputs.

Features

  • Estimation of multi-country ATSMs (JPS, 2014, JLL, 2015, GVAR, 2023-2024, and variants)
  • Flexible input structure for macroeconomic and yield data
  • Graphical and numerical outputs for model diagnostics and interpretation
  • Bias correction for a VAR dynamics (BRW, 2012)
  • Bootstrap analysis for confidence intervals
  • Out-of-sample forecasting

Installation

You can install the development version of MultiATSM from GitHub with:

# install.packages("devtools")
devtools::install_github("rubensmoura87/MultiATSM")

You can also get the official release version from CRAN

install.packages("MultiATSM")

Usage and documentation

  • See the package manual and vignettes for detailed function documentation and examples.
  • Main functions: InputsForOpt, Bias_Correc_VAR, Optimization, NumOutputs, Bootstrap, ForecastYields, etc.

More information about {MultiATSM}

You can learn more about the underlying models in the working paper published in the LIDAM-LFIN Series..

References

  • Bauer, M. D., Rudebusch, G. D., & Wu, J. C. (2012). Correcting estimation bias in dynamic term structure models. Journal of Business & Economic Statistics, 30(3), 454-467.

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

  • Candelon, B., & Moura, R. (2024). A Multicountry Model of the Term Structures of Interest Rates with a GVAR. Journal of Financial Econometrics, 22(5), 1558-1587.

  • Joslin, S., Priebsch, M., & Singleton, K. J. (2014). Risk premiums in dynamic term structure models with unspanned macro risks. The Journal of Finance, 69(3), 1197-1233.

  • Joslin, S., Singleton, K. J., & Zhu, H. (2011). A new perspective on Gaussian dynamic term structure models. The Review of Financial Studies, 24(3), 926-970.

  • Jotikasthira, C., Le, A., & Lundblad, C. (2015). Why do term structures in different currencies co-move?. Journal of Financial Economics, 115(1), 58-83.

  • See also the references in the package documentation.

Copy Link

Version

Install

install.packages('MultiATSM')

Monthly Downloads

371

Version

1.5.0

License

GPL-2 | GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Rubens Moura

Last Published

October 23rd, 2025

Functions in MultiATSM (1.5.0)

BuildGVAR

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

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

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

Build P-dynamic graphs after the bootstrap implementation
BuildLinkMat

Build country-specific link matrices
BuildIRFlist

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

Generates the desired bootstrap graphs
CheckInput_K1X

Input validation for the 'FeedMat_Q' function
CheckInputsForMLE

Check consistence of inputs
Bias_Correc_VAR

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

Generates the desired bootstrap graphs
ComputeBounds_IRFandGIRF

Compute the confidence bounds from the model's numerical outputs
ComputeBounds_FEVDandGFEVD

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

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

Check Numerical Precision Issues of K1_root matrix
Check_comparison_NoBC

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

Compute FEVDs for all models
BuildRiskFactors_BS

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

Builds the confidence bounds and graphs (Bootstrap set)
CleanOrthoJLL_Boot

Clean unnecessary outputs of JLL models in the bootstrap setup
Bootstrap

Generates the bootstrap-related outputs
CholRestrictionsJLL

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

Build Confidence intervals for yield-related outputs
ChecksOOS

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

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

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

Compute GFEVDs for all models
FactorBounds_FEVDandGFEVD

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

Compute the confidence bounds for the model P-dynamics
Est_K1h

Estimate K1h
ComputeIRFs

Compute IRFs of all models
EstimationSigma_Ye

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

Compute GIRFs for all models
DataSet_BS

Prepare the factor set for GVAR models (Bootstrap version)
DatabasePrep

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

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

Get the expected component of all models
GVAR

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

Use function ML to generate the outputs from a ATSM
Est_RestOLS

Estimate a restricted OLS model
EstimationSigma_GVARrest

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

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

Generates forecasts of bond yields for all model types
FEVDandGFEVDs_Graphs

Generates graphs for FEVDs and GFEVDs
FolderCreation_Boot

Creates folder to store graphs generated from the bootstrap analysis
FeedMat_M

Computes an average or median feedback matrix across several bootstrap iterations
FacQuantile_bs

Compute quantiles for model P-dynamics
FolderCreationPoint

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

Generate artificial time-series in the bootstrap setup
ForwardPremia

Compute the forward premia for all models
Gather_Forecasts

Gather several forecast dates
BuildYields_BS

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

Check consistency of the inputs provided in GVARinputs
GaussianDensity

computes the density function of a gaussian process
CheckJLLinputs

Check consistency of the inputs provided in JLL-based models
Compute_BnX_AnX

Compute the latent loading AnX and BnX
Get_a0

Obtain the country-specific a0
Get__BnXAnX

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

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

Model fit graphs for all models
GetAuxPara

Compute the auxiliary parameters a.
FolderCreationBoot

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

Compute the Feedback matrix of each bootstrap draw
GetPdynPara_BC

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

IRF and GIRF graphs for all models
Get_r0

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

Get delta t
GetPdynPara_NoBC

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

Generate the variable labels of the JLL models
Get_SSZ_BC

Compute the variance-covariance matrix after the bias correction procedure
Get_SigmaYields

Compute the variance-covariance matrix of the bond yields
Get_llk

Compute the log-likelihood function
IRFandGIRFs_Format_Fac

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

FEVD and GFEVD graphs for all models
FEVDandGFEVDbs

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

Compute the A loadings
Gen_Forecast_Yields

Compute the bond yield forecast for any model type
Load_Excel_Data

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

Compute the B matrix of loadings
Jordan_JLL

Check for JLL models for Jordan restrictions (auxiliary form)
IdxSpanned

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

Obtain the indexes of both the domestic and global unspanned factors
K1XQStationary

Impose stationarity under the Q-measure
GlobalMacro

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

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

Perform a linear regression using demeaned variables
IRFandGIRFbs

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

Prepare outputs to export after the model optimization
Get_FeedMat_NoBC

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

IRFs and GIRFs after bootstrap for all models
Optimization

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

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

Build the B loadings
MLEdensity

Compute the maximum likelihood function of all models
Transition_Matrix

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

Robust method for matrix inversion
TradeFlows_covid

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

Estimates the P-dynamics from JLL-based models
RemoveNA

Exclude series that contain NAs
ParaLabelsOpt

Create the variable labels used in the estimation
ParaSetEx

Example of parameter set after optimization
InpForOutEx

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

Overview of Datasets Included in the MultiATSM Package
GVAR_PrepFactors

Prepare risk factors for the estimation of the GVAR model
True_jordan_OneCountry

True function for a single-country specification
ImposeStat_Aux

Impose stationary constraint under the risk-neutral measure
OutputConstruction

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

Map auxiliary (unconstrained) parameters a to constrained parameters b
NoOrthoVAR_JLL

Obtain the non-orthogonalized model parameters
Update_ParaList

Update parameters in the optimization process
GetYields_AllCountries

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

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

Adjust vector of maturities
Maturities

Create a vector of numerical maturities in years
Get_Unspanned

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

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

Build subplot for fitted yields
GlobalMacro_covid

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

Example of computed numerical outputs
Wished_Graphs_FEVDandGFEVD

Extract list of desired graph features (IRFs anc GIRFs)
Get_Sigma_JLL

Compute Sigmas/Cholesky factorizations
GraphicalOutputs

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

Concatenate the model-specific inputs in a list
TPDecompGraph

Term Premia decomposition graphs for all models
Compute_EP

Compute the expected component for all models
Outputs2exportMLE

Prepares inputs to export
True_JLLstruct

Transformation of the JLL-related parameters (true form)
MLtemporary

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

Estimate the marginal model for the global factors
RMSE

Compute the root mean square error for all models
NumOutputs

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

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

Transformation of the block diagonal parameters (true form)
Intra_Yields

Fit the cross-section of yields using spline
Optimization_Time

Compute the time elapsed in the numerical optimization
RiskFactorsGraphs

Spanned and unspanned factors plot
OrthoReg_JLL

Get coefficients from the orthogonalized regressions
YieldBounds_FEVDandGFEVD

Compute the confidence bounds for the model bond yield-related outputs
Wished_Graphs_IRFandGIRF

Extract list of desired graph features (IRFs anc GIRFs)
RiskFactorsPrep

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

Scaling vector computation
YieldBounds_IRFandGIRF

Compute the confidence bounds for the model bond yield-related outputs
ImposeStat_True

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

Stochastic approximation algorithm
LabFac

Generates the labels for risk factors used in the model
MLFunction

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

Generate the labels of the spanned factors
Y_Fit

Model-implied yields (cross-section)
Spanned_Factors

Computes the country-specific spanned factors
Yields_covid

Data: Yields - Candelon and Moura (2023)
pos_map

Exponential transformation
Y_ModImp

Model-implied yields (P-dynamics)
YieldsFitAll

Fit yields for all maturities of interest
FEVDandGFEVD

FEVDs and GFEVDs for all models
FEVDandGFEVD_BS

FEVDs and GFEVDs after bootstrap for all models
print.ATSMModelInputs

Print method for ATSMModelInputs objects
OOS_Forecast

Perform out-of-sample forecast of bond yields
True_Jordan

Transformation of the Jordan-related parameters (True form)
ML_stable

Prevents algorithm to end up in ill-defined likelihood
OptimizationSetup_ATSM

Optimization routine for the entire selected ATSM
NumOutputs_Bootstrap

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

Compute quantiles for model bond yield-related outputs
Optimization_PE

Perform the minimization of ML function
TermPremiaDecomp

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

Compute the term premia
ResampleResiduals_BS

Compute the residuals from the original model
RiskFacFull

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

Autoplot method for ATSMModelBoot objects
summary.ATSMModelInputs

Summary method for ATSMModelInputs objects
pca_weights_one_country

Computes the PCA weights for a single country
plot.ATSMModelForecast

Plot method for ATSMModelForecast objects
adjust_delta

Adjust delta for numerical differentiation
True_PSD

Transformation of a PSD matrix (true form)
YieldFor

Compile the bond yield forecast for any model type
shrink_FeedMat_BC

Shrinking the largest eigenvalue
Gen_art_series

Simulate N_Boot dataset from the P-dynamics
FolderPrep_IRFs

Create folders for storing IRFs and GIRFs
FolderPrep_FEVDs

Create folders for storing IRFs and GIRFs
summary.ATSMModelOutputs

Summary method for ATSMModelOutputs objects
GeneralMLEInputs

Gathers the general inputs for model estimation
Get_G0G1Sigma

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

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

Compute the feedback matrix from a GVAR model with global factors
GetLabels_sepQ

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

Check for presence of NAs and infinite in numeric variables
IDXZeroRestrictionsJLLVarCovOrtho

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

IRFs and GIRFs for all models
IRFandGIRFs_Format_Yields

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

Find the indexes of the spanned factors
llk_JLL_Sigma

Build the log-likelihood function of the P-dynamics from the JLL-based models
Jac_approx

Main Jacobian approximation
JordanMat

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

Generate the labels of the star variables
LoadData

Loads data sets from several papers
YieldsFit

Computes two measures of model fit for bond yields (all models)
VAR

Estimates a standard VAR(1)
safe_solve

Safe matrix inversion with conditioning check
Update_SSZ_JLL

Update the variance-covariance matrix from the "JLL joint Sigma" model. Necessary for optimization
richardson_diff

Richardson extrapolation
MultiATSM

ATSM Package
Yields

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

Compute the root of the eigenvalue of K1h
MergeFEVD_graphs

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

VAR(1) with orthogonalized factors (JLL models)
TimeVarWeights_GVAR

Compute the star variables with time-varying weights
Rotate_Lat_Obs

Rotate latent states to observed ones
Out_Example

Complete list of several outputs from an ATSM
TradeFlows

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

Percentage explained by the spanned factors of the variations in the set of observed yields for all models
VARX

Estimate a VARX(1,1,1)
WishGraphs_IRFandGIRF_Boot

Extract graphs of interest (bootstrap version)
autoplot

Autoplot generic function
autoplot.ATSMNumOutputs

Autoplot method for ATSMNumOutputs objects
withDefault

Check default value
rhoParas

Compute risk-neutral intercept and slope
residY_original

Compute the residuals from the observational equation
WishGraphs_FEVDandGFEVD_Boot

Extract graphs of interest (bootstrap version)
Aux_JLLstruct

Transformation of the JLL-related parameters (auxiliary form)
BUnspannedAdapJoint

Transform B_spanned into B_unspanned for jointQ models
AdjustYieldsDates

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

Generate paths to save IRFs/GIRFs graphs
AdjustOptm_BS

Gathers the estimate of the bootstrap draws
Aux_jordan_OneCountry

Auxiliary function for a single-country specification
BUnspannedAdapSep_BS

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

Adjust the constant label
Boot_graph_template

Builds template from bootstrap-related graphs
BR_jps_out

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

Transformation of the block diagonal parameters (auxiliary form)
Aux_PSD

Transformation of a PSD matrix (auxiliary form)
BUnspannedAdapSep

Transform B_spanned into B_unspanned for sepQ models
Boot_Yields_Graphs

Build P-dynamic graphs after the bootstrap implementation
Aux_Jordan

Transformation of the Jordan-related parameters (auxiliary form)
AdjustPathFEVDs

Generate paths to save IRFs/GIRFs graphs