Credit shocks
Practicum · Session 09
Prepare the panel
Obtain the exact workbook described in the session README and set MATLAB’s Current Folder to the repository root. The code below executes the preferred replication and its explicitly labelled source-compatible version. It writes generated outputs, not raw data.
% Estimate the preferred four-factor credit-shock FAVAR and its compatibility comparison.
result = run_session(9);
% The preferred panel must have 754 months and 106 observed series.
assert(isequal(size(result.data.Y),[754,106]));
% March 1959 follows the two genuine initial monthly differences.
assert(result.data.periods(1) == 12*1959+2);
% The source-compatible panel retains one extra, metadata-contaminated month.
assert(size(result.classroom.data.Y,1) == 755);
% Inspect which incomplete columns were excluded before standardization.
disp(result.data.excludedNames);An excluded column is not an observation of zero. Nor does dropping incomplete columns create a real-time panel: this selection uses knowledge of the complete vintage. Compare the two transformed samples before looking at the responses.
Reconstruct the common component
% Retain the standardized data, estimated scores, and unit-length loading vectors.
pcaModel = result.pca;
% Four loading vectors must be orthonormal even though their factors are not standardized.
assert(norm(pcaModel.loadings' * pcaModel.loadings-eye(4),'fro') < 1e-10);
% The common plus idiosyncratic components recover every standardized panel observation.
reconstructed = pcaModel.common + pcaModel.idiosyncratic;
% Check the complete matrix, not only an average fit statistic.
assert(max(abs(reconstructed-pcaModel.standardized),[],'all') < 1e-10);
% Report how much standardized panel variance the four components explain.
explainedShare = sum(pcaModel.eigenvalues(1:4)) / sum(pcaModel.eigenvalues);
% Display the sample-specific compression measure without calling it a causal diagnostic.
disp(explainedShare);The measurement regression then augments these scores with the observed spread. Its coefficients are not just the original PCA loadings. Read tsma.factor.favar from the construction of states through measurementBeta to see where the additional observed factor enters.
Read the identified shock
% The stored order links each recursive shock column to an observed identifying variable.
rows = result.identification.identifyingRows;
% The first response slot is impact and the fifth shock is the credit shock.
creditImpact = result.identification.responses(rows,5,1);
% The first four impact responses are restricted to zero, not estimated freely.
assert(max(abs(creditImpact(1:4))) < 1e-8);
% The last diagonal impact is positive under the Cholesky sign convention.
assert(creditImpact(5) > 0);
% Inspect the rate and log-percentage units actually exported for the figure.
disp(unique(result.summary(:,{'variable','units'}),'rows'));Do not interpret a zero in the first four rows as evidence that the restriction is correct. It is a check that the code imposed the stated model. The response paths depend on that ordering, the factor count, the data transformations and the treatment of the pandemic observations.
Worked exercises
Exercises
1. Normalization and reconstruction
For Z=\begin{pmatrix}-1&-1\\0&0\\1&1\end{pmatrix}, find the first loading vector, factor scores, covariance eigenvalue, common component, and idiosyncratic component. Show why the factor does not have unit sample variance under the stated normalization.
Hint: The two columns are identical and each has sample variance one.
2. An observable rotation
Let B_0=\begin{pmatrix}1&2\\3&1\end{pmatrix}. Compute L=\operatorname{chol}(B_0B_0'), solve B_0H=L, and verify that H'H=I. Which impact is restricted to zero by this order?
Hint: The lower Cholesky factor has first column (\sqrt5,\sqrt5)'.
3. Cumulating responses
A response to a second difference is (1,0,0) at horizons zero, one, and two. Calculate the response of the first difference and the level. Repeat for (0.01,-0.002,0) in the first difference of a log series, reporting approximate percentage changes.
Hint: All cumulative sums run over horizons, beginning with impact.
4. A metadata row
A workbook has 756 real monthly observations preceded by one row of transformation codes. The largest transformation is a second difference. Calculate the preferred common-sample size and the size obtained if the metadata row is mistakenly treated as data. Explain why deleting the first two transformed rows does not necessarily remove all contamination.
Hint: A second difference at the second real observation still uses the metadata value two rows earlier.
Normalization and reconstruction
The sample covariance is
\frac{Z'Z}{3-1}=\begin{pmatrix}1&1\\1&1\end{pmatrix}.
Its eigenvalues are two and zero. Choose v_1=(1,1)'/\sqrt2, whose Euclidean norm is one. The first factor is F=Zv_1=(-\sqrt2,0,\sqrt2)'. Its mean is zero and its sample variance is (2+0+2)/2=2, not one.
The common component Fv_1' equals Z exactly, so the idiosyncratic component is the zero matrix. If instead the factor were divided by \sqrt2 to have unit sample variance, its loading vector would need to be multiplied by \sqrt2. Normalization changes coordinates, not the fitted common component, provided both sides of the decomposition change together.
An observable rotation
First,
B_0B_0'=\begin{pmatrix}5&5\\5&10\end{pmatrix},\qquad L=\begin{pmatrix}\sqrt5&0\\\sqrt5&\sqrt5\end{pmatrix}.
Solving the two linear systems B_0h_j=L_{\cdot j} gives
H=\frac1{\sqrt5}\begin{pmatrix}1&2\\2&-1\end{pmatrix}.
Indeed H'H=\frac15\begin{pmatrix}5&0\\0&5\end{pmatrix}=I and B_0H=L. The first observable has zero impact response to the second shock, because L_{12}=0. The second observable may respond immediately to the first shock. Reversing the observable order would impose a different economic restriction, even though each ordering reproduces the same reduced-form covariance.
Cumulating responses
The first cumulative sum of (1,0,0) is (1,1,1), the response of the first difference. The second cumulative sum is (1,2,3), the level response. A one-time acceleration therefore produces a persistent change in growth and a growing level effect under this simple response path.
For the first difference of a log series, one cumulative sum gives (0.01,0.008,0.008). Multiplying by 100 yields approximate percentage responses (1,0.8,0.8). The exact proportional level change is 100[\exp(b_h^{log})-1], approximately (1.0050,0.8032,0.8032) percent. The figure uses the explicitly labelled log approximation, not the exact nonlinear transformation.
A metadata row
The preferred procedure first removes the metadata row, leaving 756 observations. Dropping two unavailable initial differences then gives 756-2=754 usable months. Counting metadata as an observation creates 757 rows, after which dropping two leaves 755.
For real values x_1,x_2 and metadata value m, the erroneous second difference attached to x_2 is x_2-2x_1+m. It survives the deletion of the first two rows because it is in the third row of the augmented array. The valid second difference first exists at x_3, where it equals x_3-2x_2+x_1. Thus the wrong rule introduces both an extra observation and an artificial initial transformed value for second-differenced series. The preferred and compatibility samples must be stored separately.