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 paper published in the R Journal.

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.

  • Moura, R (2025). MultiATSM: An R Package for Arbitrage-Free Macrofinance Multicountry Affine Term Structure Models. The R Journal, 17(4), 275-304.

  • See also the references in the package documentation.

Copy Link

Version

Install

install.packages('MultiATSM')

Monthly Downloads

269

Version

1.5.1-1

License

GPL-2 | GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Rubens Moura

Last Published

February 26th, 2026

Functions in MultiATSM (1.5.1-1)

Boot_DataGraphFact_perShock

Generates the desired bootstrap graphs
Bias_Correc_VAR

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

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

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

Transform B_spanned into B_unspanned for jointQ models
BuildCI_Yields

Build Confidence intervals for yield-related outputs
Boot_DataGraphYield_perShock

Generates the desired bootstrap graphs
BuildATSM_RiskFactors

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

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

Builds template from bootstrap-related graphs
BUnspannedAdapSep

Transform B_spanned into B_unspanned for sepQ models
Boot_Fac_Graphs

Build P-dynamic graphs after the bootstrap implementation
Boot_Yields_Graphs

Build P-dynamic graphs after the bootstrap implementation
Bootstrap

Generates the bootstrap-related outputs
BR_jps_out

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

Check consistence of inputs
BuildGVAR

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

Check Numerical Precision Issues of K1_root matrix
BootstrapBoundsSet

Builds the confidence bounds and graphs (Bootstrap set)
Check_comparison_NoBC

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

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

Clean unnecessary outputs of JLL models in the bootstrap setup
BuildLinkMat

Build country-specific link matrices
BuildYields_BS

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

Input validation for the 'FeedMat_Q' function
CheckInputsGVAR

Check consistency of the inputs provided in GVARinputs
CholRestrictionsJLL

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

Compute the expected component for all models
CheckJLLinputs

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

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

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

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

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

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

Compute GFEVDs for all models
ComputeFEVDs

Compute FEVDs for all models
Compute_BnX_AnX

Compute the latent loading AnX and BnX
ComputeIRFs

Compute IRFs of all models
ComputeGIRFs

Compute GIRFs for all models
DatabasePrep

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

Estimate K1h
Est_RestOLS

Estimate a restricted OLS model
EstimationSigma_GVARrest

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

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

Compute the Feedback matrix of each bootstrap draw
FolderCreationPoint

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

FEVDs and GFEVDs for all models
FeedMat_Q

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

Generates forecasts of bond yields for all model types
Factors_NonOrtho

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

FEVDs and GFEVDs after bootstrap for all models
EstimationSigma_Ye

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

FEVD and GFEVD graphs for all models
DomMacro

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

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

Model fit graphs for all models
GVAR

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

Create folders for storing IRFs and GIRFs
GetAuxPara

Compute the auxiliary parameters a.
FactorBounds_IRFandGIRF

Compute the confidence bounds for the model P-dynamics
FactorBounds_FEVDandGFEVD

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

computes the density function of a gaussian process
Gather_Forecasts

Gather several forecast dates
FolderPrep_FEVDs

Create folders for storing IRFs and GIRFs
FEVDandGFEVDbs

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

Use function ML to generate the outputs from a ATSM
Fit_Subplot

Build subplot for fitted yields
FolderCreation_Boot

Creates folder to store graphs generated from the bootstrap analysis
ForwardPremia

Compute the forward premia for all models
FeedMat_M

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

Generates graphs for FEVDs and GFEVDs
ExpectedComponent

Get the expected component of all models
FeedbackMatrixRestrictionsJLL

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

Gathers the general inputs for model estimation
Get_SigmaYields

Compute the variance-covariance matrix of the bond yields
Get_SSZ_BC

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

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

Prepare risk factors for the estimation of the GVAR model
FacQuantile_bs

Compute quantiles for model P-dynamics
Gen_Forecast_Yields

Compute the bond yield forecast for any model type
GetLabels_JLL

Generate the variable labels of the JLL models
GetYields_AllCountries

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

Build the B loadings
GVARFactors

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

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

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

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

Simulate N_Boot dataset from the P-dynamics
GetLabels_sepQ

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

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

Generate artificial time-series in the bootstrap setup
Get_FeedMat_NoBC

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

Compute Sigmas/Cholesky factorizations
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
GetPdynPara_NoBC

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

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

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

Compute the A loadings
Get_BFull

Compute the B matrix of loadings
Get_Gy1

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

Obtain the country-specific a0
ImposeStat_Aux

Impose stationary constraint under the risk-neutral measure
GetPdynPara

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

Get delta t
InvMat_Robust

Robust method for matrix inversion
Get_llk

Compute the log-likelihood function
InputsForOutputs

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

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

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

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

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

IRFs and GIRFs after bootstrap for all models
Get_r0

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

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

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

Main Jacobian approximation
IdxSpanned

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

Compute the maximum likelihood function of all models
IdxAllSpanned

Find the indexes of the spanned factors
IRFandGIRFbs

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

IRF and GIRF graphs for all models
JLL

Estimates the P-dynamics from JLL-based models
InpForOutEx

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

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

Fit the cross-section of yields using spline
LabFac

Generates the labels for risk factors used in the model
GraphicalOutputs

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

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

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

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

Generate the labels of the spanned factors
K1XQStationary

Impose stationarity under the Q-measure
MultiATSM

ATSM Package
NumOutputs

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

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

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

Create a vector of numerical maturities in years
MarginalModelPara

Estimate the marginal model for the global factors
MLFunction

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

Perform out-of-sample forecast of bond yields
ML_stable

Prevents algorithm to end up in ill-defined likelihood
LabelsStar

Generate the labels of the star variables
OptOutputs

Prepare outputs to export after the model optimization
LoadData

Loads data sets from several papers
MultiATSM_datasets

Overview of Datasets Included in the MultiATSM Package
NumOutEx

Example of computed numerical outputs
ResampleResiduals_BS

Compute the residuals from the original model
OrthoVAR_JLL

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

Adjust vector of maturities
Outputs2exportMLE

Prepares inputs to export
TermPremia

Compute the term premia
PdynResid_BS

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

Exclude series that contain NAs
OutputConstruction

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

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

Perform a linear regression using demeaned variables
OrthoReg_JLL

Get coefficients from the orthogonalized regressions
Spanned_Factors

Computes the country-specific spanned factors
Out_Example

Complete list of several outputs from an ATSM
Transition_Matrix

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

Estimates a standard VAR(1)
RMSE

Compute the root mean square error for all models
Update_ParaList

Update parameters in the optimization process
SA_algorithm

Stochastic approximation algorithm
TermPremiaDecomp

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

Rotate latent states to observed ones
Optimization_Time

Compute the time elapsed in the numerical optimization
RootEigen

Compute the root of the eigenvalue of K1h
True_jordan_OneCountry

True function for a single-country specification
Update_SSZ_JLL

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

Obtain the non-orthogonalized model parameters
RiskFacFull

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

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

Perform the minimization of ML function
YieldBounds_FEVDandGFEVD

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

Transformation of a PSD matrix (true form)
TimeVarWeights_GVAR

Compute the star variables with time-varying weights
VARX

Estimate a VARX(1,1,1)
True_Jordan

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

Extract graphs of interest (bootstrap version)
OptimizationSetup_ATSM

Optimization routine for the entire selected ATSM
Y_ModImp

Model-implied yields (P-dynamics)
Y_Fit

Model-implied yields (cross-section)
WishGraphs_IRFandGIRF_Boot

Extract graphs of interest (bootstrap version)
RiskFactorsGraphs

Spanned and unspanned factors plot
TradeFlows

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

Autoplot method for ATSMModelBoot objects
YieldBounds_IRFandGIRF

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

Fit yields for all maturities of interest
RiskFactorsPrep

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

Adjust delta for numerical differentiation
ParaLabelsOpt

Create the variable labels used in the estimation
print.ATSMModelInputs

Print method for ATSMModelInputs objects
ParaSetEx

Example of parameter set after optimization
TPDecompGraph

Term Premia decomposition graphs for all models
True_BlockDiag

Transformation of the block diagonal parameters (true form)
Yields_covid

Data: Yields - Candelon and Moura (2023)
residY_original

Compute the residuals from the observational equation
check_numeric

Check for presence of NAs and infinite in numeric variables
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
summary.ATSMModelOutputs

Summary method for ATSMModelOutputs objects
SpecificMLEInputs

Concatenate the model-specific inputs in a list
YieldFor

Compile the bond yield forecast for any model type
True_JLLstruct

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

Modify variable labels to make legends more readable
VarianceExplained

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

Check default value
scaling_from_jacobian

Scaling vector computation
YieldQuantile_bs

Compute quantiles for model bond yield-related outputs
summary.ATSMModelInputs

Summary method for ATSMModelInputs objects
pca_weights_one_country

Computes the PCA weights for a single country
autoplot.ATSMNumOutputs

Autoplot method for ATSMNumOutputs objects
shrink_FeedMat_BC

Shrinking the largest eigenvalue
rhoParas

Compute risk-neutral intercept and slope
richardson_diff

Richardson extrapolation
Wished_Graphs_IRFandGIRF

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

Autoplot generic function
YieldsFit

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

Extract list of desired graph features (IRFs anc GIRFs)
plot.ATSMModelForecast

Plot method for ATSMModelForecast objects
Yields

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

Exponential transformation
Aux_Jordan

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

Transformation of a PSD matrix (auxiliary form)
Aux_jordan_OneCountry

Auxiliary function for a single-country specification
Adjust_Const_Type

Adjust the constant label
AdjustPathIRFs

Generate paths to save IRFs/GIRFs graphs
Aux_JLLstruct

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

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

Transformation of the block diagonal parameters (auxiliary form)
AdjustPathFEVDs

Generate paths to save IRFs/GIRFs graphs
AdjustOptm_BS

Gathers the estimate of the bootstrap draws