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

436

Version

1.5.1

License

GPL-2 | GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Rubens Moura

Last Published

November 5th, 2025

Functions in MultiATSM (1.5.1)

Aux_PSD

Transformation of a PSD matrix (auxiliary form)
Aux_Jordan

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

Transformation of the block diagonal parameters (auxiliary form)
Aux_JLLstruct

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

Auxiliary function for a single-country specification
AdjustPathFEVDs

Generate paths to save IRFs/GIRFs graphs
AdjustOptm_BS

Gathers the estimate of the bootstrap draws
Adjust_Const_Type

Adjust the constant label
AdjustPathIRFs

Generate paths to save IRFs/GIRFs graphs
AdjustYieldsDates

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

Generates the desired bootstrap graphs
Bias_Correc_VAR

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

Transform B_spanned into B_unspanned for jointQ models
Boot_Yields_Graphs

Build P-dynamic graphs after the bootstrap implementation
Boot_Fac_Graphs

Build P-dynamic graphs after the bootstrap implementation
Boot_DataGraphFact_perShock

Generates the desired bootstrap graphs
Boot_graph_template

Builds template from bootstrap-related graphs
BUnspannedAdapSep_BS

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

Transform B_spanned into B_unspanned for sepQ models
BR_jps_out

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

Build country-specific link matrices
Bootstrap

Generates the bootstrap-related outputs
BuildFEVDlist

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

Builds the confidence bounds and graphs (Bootstrap set)
BuildCI_Yields

Build Confidence intervals for yield-related outputs
BuildGVAR

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

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

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

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

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

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

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

Input validation for the 'FeedMat_Q' function
Check_label_consistency

Check consistency of labels (economies, domestic and global variables)
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
ComputeIRFs

Compute IRFs of all models
ComputeBounds_FEVDandGFEVD

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

Check consistence of inputs
CleanOrthoJLL_Boot

Clean unnecessary outputs of JLL models in the bootstrap setup
CholRestrictionsJLL

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

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

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

Compute the latent loading AnX and BnX
ComputeGFEVDs

Compute GFEVDs for all models
ComputeGIRFs

Compute GIRFs for all models
CheckInputsGVAR

Check consistency of the inputs provided in GVARinputs
ComputeFEVDs

Compute FEVDs for all models
ComputeBounds_IRFandGIRF

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

Compute the expected component for all models
EstimationSigma_GVARrest

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

Get the expected component of all models
EstimationSigma_Ye

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

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

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

FEVDs and GFEVDs for all models
FEVDandGFEVD_BS

FEVDs and GFEVDs after bootstrap for all models
Est_RestOLS

Estimate a restricted OLS model
DomMacro

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

Compute the Feedback matrix of each bootstrap draw
Est_K1h

Estimate K1h
FactorBounds_FEVDandGFEVD

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

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

Compute the confidence bounds for the model P-dynamics
FEVDandGFEVDgraphs

FEVD and GFEVD graphs for all models
FacQuantile_bs

Compute quantiles for model P-dynamics
Fitgraphs

Model fit graphs for all models
FEVDandGFEVDs_Graphs

Generates graphs for FEVDs and GFEVDs
ForecastYields

Generates forecasts of bond yields for all model types
FeedMat_M

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

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

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

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

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

Create folders for storing IRFs and GIRFs
Fit_Subplot

Build subplot for fitted yields
FolderPrep_FEVDs

Create folders for storing IRFs and GIRFs
ForwardPremia

Compute the forward premia for all models
FolderCreationPoint

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

Creates folder to store graphs generated from the bootstrap analysis
GVAR

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

Prepare risk factors for the estimation of the GVAR model
Gather_Forecasts

Gather several forecast dates
GaussianDensity

computes the density function of a gaussian process
Gen_art_series

Simulate N_Boot dataset from the P-dynamics
Gen_Artificial_Series

Generate artificial time-series in the bootstrap setup
GVARFactors

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

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

Gathers the general inputs for model estimation
GetPdynPara

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

Compute the B matrix of loadings
GetPdynPara_BC

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

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

Use function ML to generate the outputs from a ATSM
Gen_Forecast_Yields

Compute the bond yield forecast for any model type
GetLabels_JLL

Generate the variable labels of the JLL models
Get_As

Compute the A loadings
GetAuxPara

Compute the auxiliary parameters a.
GetYields_AllCountries

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

Compute P-dynamics parameters without using the bias correction method from BRW (2012)
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_Gy1

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

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

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

Compute Sigmas/Cholesky factorizations
Get__BnXAnX

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

Obtain the country-specific a0
Get_Bs

Build the B loadings
Get_FeedMat_NoBC

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

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

Compute the log-likelihood function
IDXZeroRestrictionsJLLVarCovOrtho

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

Get delta t
IRFandGIRF

IRFs and GIRFs for all models
IRFandGIRF_BS

IRFs and GIRFs after bootstrap for all models
GlobalMacro_covid

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

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

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

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

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

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

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

IRF and GIRF graphs for all models
GlobalMacro

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

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

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

Find the indexes of the spanned factors
ImposeStat_Aux

Impose stationary constraint under the risk-neutral measure
IRFandGIRFs_Format_Fac

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

Generates the labels for risk factors used in the model
InputsForOutputs

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

Estimates the P-dynamics from JLL-based models
JordanMat

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

Fit the cross-section of yields using spline
Jordan_JLL

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

Generate the labels of the spanned factors
Jac_approx

Main Jacobian approximation
InvMat_Robust

Robust method for matrix inversion
K1XQStationary

Impose stationarity under the Q-measure
LoadData

Loads data sets from several papers
MarginalModelPara

Estimate the marginal model for the global factors
ML_stable

Prevents algorithm to end up in ill-defined likelihood
MatAdjusted

Adjust vector of maturities
LabelsStar

Generate the labels of the star variables
Load_Excel_Data

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

Compute the maximum likelihood function of all models
MLFunction

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

Create a vector of numerical maturities in years
MLtemporary

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

Perform out-of-sample forecast of bond yields
Optimization

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

Overview of Datasets Included in the MultiATSM Package
MergeFEVD_graphs

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

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

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

ATSM Package
NoOrthoVAR_JLL

Obtain the non-orthogonalized model parameters
OptOutputs

Prepare outputs to export after the model optimization
NumOutEx

Example of computed numerical outputs
OrthoReg_JLL

Get coefficients from the orthogonalized regressions
Optimization_PE

Perform the minimization of ML function
Outputs2exportMLE

Prepares inputs to export
OptimizationSetup_ATSM

Optimization routine for the entire selected ATSM
OutputConstruction

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

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

Spanned and unspanned factors plot
ParaSetEx

Example of parameter set after optimization
Out_Example

Complete list of several outputs from an ATSM
ResampleResiduals_BS

Compute the residuals from the original model
ParaLabelsOpt

Create the variable labels used in the estimation
RiskFactorsPrep

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

Exclude series that contain NAs
PdynResid_BS

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

Rotate latent states to observed ones
RMSE

Compute the root mean square error for all models
Reg_demean

Perform a linear regression using demeaned variables
TPDecompGraph

Term Premia decomposition graphs for all models
RootEigen

Compute the root of the eigenvalue of K1h
SpecificMLEInputs

Concatenate the model-specific inputs in a list
Optimization_Time

Compute the time elapsed in the numerical optimization
Transition_Matrix

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

Computes the country-specific spanned factors
RiskFacFull

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

Compute the star variables with time-varying weights
TermPremiaDecomp

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

Stochastic approximation algorithm
TermPremia

Compute the term premia
TradeFlows

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

Estimates a standard VAR(1)
Update_SSZ_JLL

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

Transformation of a PSD matrix (true form)
True_Jordan

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

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

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

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

Estimate a VARX(1,1,1)
True_BlockDiag

Transformation of the block diagonal parameters (true form)
True_jordan_OneCountry

True function for a single-country specification
Update_ParaList

Update parameters in the optimization process
YieldQuantile_bs

Compute quantiles for model bond yield-related outputs
Y_ModImp

Model-implied yields (P-dynamics)
Y_Fit

Model-implied yields (cross-section)
YieldBounds_FEVDandGFEVD

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

Compile the bond yield forecast for any model type
WishGraphs_FEVDandGFEVD_Boot

Extract graphs of interest (bootstrap version)
Wished_Graphs_FEVDandGFEVD

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

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

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

Extract graphs of interest (bootstrap version)
clean_labels

Modify variable labels to make legends more readable
autoplot

Autoplot generic function
autoplot.ATSMNumOutputs

Autoplot method for ATSMNumOutputs objects
autoplot.ATSMModelBoot

Autoplot method for ATSMModelBoot objects
Yields_covid

Data: Yields - Candelon and Moura (2023)
adjust_delta

Adjust delta for numerical differentiation
check_numeric

Check for presence of NAs and infinite in numeric variables
YieldsFit

Computes two measures of model fit for bond yields (all models)
print.ATSMModelInputs

Print method for ATSMModelInputs objects
plot.ATSMModelForecast

Plot method for ATSMModelForecast objects
Yields

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

Computes the PCA weights for a single country
summary.ATSMModelInputs

Summary method for ATSMModelInputs objects
summary.ATSMModelOutputs

Summary method for ATSMModelOutputs objects
residY_original

Compute the residuals from the observational equation
safe_solve

Safe matrix inversion with conditioning check
llk_JLL_Sigma

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

Shrinking the largest eigenvalue
scaling_from_jacobian

Scaling vector computation
pos_map

Exponential transformation
YieldsFitAll

Fit yields for all maturities of interest
withDefault

Check default value
richardson_diff

Richardson extrapolation
rhoParas

Compute risk-neutral intercept and slope