Matlab Toolbox for Transmission Channel Analysis – Advanced
The Matlab Toolbox for Transmission Channel Analysis provides functions for TCA in Matlab. It is as general as the Julia version and can thus, equally well, handle all kinds of transmission channels. In developing the two packages, we tried to keep the naming conventions as close as possible, with names only being brought into their respective coding styles (Camel Case for Matlab, Snake Case for Julia). Thus, users should find it hopefully easy to use examples and help that are not originally written for Matlab and still be able to apply it in Matlab. Nonetheless, the examples section provides detailed examples using the Matlab toolbox.
The rest of this documentation gives an overview of the key functions in the toolbox. We start with simple transmission channels, how they can be defined, and how they can be computed. We then become more and more general and introduce the more advanced methods within the toolbox. These advanced methods allow for the computation of any possible transmission channel.
Contributer Information
For interested contributers or others interested in the internals of the toolbox please have a look at the explanation of the internals.
Defining Simple Transmission Channels
Two helper functions are provided that allow for the definition of transmission channels without having to use the more advanced methods. These are through and notThrough. As the names hint at, through is used to define a channel that must go through certain variables in certain periods, while notThrough is used to define a transmission channel that cannot go through certain variables in all defined periods.
through
through Construct a transmission condition enforcing paths through specific variables.
q = through(idx, horizons, order) creates a transmission condition Q where paths must pass through the variables specified in idx. The variable indices refer to their positions in the original dynamic system (e.g., in the SVARMA model), before applying the transmission matrix.
Arguments
For a single variable:
idx (integer): Index of the variable that paths must go through, using its original index in the dynamic system (before transmission ordering).
horizons (vector of integers): Time horizons at which the paths must pass through the variable.
order (vector of integers): Variable ordering determined by the transmission matrix.
For multiple variables:
idx (vector of integers): Indices of the variables that paths must go through, using their original indices in the dynamic system.
horizons (cell array of vectors or vector of integer): If a single vector of integers is provided, then it will be applied to each idx. Alternatively, a cell array of integer vectors can be provided in which case each element in the cell array applies to the respective element in idx.
order (vector of integers): Variable ordering determined by the transmission matrix.
Returns
q (Q): A transmission condition.
Notes
The resulting transmission condition can be used in transmission to compute the transmission effect.
Example
% Contemporaneous channel (Section 5.1 in Wegner)contemporaneous_channel=through(1, [0],1:4);% Effect through the federal funds rate in the first two periodsq=through(1, [0,1],1:4);% Effect through both the federal funds rate and output gapq=through([1,2], {[0,1], [0,1]},1:4);% Adjusting for a re-ordered system where the output gap comes firstq=through([1,2], {[0,1], [0,1]}, [2,1,3,4]);
See also notThrough, transmission
notThrough
notThrough Construct a transmission condition excluding specific variables from the channel.
q = notThrough(idx, horizons, order) creates a transmission condition Q where paths cannot pass through specified variables at given time horizons. The variable indices refer to their positions in the original dynamic system (e.g., in the SVARMA model), before applying the transmission matrix.
Arguments
For a single variable:
idx (integer): Index of the variable that paths cannot go through, using its original index in the dynamic system (before transmission ordering).
horizons (vector of integers): Time horizons at which the paths cannot pass through the variable.
order (vector of integers): Variable ordering determined by the transmission matrix.
For multiple variables:
idx (vector of integers): Indices of the variables that paths cannot go through, using their original indices in the dynamic system.
horizons (cell array of vectors or vector of integer): If a single vector of integers is provided, then it will be applied to each idx. Alternatively, a cell array of integer vectors can be provided in which case each element in the cell array applies to the respective element in idx.
order (vector of integers): Variable ordering determined by the transmission matrix.
Returns
q (Q): A transmission condition.
Notes
The resulting transmission condition can be used in transmission to compute the transmission effect.
Example
% Non-contemporaneous monetary policy channel (Section 5.1 in Wegner etal 2024)q=notThrough(1, [0],1:4);% Anticipation channel of government defense spending (Section 5.2 in Wegner etal 2024)q=notThrough(2,0:20,1:4);
See also through, transmission
Both through and notThrough return a transmission condition Q, which is simply an internal representation of the provided transmission channel (represented as Boolean statements). To double check whether the condition represents the desired channel, simply display the resulting transmission condition using disp. The displayed version uses the systems form and thus uses the variable notation \(x\). Alternatively, disp can be called with an additional agrguments, defining the ordering of the transmission matrix. If two arguments are provided, disp will display the transmission condition using the dynamic form – using the variable notation y_{i,t} with i being the variable index before applying the transmission matrix, and t is the time period with t=0 corresponding to the contemporaneous period.
Q.disp
disp Display a transmission condition in either systems form or dynamic form.
disp(q) displays the transmission condition using the systems form notation.
disp(q, order) displays the transmission condition using the dynamic form notation, where order is the variable ordering defined by the transmission matrix.
Arguments
q (Q): A transmission condition.
order (vector of integers, optional): The variable ordering defined by the transmission matrix. If provided, the condition is displayed using the dynamic form notation.
Example
q=makeCondition("x1 | x2");disp(q);% Displays condition in systems form.order= [3,1,2];disp(q,order);% Displays condition in dynamic form.
Advanced Usage of through and notThrough
Conditions created using through and notThrough can be combined using AND (&), OR (|) and NOT (~)1. Every new combination will return a new condition that combines the previous conditions. The returned conditions can again be combined using AND, OR, and NOT. For example, if q1, q2 and q3 are conditions obtained using through or notThrough, then the following works.
This functionality allows definitions of transmission channels that are not easily defined using through and notThrough. For example, if we were interested in the transmission channel that goes through \(y_{1,0}\) OR through \(y_{1,1}\), then neither of the helper functions can be used, since neither can handle OR statements. However, we can use Boolean logic and the rules for the manipulation of transmission conditions to define this transmission channel using our helper functions.
In most cases, the easiest step is to negate the original condition. The above condition can be succinctly be represented as \[
y_{1,0} \lor y_{1,1}.
\] The negated statement is thus \[
\neg y_{1,0} \land \neg y_{1,1}.
\] This can be defined using notThrough in the following way
q=notThrough(1, [0,1],1:n);
where we assumed that the transmission matrix is the identity matrix, implying an ordering 1:n.
To obtain the original transmission channel, we can simply negate this condition.
originalCondition=~q;
Defining Complex Transmission Channels
Although through and notThrough are sufficient for many situations, it is still sometimes more convenient to directly define the transmission channel as a Boolean condition withough having to refer back to through and notThrough.
Say, for example, we are again interested in the transmission channel going through y_{1,0} OR y_{1,1}. Instead of using the approach of first negating the statement, then using notThrough, just to negate this statement again, we may as well just define the condition directly using the more advanced functionality of the toolbox.
The advanced functionality simply takes a String that defines the transmission channel as a Boolean condition. The string can either be defined using the variables of the dynamic form\(y\) or the variables using the systems form\(x\). In the former case, the ordering defined by the transmission matrix must also be defined. makeConditionY and makeCondition handle these two cases respectively.
makeConditionY
makeConditionY Create a transmission condition from a Boolean string using dyanmic form variables.
q = makeConditionY(strY, order) constructs a transmission condition \(Q(b)\) from a Boolean statement specified in terms of dynamic system variables (i.e., y_{i,t} notation).
Arguments
strY (string): A Boolean condition string where variables are represented as y_{i,t}, with i as the variable index and t >= 0 as the time period. t=0 corresponds to the contemporaneous horizon.
order (vector of integers): The variable ordering defined by the transmission matrix.
Boolean conditions can include AND (&), NOT (! or ~), OR (|), and parentheses.
The resulting transmission condition can be used in transmission to calculate the transmission effect.
See also transmission, makeCondition
makeCondition
makeCondition Create a transmission condition from a Boolean string.
q = makeCondition(s) constructs a transmission condition \(Q(b)\) from a Boolean statement given as a string. The Boolean expression should use variables of the systems form x<num>, where <num> represents a variable index.
Arguments
s (string): A Boolean condition string where variables must be represented using x<num>.
Returns
q (Q): A transmission condition.
Example
s="x2 & !x3";cond=makeCondition(s);
Notes
Boolean conditions can include AND (&), NOT (! or ~), OR (|), and parentheses.
The resulting transmission condition can be used in transmission to calculate the transmission effect.
See also transmission, makeConditionY
So, to define the transmission channel that goes through \(y_{1,0}\) OR through \(y_{1,1}\) with an identity transmission matrix, we can do either of the following.
% Note, we assume 4 variables in the system. q=makeConditionY("y_{1,0} | y_{1,1}",1:4);% With an identity transmission matrix, y_{1,0} -> x1% and y_{1,1} -> x5.q=makeCondition("x1 | x5");
Computing Transmission Effects
Transmission effects, i.e. the effect through the transmission channel, can be computed in one of two ways. The first way is to use the systems form to compute the transmission effect. The second way exploits the sufficiency of impulse response functions (IRFs)2 and uses these to compute the effects. The following sections describe both methods.
Preparing the Systems Form
The systems form can be used whenever a SVAR(MA) was estimated and the AR and MA coefficients are available. The first step then consists of transforming the dynamic form of the SVAR(MA) into the systems form. We provide the utility function makeSystemsForm for this purpose.
makeSystemsForm
makeSystemsForm Transform an SVARMA dynamic model into the system representation \(x = Bx + \Omega\varepsilon\).
Arguments
Phi0 (matrix): The matrix of contemporaneous structural impulse responses.
As (cell array of matrices): A vector of reduced-form autoregressive (AR) matrices, where the first entry corresponds to the AR matrix for the first lag, etc.
Psis (cell array of matrices): A vector of reduced-form moving average (MA) matrices, where the first entry corresponds to the MA matrix for the first lag, etc.
order (vector): The vector of intergers indicating the order of variables, typically determined by the transmission matrix.
maxHorizon (integer): The maximum time horizon to consider for the systems form, with 0 representing the contemporaneous period.
Returns
B (matrix)
Omega (matrix)
See also makeB, makeOmega.
The returned systems form can then be used in transmission to compute the trasnmission effect.
Besides makeSystemsForm we also offer the two separate functions makeB and makeOmega which respectively create \(B\) and \(\Omega\) of the systems form. Use of these two functions should most of the time not be required. However, for users that might want to extend TCA, having access to these two methods seperately can be helpful.
makeB
makeB Construct the matrix B in the system representation \(x = Bx + \Omega\varepsilon\).
Arguments
As (cell array of matrices): Autoregressive coefficient matrices.
Sigma (matrix): Covariance matrix of the shocks.
order (vector): Ordering of variables given by the transmission matrix.
maxHorizon (integer): Maximum IRF horizon.
Returns
B (matrix): Part of the sytems representation.
See also makeOmega, makeSystemsForm
makeOmega
makeOmega Construct the Omega matrix in the system representation \(x = Bx + \Omega\varepsilon\).
Arguments
Phi0 (matrix): Impact matrix for the shocks.
Psis (cell array of matrices): MA terms for the dynamic model.
order (vector): Ordering of variables.
maxHorizon (integer): Maximum IRF horizon.
Returns
Omega (matrix): Part of the systems form.
See also makeB, makeSystemsForm
Preparing the IRFs
Estimating the transmission effects using IRFs requires Cholesky / orthogonalised IRFs for all variables, as well as the structural shock’s impulse response functions. In either case, the toolbox works internally with a matrix representation of IRFs. Since many software solutions for SVAR(MA) return IRFs in the form of three-dimensional arrays, we provide the utility function toTransmissionIrfs that transforms the three-dimensional arrays into a matrix of IRFs.
toTransmissionIrfs
toTransmissionIrfs Transform a standard 3D IRF array into a 2D IRF matrix.
irfs = toTransmissionIrfs(irfs) converts an impulse response function (IRF) array of dimensions (n_variables × n_shocks × n_horizons) into a 2D matrix. The first horizon in the input corresponds to horizon 0.
Arguments: - irfs (3D array): An IRF array of size (n_variables × n_shocks × n_horizons), where: - n_variables is the number of variables, - n_shocks is the number of shocks, - n_horizons is the number of forecast horizons.
Returns
irfs (2D matrix): A transformed IRF matrix of size (n_variables * n_horizons) × (n_variables * n_horizons). This is equivalent to computing \((I - B)^{-1}Q\) using the systems form.
Example
irfs3D=rand(4,2,10);% Example 3D IRF array with 4 variables, 2 shocks, and 10 horizonsirfs2D=toTransmissionIrfs(irfs3D);
Notes
The first n_shocks column of the returned matrix are simply the standard slices of the IRF 3D-array stacked vertically. The next n_shocks columns follow the same principle, but with the first n_variables columns being zero because the shocks are time t shocks which cannot affect time t-1 variables.
toTransmissionIrfs should be applied to both the Cholesky / orthogonalised and the structural IRFs. The resulting IRFs can then be used in transmission to compute the transmission effects.
Computing
With either the IRFs or the systems form prepared, transmission effects can be computed using any of the following versions of the transmission function. In either case, the fourth argument to transmission must be a transmission condition that can be obtained in any of the ways described above.
To compute transmission effects using the systems form, method should be set equal to "BOmega". Similarly, to use IRFs, method should be set equal to "irfs".
transmission
transmission Compute the transmission effect given a transmission condition.
effects = transmission(from, arr1, arr2, q, method) calculates the transmission effect for a given transmission condition q using either the BOmega method or the irf method. If BOmega is used, then transmission effects will be calculated using the systems form \(x = Bx + \Omega\varepsilon\)
Arguments
from (integer): Index of the shock.
arr1 (matrix):
If method = "BOmega", this must be B from the systems form.
If method = "irf", this must be structural irfs (technically only those of the shock that is being investigates (from)). Has to be a IRF matrix. See toTransmissionIrfs for more information.
arr2 (matrix):
If method = "BOmega", this must be Omega from the systems form.
If method = "irf", this must be irfsOrtho (Cholesky IRFs) following the ordering of the transmission matrix.
q (Q): A transmission condition. See also Q.
method (string): Specifies the calculation method:
"BOmega" uses the systems form.
"irf" uses only IRFs and can thus be used with local projections.
order (vector, optional): variable ordering as defined by the transmission matrix.
Returns:
effects (vector): A vector where entry i corresponds to the transmission effect on variable x_i. If x_k is the variable in the transmission condition with the highest index, all entries in the returned vector with index less than k are NaN, since interpretation of those results is nonsensical.
If method = "BOmega", the function applies transmissionBOmega.
If method = "irf", the function applies transmissionIrfs.
If order is provided, the returned effects will be a 3D array of dimension (nVariables, 1, horizons) where the variables are in the original ordering (before applying the transmission matrix).
If order is not provided, the returned effects will be a (nVariable*horizons, 1) dimensional vector following the ordering after applying the transmission matrix. This is similar to the matrix obtained via \((I - B)^{-1}\Omega\) using the matrices from the systems form.
See also transmissionBOmega, transmissionIrfs, makeCondition, through, notThrough
It may occur that a transmission condition contains a contradiction, i.e. a part of the boolean conditions says \(x_i \land \neg x_i\). These are usually automatically removed internally. However, this automatic removal can sometimes lengthen the time it takes for the condition to compile. We therefore offer the possibility not to remove contradictions. To set this alternative option, use setRemoveContradiction. Even if contradictions are not removed, the resulting transmission effect will be correct, but the computation may take a bit longer. Thus, there is a trade-off between longer compile times (if contradictions are being removed) and longer computing time (if contradictions are not removed).
setRemoveContradictions
setRemoveContradictions Set the global flag for removing contradictions in transmission conditions.
setRemoveContradictions(bool) controls whether contradictions in transmission conditions are removed when calling setRemoveContradictions.
Arguments
bool (logical): If true, contradictions of the form “x_i & !x_i” will be removed from transmission conditions. If false, contradictions will not be removed.
removeContradictions Remove contradicting terms from a transmission condition.
q = removeContradictions(q) removes terms that contain contradictions of the form x_i & !x_i, which always evaluate to false and contribute zero to the transmission effect. Behaviour of the function can be changed by setting REMOVECONTRADICTIONS=false locally.
Arguments: - q (Q): A transmission condition. See also Q and makeCondition.
Returns: - If REMOVECONTRADICTIONS is set to false, the input q is returned unchanged. - If REMOVECONTRADICTIONS is true or not set: 1. If all terms are contradicting, Q("T", 0) is returned, which represents a transmission effect of zero. 2. If some terms are non-contradicting, only the non-contradicting terms are retained in the output.
Example
setRemoveContradictions(true);% on by defaultq=Q('x1',1);q=removeContradictions(q);% Returns q unchanged (no contradictions).q=Q('x1 & !x1',1);q=removeContradictions(q);% Returns Q('T', 0).q=Q({'x1 & !x1','x1 & x2'}, [1,1]);q=removeContradictions(q);% Returns Q('x2 & x1', 1).setRemoveContradictions(false);q=Q('x1 & !x1',1);q=removeContradictions(q);% Returns the original q.
Notes
If REMOVECONTRADICTIONS is not explicitly set, contradictions are removed by default.
References
Wegner, Enrico, Lenard Lieb, Stephan Smeekes, and Ines Wilms. 2025. “Transmission Channel Analysis in Dynamic Models.” 2025. https://doi.org/10.48550/arxiv.2405.18987.
Footnotes
Note that ~ and ! are both notation for NOT. Matlab uses ~, however we will use these interchangably. If makeCondition use used, either will work. However, if two condition are being combined, only ~ will work, since ! is not defined in Matlab.↩︎