Learn R Programming

⚠️There's a newer version (1.3.1) of this package.Take me there.

MultiATSM (version 1.0.0)

Multicountry Term Structure of Interest Rates Models

Description

Estimation routines for several classes of affine term structure of interest rates models. All the models are based on the single-country unspanned macroeconomic risk framework from Joslin, Priebsch, and Singleton (2014, JF) . Multicountry extensions such as the ones of Jotikasthira, Le, and Lundblad (2015, JFE) , Candelon and Moura (2023, EM) , and Candelon and Moura (Forthcoming, JFEC) are also available.

Copy Link

Version

Install

install.packages('MultiATSM')

Monthly Downloads

324

Version

1.0.0

License

GPL-2 | GPL-3

Maintainer

Rubens Moura

Last Published

October 15th, 2024

Functions in MultiATSM (1.0.0)

Check_comparison__OLS

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

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

Check consistency of the inputs provided in GVARinputs
BuildATSM_RiskFactors

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

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

Build country-specific link matrices
Check_label_consistency

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

Check consistence of inputs
CleanOrthoJLL_Boot

Clean unnecessary outputs of JLL models in the bootstrap setup
DomMacro

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

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

Compute the latent loading AnX and BnX
CheckJLLinputs

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

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

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

Convert a generic matrix to its Jordan form
EstimationSigma_Ye

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

FEVDs after bootstrap for "joint Q" models
FEVDandGFEVDbs_sepQ

Creates the confidence bounds and the graphs of FEVDs and GFEVDs after bootstrap ("sep Q" models)
DatabasePrep

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

FEVDs graphs for orthogonalized risk factors of JLL-based models
FEVDjointOrthogoJLL_BS

FEVDs after bootstrap for JLL-based models
FF

mean of the llk function used in the estimation of the selected ATSM
ChecksOOS

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

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

FEVDs for "joint Q" models
FFtemporary

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

Generates forecasts of bond yields for all model types
Functionf

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

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

GFEVDs graphs for orthogonalized risk factors of JLL-based models
FMN__Rotate

Performs state rotations
FEVDjointOrthogoJLL

Orthogonalized FEVDs for JLL models
FactorsGVAR

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

FEVDs after bootstrap for "sep Q" models
FitgraphsSep

Model fit graphs for ("sep Q" models)
FEVDgraphsJoint

FEVDs graphs for ("joint Q" models)
FolderCreationBoot

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

FEVDs for "sep Q" models
GFEVDjointOrthoJLL_BS

GFEVDs after bootstrap for JLL-based models
FEVDandGFEVDbs_jointQ_Ortho

Creates the confidence bounds and the graphs of FEVDs and GFEVDs after bootstrap (JLL-based models)
GFEVDjoint_BS

GFEVDs after bootstrap for "joint Q" models
FEVDandGFEVDbs_jointQ

Creates the confidence bounds and the graphs of FEVDs and GFEVDs after bootstrap ("joint Q" models)
DomesticMacroVar

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

GIRFs graphs for orthogonalized risk factors of JLL-based models
Gen_Artificial_Series

Generate artificial time-series in the bootstrap setup
GaussianDensity

computes the density function of a gaussian process
GIRFjointOrthoJLL

Orthogonalized GIRFs for JLL models
GIRFgraphsJoint

GIRFs graphs for ("joint Q" models)
Factors_NonOrtho

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

Compute the Feedback matrix of each bootstrap draw
GetLabels_JLL

Generate the variable labels of the JLL models
GFEVDsep_BS

GFEVDs after bootstrap for "sep Q" models
GIRFgraphsSep

GIRFs graphs for ("sep Q" models)
GetLabels_sepQ

Generate the factor labels for models estimated on a country-by-country bases
GFEVDsep

GFEVDs for "sep Q" models
GFEVDgraphsSep

GFEVDs graphs for ("sep Q" models)
GFEVDgraphsJoint

GFEVDs graphs for "joint Q" models
GIRFjointOrthoJLL_BS

GIRFs after bootstrap for JLL-based models
Get_Bs

BUild the B loadings
GetPdynPara_NoBC

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

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

FEVDs graphs for ("sep Q" models)
IRFandGIRFbs_jointQ_Ortho

Creates the confidence bounds and the graphs of IRFs and GIRFs after bootstrap (JLL-based models)
Get_Sigama_JLL

Compute Sigmas/Cholesky factorizations
GFEVDjointOrthoJLL

Orthogonalized GFEVDs for JLL models
GVAR_PrepFactors

Prepare risk factors for the estimation of the GVAR model
Get_Gy1

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

GFEVDs for "joint Q" models
GIRFSep

GIRFs for "sep Q" models
GVAR

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

Gathers the general inputs for model estimation
FeedbackMatrixRestrictionsJLL

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

GIRFs after bootstrap for "sep Q" models
IRFsep_BS

IRFs after bootstrap for "sep Q" models
IRFandGIRFbs_sepQ

Creates the confidence bounds and the graphs of IRFs and GIRFs after bootstrap ("sep Q" models)
Gen_Forecast_Yields

compute the bond yield forecast for any model type
FitgraphsJoint

Model fit graphs for ("joint Q" models)
GIRFjoint

GIRFs for "joint Q" models
GIRFjoint_BS

GIRFs after bootstrap for "joint Q" models
IRFgraphsJoint

IRFs graphs for ("joint Q" models)
IRFgraphsJLLOrtho

IRFs graphs for orthogonalized risk factors of JLL-based models
IdxAllSpanned

Find the indexes of the spanned factors
MarginalModelPara

Estimate the marginal model for the global factors
Getdt

Get delta t
IRFjoint

IRFs for "joint Q" models
Get_G0G1Sigma

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

Compute the maximum likelihood function of all models
LabFac

Generates the labels factors
IRFgraphsSep

IRFs graphs for ("sep Q" models)
LabelsSpanned

Generate the labels of the spanned factors
InputsForOpt

Generates several inputs that are necessary to build the likelihood function
GetPdynPara

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

Data: Risk Factors - Candelon and Moura (2023)
Idx_UnspanFact

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

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

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

Gather several forecast dates
OptOutputs

Prepare outputs to export after the model optimization
OOS_Forecast

Perform out-of-sample forecast of bond yields
Get_BFull

Compute the B matrix of loadings
MultiATSM

ATSM Package
NoOrthoVAR_JLL

Obtain the non-orthogonalized model parameters
Reg_K1Q

Estimate the risk-neutral feedbak matrix K1Q using linear regressions
RMSEsep

Compute the root mean square error ("sep Q" models)
OrthoVAR_JLL

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

Compute the A loadings
OutputConstructionJoint

Numerical outputs (variance explained, model fit, IRFs, GIRFs, FEVDs, GFEVDs and risk premia decomposition) for "joint Q" models
Get_r0

Compute r0 for the various models
IRFjointOrthoJLL_BS

IRFs after bootstrap for JLL-based models
Get_llk

Compute the log-likelihood function
IRFjointOrthoJLL

Orthogonalized IRFs for JLL models
Get_SigmaYields

Compute the variance-covariance matrix of the bond yields
Get_Unspanned

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

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

Term Premia decomposition graphs for "joint Q" models
JLL

Estimates the P-dynamics from JLL-based models
Optimization

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

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

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

Impose stationarity under the Q-measure
TermPremiaDecompJoint

Decomposition of yields into the average of expected future short-term interest rate and risk premia for "joint Q" models
LoadData

Loads data sets from several papers
NumOutputs

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

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

Peform the minimization of mean(f)
Yields

Data: Yields - Candelon and Moura (forthcoming, JFEC)
LabelsStar

Generate the labels of the star variables
StarFactors

Generates the star variables necessary for the GVAR estimation
YieldsFitAllJoint

Fit yields for all maturities of interest
IDXZeroRestrictionsJLLVarCovOrtho

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

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

Obtain the country-specific a0
bound2x

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

Eliminates the @
llk_JLL_Sigma

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

Numerical outputs (variance explained, model fit, IRFs, GIRFs, FEVDs, GFEVDs, and risk premia decomposition) for "sep Q" models
sqrtm_robust

Compute the square root of a matrix
contain

Check whether one element is a subset of another element
OutputConstructionJoint_BS

Gathers all the model numerical ouputs after bootstrap for "joint Q" models
true2aux

Map constrained parameters b to unconstrained auxiliary parameters a.
ParaATSM_opt_ALL

Update the list of parameters
ParaLabelsOpt

Create the variable labels used in the estimation
OptimizationSetup_ATSM

Optimization routine for the entire selected ATSM
RiskFactorsPrep

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

Spanned and unspanned factors plot
Reg__OLSconstrained

Restricted OLS regression
VAR

Estimates a standard VAR(1)
Update_SSZ_JLL

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

Term Premia decomposition graphs for "joint Q" models
YieldsFitsep

Computes two measures of model fit for bond yields
TermPremiaDecompSep

Decomposition of yields into the average of expected future short-term interest rate and risk premia for "joint Q" models
TradeFlows

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

Percentage explained by the spanned factors of the variations in the set of observed yields for "sep Q" models
RemoveNA

Exclude series that contain NAs
mult__prod

Efficient computation of matrix product for arrays
YieldFor

Compile the bond yield forecast for any model type
residY_original

Compute the residuals from the observational equation
estVARbrw

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

Computes numerical first order derivative of f(x)
IRFandGIRFbs_jointQ

Creates the confidence bounds and the graphs of IRFs and GIRFs after bootstrap ("joint Q" models)
logdet

computes the logarithm of determinant of a matrix A
aux2true

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

IRFs after bootstrap for "joint Q" models
m_var

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

computes matrix product for arrays a and b: c[,,i] = a[,,i] b[,,i]
mult__inv

Inverts an array of matrices so that: inva[,,i] = inv(a[,,i])
mult_logabsdet

Inverse each 2D slice of an array (M) with arbitrary dimensions support
getpara

Extract the parameter values from varargin
shrink_Phi

Killan's VAR stationarity adjustment
IRFsep

IRFs for "sep Q" models
YieldsFitJoint

Computes two measures of model fit for bond yields
getx

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

Fit yields for all maturities of interest
OutputConstructionSep_BS

Gathers all the model numerical ouputs after bootstrap for "sep Q" models
Maturities

Create a vector of numerical maturities in years
Outputs2exportMLE

Prepares inputs to export
pca_weights_one_country

Weight matrix from principal components
ModelPara

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

Get coefficients from the orthogonalized regressions
pos2x

Transform a positive number y to back to x by:
PdynResid_BS

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

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

Concatenate the model-specific inputs in a list
VARX

Estimate a VARX(1,1,1)
SpannedFactorsSepQ

Gather all spanned factors ("sep Q" models)
ResampleResiduals_BS

Compute the residuals from the original model
Spanned_Factors

Computes the country-specific spanned factors
SpannedFactorsjointQ

Gather all spanned factors ("joint Q" models)
RiskFactors

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

Data: Trade Flows - Candelon and Moura (2023)
f_with_vectorized_parameters

Use function f to generate the outputs from a ATSM
RMSEjoint

Compute the root mean square error ("joint Q" models)
x2pos

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

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

Generate M data sets from VAR(1) model
VarianceExplainedJoint

Percentage explained by the spanned factors of the variations in the set of observed yields for "joint Q" models
mult_inv_small

Inverse the (m,m,T) array of matrices for m<=4
mult_inv_large

Inverse each 2D slice of an array (M) with arbitrary dimensions support
update_para

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

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

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

Generates the bootstrap-related outputs
BUnspannedAdapSep

Transform B_spanned into B_unspanned for sepQ models
BUnspannedAdapSep_BS

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

Builds the confidence bounds and graphs (Bootstrap set)
AdjustYieldsDates

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

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

Transform B_spanned into B_unspanned for jointQ models
AdjustOptm_BS

Gathers the estimate of the bootstrap draws
BR_jps_out

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