States and shock size

Practicum · Session 07

Replicate smooth-transition fiscal dynamics and quadratic financial-shock responses, with numerical convergence checks.

Run both applications

Follow the session README to place the five pinned fiscal and financial inputs in data/raw/07-nonlinear-models/. MATLAB needs no optional toolbox. The smooth-transition optimizer takes longer than a single linear VAR; it stops with an error if the declared convergence criteria are not met.

% Estimate the fiscal STVAR and the separate monthly quadratic financial model.
result = run_session(7);
% Inspect every optimizer iteration rather than accepting a plot as a convergence test.
disp(result.stvar.trace);
% Confirm that the returned object met the explicit stopping conditions.
assert(result.stvar.converged);

The checked run has seven outer iterations and a log likelihood of 2018.203067, including the Gaussian constant. The final two trace columns report the inner optimizer flag and objective change. These are distinct from the relative coefficient change in the second column.

Trace the state timing

% Expose the shared package after run_session restores its caller's path.
addpath('matlab');
% The first fitted quarterly equation follows three lost initial observations.
firstEquation = result.config.lags + 1;
% Its state is observed one quarter earlier, not contemporaneously.
expectedWeight = tsma.nonlinear.logistic(result.state(firstEquation - 1), result.config.gamma);
% Confirm that the stored first equation weight uses that exact lagged state.
assert(abs(expectedWeight - result.stvar.weights(1)) < 1e-14);

This verifies the implemented timing convention. It does not demonstrate that the supplied state series or full-sample standardization was available in real time. Keep that separate information-set limitation attached to a historical interpretation.

Inspect the frozen-regime comparison

% Read the spending responses at impact for expansion, recession, and the linear VAR.
impactSpending = squeeze(result.fiscalPaths(1, 1, :));
% Each path is normalized to an approximately one-percent spending increase.
assert(all(abs(impactSpending - 1) < 1e-12));
% Compare GDP impacts in the two frozen regimes and the linear benchmark.
disp(squeeze(result.fiscalPaths(1, 3, :)));

The first two GDP impacts are about 0.0732 and 0.1700 percent. These are not automatically dollar multipliers, and the two frozen regimes do not simulate an initial shock changing future recession weights.

Verify the quadratic asymmetry

% Read the contemporaneous linear loading on the financial shock for real stocks.
a = result.financial.beta(end - 1, 6);
% Read the same equation's squared-shock loading.
b = result.financial.beta(end, 6);
% A positive unit shock adds both loadings on impact.
assert(abs(result.financial.paths(1, 6, 1) - (a + b)) < 1e-12);
% A negative unit shock reverses only the linear contribution.
assert(abs(result.financial.paths(1, 6, 2) - (-a + b)) < 1e-12);
% Doubling the shock quadruples the squared contribution.
assert(abs(result.financial.paths(1, 6, 3) - (2*a + 4*b)) < 1e-12);

On impact, real stocks respond approximately -1.2337 percent to a positive unit financial shock and +0.7762 percent to a negative unit shock. Positive shocks tighten credit in this orientation because they raise EBP. The asymmetry is not a different sign convention applied to each line.

Worked exercises

State weights and timing

Because e^{1.5}\simeq4.4817 and e^{-1.5}\simeq0.2231,

F(-1)\simeq0.8176,\quad F(0)=0.5,\quad F(1)\simeq0.1824.

Low growth receives the high recession weight, and opposite standardized states have complementary weights. This is an immediate direction check for the sign in the exponential. The implementation’s stable formula also returns finite weights at states of magnitude 1000.

With three lags, fitted equations are dated t=4,5,6,7,8. Their state observations are s_3,s_4,s_5,s_6,s_7, respectively. Using s_4 for the equation at t=4 would use the contemporaneous state; using s_2 would introduce an extra unintended lag.

Full-sample standardization uses observations later than some historical forecast origins to estimate the mean and standard deviation. It is a well-defined retrospective normalization, but not the same information set available at each origin. Moreover, the raw state itself must have a documented timing construction. Lagging a centered moving average once does not necessarily remove all future observations from that average.

Whitening a likelihood

The standardized residuals are 2/2=1 and 3/3=1. The negative Gaussian log likelihood is therefore

\mathcal L=\log(2\pi)+\log2+\log3+\tfrac12(1+1) \simeq4.6296.

Dropping the constant subtracts \log(2\pi)\simeq1.8379, giving about 2.7918. The minimizing parameter values do not change when the same fixed-sample constant is omitted, but reported objective levels cannot be compared until the convention is reconciled. This is precisely the adjustment used in the classroom likelihood audit.

For a common T\times k design X and constant n\times n covariance \Sigma, the GLS normal equations for the coefficient matrix D are X'(Y-XD)\Sigma^{-1}=0. Multiplying on the right by \Sigma gives X'Y-X'XD=0, hence D=(X'X)^{-1}X'Y. The production implementation uses QR to solve the equivalent system rather than forming that inverse. Equal regime covariances make weights irrelevant to the covariance step; they do not remove state interactions from a mean design that already contains them.

A state that changes after impact

Initially s_{t-1}=-1<0, so both paths use coefficient 0.8 at impact. The unshocked value is y_t^0=-0.8; the shocked value is y_t^1=-0.8+1=0.2. Their impact difference is one.

The histories then imply different next states. The unshocked path remains in the high-persistence regime, giving y_{t+1}^0=0.8(-0.8)=-0.64. The shocked path has crossed zero and uses coefficient 0.2, giving y_{t+1}^1=0.2(0.2)=0.04. The horizon-one difference is

0.04-(-0.64)=0.68.

Freezing the initial coefficient at 0.8 on both paths would instead give the difference 0.8\times1=0.8. The disagreement is not a simulation error. One calculation lets the shock change the future regime; the other deliberately prevents that channel. In a generalized response with random future innovations, the comparison would also integrate over future innovation paths under a stated conditional distribution.

Shock size and asymmetry

The response function at this horizon is r(\delta)=-0.5\delta-0.2\delta^2. Thus

Shock Linear part Quadratic part Total
+1 -0.5 -0.2 -0.7
-1 +0.5 -0.2 +0.3
+2 -1.0 -0.8 -1.8
-2 +1.0 -0.8 +0.2

Doubling the positive shock changes the response from -0.7 to -1.8, not -1.4. Both the positive and negative shocks have a negative quadratic component. A large negative shock can therefore have a smaller positive effect than a small negative shock in this example.

Adding and subtracting unit-shock responses recovers

C_ha=\frac{r(1)-r(-1)}{2}=\frac{-0.7-0.3}{2}=-0.5, \qquad C_hb=\frac{r(1)+r(-1)}{2}=\frac{-0.7+0.3}{2}=-0.2.

Each response compares the chosen shock with zero, holding the history and other innovations fixed. It is not a deviation from the unconditional mean of the squared innovation. For a unit-variance shock, E(\eta^2)=1, whereas the zero-shock baseline has \eta^2=0.