Behavioral Equations Mark0COVID#

Initialization Equations#

Initialise firm-level state vectors and macro carry-over scalars. Firms are indexed \(i \in \{0, \ldots, N-1\}\). Initial price and production carry a small linear spread across the index, scaled by \(0.01\). Assets are seeded so the cross-section average equals \(Y_0 W_0\). The aggregates \(\bar P\), \(\bar W\), \(Y_{tot}\), \(A_{tot}\) are recorded as production-weighted moments.

\begin{align} P_{i,0} &= 1 + 0.01\,(2 i/N - 1), \\ Y_{i,0} &= Y_0 + 0.01\,(2 i/N - 1), \\ W_{i,0} &= 1, \quad D_{i,0} = Y_0, \\ A_{i,0} &= 2\,Y_{i,0}\,W_{i,0}\,(i/N), \\ \Pi_{i,0} &= P_{i,0}\,\min(D_{i,0}, Y_{i,0}) - W_{i,0}\,Y_{i,0}, \\ \alpha_{i,0} &= 1. Each firm receives a distinct initial price, production, and asset endowment, producing a non-degenerate cross-section before the first macro step. \end{align}

Initialise macro state: savings, interest rates, employment, EWMA registers. Total money stock is fixed to \(N\) by rescaling household savings \(S\) and firm assets \(A_i\) against the prior firm endowment. The CB rate, loan rate, and EWMA loan rate are all initialised to the baseline \(\rho^\star\); deposit-side rates, inflation registers, and the bankruptcy / propensity / gamma / default accumulators all initialise to zero.

\begin{align} S_0 &= N\,\frac{Y_{tot}}{A_{tot} + Y_{tot}}, \\ A_{i,0} &\leftarrow A_{i,0}\,\frac{N}{A_{tot} + Y_{tot}}, \\ M^0_0 &= N, \\ \rho^{CB}_0 = \rho^l_0 = \bar\rho^l_0 &= \rho^\star, \\ e_0 &= Y_{tot}/N, \quad u_0 = 1 - e_0. Rescaling pins :math:`A_{tot} + S = N` exactly at :math:`t=0`, so the money-stock identity holds before any phase fires. \end{align}

Step Equations#

  1. Bankrupt Firms

Zero out production, assets, wage of bankrupt firms; record the defaulted asset total.

\begin{align} D^{\text{def}}_t &= -\sum_i \text{enter}_{i,t}\,A_{i,t}, \\ Y_{i,t},\,A_{i,t},\,\alpha_{i,t},\,W_{i,t} &\leftarrow 0 \quad\text{if}\quad \text{enter}_{i,t} = 1. Bankrupt firms are zeroed simultaneously across production, assets, alive flag, and wage; the negative-asset sum surfaces as the system-level defaulted total, which the loan rate phase uses to set the bankruptcy-adjusted spread. \end{align}
  1. Compute Employment

Update aggregate employment and unemployment scalars.

\begin{align} e_t &= Y_{tot} / N, \\ u_t &= 1 - e_t. Aggregate employment is the total production normalised to the labour-force ceiling; unemployment is the residual that downstream wage and revival phases consume. \end{align}
  1. Compute Gamma And Ren

Bank-side \(\Gamma\) (real-rate gap above baseline) and per-firm \(\text{ren}\) ratio (\(\Gamma\) times solvency).

\begin{align} \Gamma_t &= \Gamma_0 + \text{ReLU}\big(\alpha_\Gamma\,(\bar\rho^l_t - \hat\pi_t) - \Gamma_0\big), \\ \text{ren}_{i,t} &= \Gamma_t \cdot \frac{A_{i,t}}{W_{i,t} Y_{i,t} + \epsilon}. baseline; :math:`\text{ren}_{i,t}` scales each firm's gross solvency by that bank-side aggressiveness, driving the hiring, wage, and price asymmetries downstream. \end{align}
  1. Compute Inflation And Employment

Inflation from the current/prior average price; aggregate employment update.

\begin{align} \pi_t &= \bar P_t - 1, \\ e_t &= Y_{tot} / N, \\ u_t &= 1 - e_t. Re-deriving employment after revival closes the labour-market identity used by the next period's wage and consumption phases. \end{align}
  1. Compute Lowest Price

Lowest price among surviving firms with positive price.

\begin{align} P^{\min}_t = \min_{i \in \{i: \text{stay}_{i,t}\,P_{i,t} > 0\}} P_{i,t}. Dead firms are masked to a large sentinel so the minimum picks up only live, positively-priced firms. The result anchors the household demand allocation in the next phase. \end{align}
  1. Compute Moments

Recompute wage and price moments after bankruptcy zeroing.

\begin{align} W_{tot} &= \sum_i \text{stay}_{i,t}\,W_{i,t}\,Y_{i,t}, \\ \bar W_t &= W_{tot} / (Y_{tot} + \epsilon), \\ \bar P_t &= \sum_i \alpha_{i,t}\,P_{i,t}\,Y_{i,t} / (Y_{tot} + \epsilon), \\ W^{\max}_t &= \max_i \alpha_{i,t}\,W_{i,t}. The post-bankruptcy moments anchor the bank-side and household-side decisions: maximum wage drives the unemployment logit, average price drives the demand allocation, average wage feeds the consumption budget. \end{align}
  1. Compute Ushare

Per-firm share of the unemployed labour pool via a logit weight on the wage gap to the maximum wage.

\begin{align} z_{i,t} &= \beta\,(W_{i,t} - W^{\max}_t) / \bar W_t, \\ w_{i,t} &= \alpha_{i,t}\,e^{z_{i,t}}, \\ Z_t &= \sum_i w_{i,t}, \\ u^{\text{share}}_{i,t} &= \alpha_{i,t}\,\frac{u_t\,N\,(1 - \text{bust}_t)\,e^{z_{i,t}}}{Z_t + \epsilon}. Higher-wage live firms attract a larger share of the unemployed pool, allowing them to expand production faster when demand pressure builds. \end{align}
  1. Demand Production Imbalance

Compute the per-firm demand-production gap and the corresponding excess-demand and excess-supply indicator masks.

\begin{align} \Delta Y_{i,t} &= \text{stay}_{i,t}\,(D_{i,t} - Y_{i,t}), \\ \mathbf{1}^D_{i,t} &= \mathbb{1}\{\Delta Y_{i,t} > 0\}, \\ \mathbf{1}^S_{i,t} &= \alpha_{i,t}\,\mathbb{1}\{D_{i,t} - Y_{i,t} \le 0\}. The masks partition the surviving firm cross-section into demand-constrained and supply-constrained sub-populations consumed by the subsequent production, price, and wage updates. \end{align}
  1. Expectation Adjustments

Anticipated inflation pass-through into prices and wages for surviving firms.

\begin{align} P_{i,t} &\leftarrow P_{i,t}\,(1 + \hat\pi_t) \quad\text{if stay}_{i,t}, \\ W_{i,t} &\leftarrow W_{i,t}\,(1 + \hat\pi_t\,w_f) \quad\text{if stay}_{i,t}. Surviving firms transmit a fraction :math:`w_f` of the expected inflation to wages and the full amount to prices, building in a wedge that drives the loan-rate response. \end{align}
  1. Find Surviving Firms

Identify firms whose assets plus a fraction \(\Theta\) of payroll are positive; survivors stay alive next period, the rest enter bankruptcy. The differentiable indicator uses Behavior.diffwhere() so gradient flows through the solvency threshold. The bankruptcy indicator is the squared complement, giving a smoother gradient at the boundary.

\begin{align} \text{stay}_{i,t} &= \alpha_{i,t-1} \cdot \text{diffwhere}\big(A_{i,t} + \Theta\, W_{i,t} Y_{i,t},\, 1,\, 0\big), \\ \text{enter}_{i,t} &= \alpha_{i,t-1}\,(1 - \text{stay}_{i,t})^2. Firms whose end-of-period assets cover a fraction :math:`\Theta` of the next period's wage bill survive; the rest are flagged for bankruptcy. \end{align}
  1. Firm Accounting

Realise per-firm EBIT and profits, draw down household savings by the aggregate EBIT, and update firm assets by the alive-weighted profit stream.

\begin{align} \text{ebit}_{i,t} &= P_{i,t}\,\min(D_{i,t}, Y_{i,t}) - W_{i,t}\,Y_{i,t}, \\ \Pi_{i,t} &= \text{ebit}_{i,t} + \rho^l_t\,\min(A_{i,t}, 0) + \rho^d_t\,\max(A_{i,t}, 0), \\ A_{i,t} &\leftarrow A_{i,t} + \alpha_{i,t}\,\Pi_{i,t}, \\ S_t &\leftarrow S_t - \sum_i \alpha_{i,t}\,\text{ebit}_{i,t}. The accounting balances aggregate EBIT against the household savings drawdown and pushes profit signals into firm assets, carrying the previous-period balance-sheet effects into the next bankruptcy check. \end{align}
  1. Household Consumption

Update the household consumption propensity, set the budget, and allocate firm-level demand by a logit weight on the price gap to the lowest live price.

\begin{align} c_t &= \mathrm{clamp}\big(c_0\,[1 + \alpha_c\,(\hat\pi_t - \bar\rho^d_t)],\,0,\,1\big), \\ B_t &= c_t\,[W_{tot} + \max(S_t, 0)], \\ z_{i,t} &= \beta\,(P^{\min}_t - P_{i,t}) / \bar P_t, \\ D_{i,t} &= \alpha_{i,t}\,\frac{B_t\,e^{z_{i,t}}}{(\sum_j \alpha_{j,t}\,e^{z_{j,t}} + \epsilon)\,P_{i,t}}, \\ D_t^{tot} &= \sum_i \alpha_{i,t}\,D_{i,t}. Real-rate gaps raise the consumption propensity; the logit allocation sends a larger share of demand to lower-priced live firms, transmitting price competition into the real economy. \end{align}
  1. Monetary Policy

Central bank policy: Taylor-like rule on EWMA inflation only.

\begin{align} \rho^{CB}_t = \rho^\star + \phi_\pi\,(\pi^{ema}_t - \pi^\star). The CB raises the policy rate when EWMA inflation runs above target and lowers it when it runs below, feeding into the next period's loan-rate setting and the household propensity gap. \end{align}
  1. Pay Dividends

Pay dividends from firms with positive assets and profits; credit household savings, debit firm assets.

\begin{align} m_{i,t} &= \alpha_{i,t}\,\mathbb{1}\{A_{i,t} > 0\}\,\mathbb{1}\{\Pi_{i,t} > 0\}, \\ d_{i,t} &= m_{i,t}\,A_{i,t}\,\delta, \\ S_t &\leftarrow S_t + \sum_i d_{i,t}, \\ A_{i,t} &\leftarrow A_{i,t} - d_{i,t}. The mask gates dividends on both balance-sheet sign and profitability, recycling part of the surviving firms' surplus back to households as a closed-loop income source. \end{align}
  1. Price Adjustment

Price update from the frozen-noise buffer. Excess-demand firms with below-average price scale \(P\) up by \((1 + r_p)\); excess-supply firms with above-average price scale down by \((1 - r_p)\).

\begin{align} r_p &= \gamma_p\,u^p_{t,i}, \\ P_{i,t} &\leftarrow P_{i,t}\,(1 + r_p) \quad\text{if}\quad \text{stay}_{i,t}\,\mathbf{1}^D_{i,t}\,(P_{i,t} < \bar P_t), \\ P_{i,t} &\leftarrow P_{i,t}\,(1 - r_p) \quad\text{if}\quad \mathbf{1}^S_{i,t}\,(P_{i,t} > \bar P_t). Below-average price-setters facing excess demand raise prices and above-average price-setters facing excess supply cut prices, pulling the cross-section toward the average. \end{align}
  1. Production Adjustment

Adjust production: increase when in excess-demand regime, decrease when in excess-supply regime.

\begin{align} \eta^+_{i,t} &= \mathrm{clamp}\big(\eta_0 r\,(1 + \text{ren}_{i,t}),\,0,\,1\big), \\ \eta^-_{i,t} &= \mathrm{clamp}\big(\eta_0\,(1 - \text{ren}_{i,t}),\,0,\,1\big), \\ Y_{i,t} &\leftarrow Y_{i,t} + \text{stay}_{i,t}\,\mathbf{1}^D_{i,t}\,\min(\eta^+_{i,t}\,\Delta Y_{i,t},\,u^{\text{share}}_{i,t}) \\ &\phantom{\leftarrow Y_{i,t}}\; + \text{stay}_{i,t}\,\mathbf{1}^S_{i,t}\,\eta^-_{i,t}\,\Delta Y_{i,t}. Hiring is capped by the firm's share of the unemployed labour pool, and firing is asymmetric to hiring through the modulation. \end{align}
  1. Recompute Firm Totals Consumption

Ordering-critical re-aggregation after firm accounting and dividends.

\begin{align} D^{tot}_t &= \sum_i \alpha_{i,t}\,D_{i,t}, \\ S^{f+}_t &= \sum_i \text{stay}_{i,t}\,\max(A_{i,t}, 0), \\ A^{tot}_t &= \sum_i \alpha_{i,t}\,A_{i,t}. The recompute refreshes the aggregate stocks the revival and balance-sheet-adjustment phases will read, after firm-level profits and dividends have moved cash around. \end{align}
  1. Recompute Firm Totals Revival

Ordering-critical re-aggregation after revival; absorb the default loss into surviving firms’ assets, then refresh every macro aggregate that downstream phases will read.

\begin{align} A_{i,t} &\leftarrow A_{i,t} - A_{i,t}\,\frac{D^{\text{def}}_t}{\tilde S^{f+}_t} \quad\text{if}\quad \alpha_{i,t}\,S^{f+}_t\,A_{i,t} > 0, \\ W_{tot} &= \sum_i \alpha_{i,t}\,W_{i,t}\,Y_{i,t}, \\ Y_{tot} &= \sum_i \alpha_{i,t}\,Y_{i,t}, \\ A_{tot} &= \sum_i \alpha_{i,t}\,A_{i,t}, \\ D^{f-}_t &= \sum_i \alpha_{i,t}\,\max(-A_{i,t}, 0), \\ W^{\max}_t &= \max_i \alpha_{i,t}\,W_{i,t}, \\ \text{bust}_t &= (N - \sum_i \alpha_{i,t})/N, \\ \bar P_t &= \sum_i \alpha_{i,t}\,P_{i,t}\,Y_{i,t} / (Y_{tot} + \epsilon), \\ \bar W_t &= W_{tot} / (Y_{tot} + \epsilon). The proportional default absorption keeps the aggregate-asset identity intact across revival; the refreshed moments feed the inflation phase and the next period's wage and price updates. \end{align}
  1. Recompute Firm Totals Stayalive

Ordering-critical re-aggregation after the wage/price update. Enforces non-negative production for surviving firms via Behavior.diffwhere(), then recomputes macro totals from the stay-alive mask. Must fire before bankrupt_firms() zeroes out the bankrupt slice.

\begin{align} Y_{i,t} &\leftarrow \text{diffwhere}\big(\text{stay}_{i,t},\,\max(Y_{i,t}, 0),\,Y_{i,t}\big), \\ Y_{tot} &= \sum_i \text{stay}_{i,t}\,Y_{i,t}, \\ W_{tot} &= \sum_i \text{stay}_{i,t}\,W_{i,t}\,Y_{i,t}, \\ \bar W_t &= W_{tot} / (Y_{tot} + \epsilon), \\ \bar P_t &= \sum_i \text{stay}_{i,t}\,P_{i,t}\,Y_{i,t} / (Y_{tot} + \epsilon), \\ S^{f+}_t &= \sum_i \text{stay}_{i,t}\,\max(A_{i,t}, 0), \\ D^{f-}_t &= \sum_i \text{stay}_{i,t}\,\max(-A_{i,t}, 0). The clamp keeps production weakly positive for solvent firms; the production-weighted averages and total payroll feed the subsequent bank-rate and household-consumption phases. \end{align}
  1. Renormalize Prices

Rescale all nominal quantities by the lagged average price so that \(\bar P_t \equiv 1\) going into the wage/price update. Every nominal series — firm prices, wages, assets, profits, household savings, the wage moments, and the money stock — is divided by \(\bar P_{t-1}\) in lock-step. The carry-over \(\bar P\) then collapses to 1.

\begin{align} P_{i,t} &\leftarrow P_{i,t} / \bar P_{t-1}, \\ W_{i,t} &\leftarrow W_{i,t} / \bar P_{t-1}, \\ A_{i,t} &\leftarrow A_{i,t} / \bar P_{t-1}, \\ \Pi_{i,t} &\leftarrow \Pi_{i,t} / \bar P_{t-1}, \\ S_t &\leftarrow S_t / \bar P_{t-1}, \\ \bar W_t, M_t^{0}, W^{\max}_t &\leftarrow (\cdot) / \bar P_{t-1}, \\ \bar P_t &\leftarrow 1. Lock-step rescaling preserves every nominal-quantity ratio while zeroing out trend inflation in the carry-over level, so subsequent wage and price update phases work in unit price units. \end{align}
  1. Revive Firms

Bernoulli revival of dead firms; revived firms receive a fresh production / price / wage / asset endowment.

\begin{align} m^{\text{rev}}_{i,t} &= (1 - \alpha_{i,t})\,\mathbb{1}\{u^r_{t,i} < \phi\}, \\ Y_{i,t} &\leftarrow \max(u_t, 0)\,u^{r,Y}_{t,i} \quad\text{if}\quad m^{\text{rev}}_{i,t} = 1, \\ P_{i,t} &\leftarrow \bar P_t,\quad W_{i,t} \leftarrow \bar W_t \quad\text{if}\quad m^{\text{rev}}_{i,t} = 1, \\ A_{i,t} &\leftarrow W_{i,t}\,Y_{i,t} \quad\text{if}\quad m^{\text{rev}}_{i,t} = 1, \\ \Pi_{i,t} &\leftarrow 0 \quad\text{if}\quad m^{\text{rev}}_{i,t} = 1, \\ D^{\text{def}}_t &= \sum_i m^{\text{rev}}_{i,t}\,A_{i,t}, \\ S^{f+}_t &\leftarrow S^{f+}_t + D^{\text{def}}_t, \\ \alpha_{i,t} &\leftarrow \alpha_{i,t} + m^{\text{rev}}_{i,t}. Revival keeps the firm count steady and seeds new entrants near the average wage and price, preventing the population from collapsing. \end{align}
  1. Set Interest Rates

Set loan rate (CB rate plus bankruptcy-adjusted spread) and deposit rate (residual closing the bank’s balance sheet); then accrue interest on household savings.

\begin{align} \rho^l_t &= \begin{cases} \rho^{CB}_t + (1 - f)\,D^{\text{def}}_t / D^{f-}_t & \text{if}\ D^{f-}_t > 0, \\ \rho^{CB}_t & \text{otherwise}, \end{cases} \\ I_t &= \rho^l_t\,D^{f-}_t, \\ \rho^d_t &= \begin{cases} (I_t - D^{\text{def}}_t) / (S_t + S^{f+}_t) & \text{if}\ S_t + S^{f+}_t > 0, \\ 0 & \text{otherwise}, \end{cases} \\ S_t &\leftarrow (1 + \rho^d_t)\,S_t. The loan-rate spread compensates the bank for default losses; the deposit rate is whatever residual balances total bank cashflow against accrued interest, so the bank's balance sheet closes without an exogenous funding source. \end{align}
  1. Solve Rounding Errors

Patch the monetary-closure residual to absorb floating-point drift from earlier denominator regularisations.

\begin{align} R_t &= S_t + S^{f+}_t - D^{f-}_t - D^{\text{def}}_t - M^0_t, \\ S_t &\leftarrow \begin{cases} S_t - R_t & \text{if}\ |R_t| > 10^{-9}, \\ S_t & \text{otherwise}. \end{cases} The patch enforces the money-stock identity floating-point tolerance at every period. \end{align}
  1. Update Averages

EWMA update of inflation, interest rate, and unemployment registers; convex combination of EWMA inflation and CB target for the expectation used downstream. The four EWMA registers share the same memory weight \(\omega\). The expected-inflation pipe used by every downstream phase mixes the CB target with the EWMA term in a fixed convex combination.

\begin{align} \pi^{ema}_t &= \omega\,\pi_{t-1} + (1-\omega)\,\pi^{ema}_{t-1}, \\ \bar\rho^d_t &= \omega\,\rho^d_{t-1} + (1-\omega)\,\bar\rho^d_{t-1}, \\ \bar\rho^l_t &= \omega\,\rho^l_{t-1} + (1-\omega)\,\bar\rho^l_{t-1}, \\ \bar u_t &= \omega\,u_{t-1} + (1-\omega)\,\bar u_{t-1}, \\ \hat\pi_t &= \tau^T \pi^\star + \tau^R \pi^{ema}_t. Smoothing the four registers in lock-step makes downstream bank-side and household-side decisions react to slow-moving aggregate signals rather than period noise. \end{align}
  1. Wage Adjustment

Smooth wage update from the frozen-noise buffer. Excess-demand profitable firms raise wages; excess-supply loss-making firms lower wages. The cashflow-per-production ceiling caps wage increases at the firm’s affordable level so the asset balance does not turn nominally infeasible.

\begin{align} r_w &= \gamma_p\,r\,u^w_{t,i}, \\ W_{i,t} &\leftarrow W_{i,t}\,[1 + (1 + \text{ren}_{i,t})\,r_w\,e_t] \quad\text{if}\quad \text{stay}_{i,t}\,\mathbf{1}^D_{i,t}\,(\Pi_{i,t} > 0), \\ W_{i,t} &\leftarrow \min\big(W_{i,t},\,\text{cashflow}_{i,t}/Y_{i,t}\big) \quad\text{(ceiling on the wage rise)}, \\ W_{i,t} &\leftarrow W_{i,t}\,[1 - (1 - \text{ren}_{i,t})\,r_w\,u_t] \quad\text{if}\quad \text{stay}_{i,t}\,\mathbf{1}^S_{i,t}\,(\Pi_{i,t} < 0). Wage growth is gated on both regime (demand/supply) and firm profitability; the cashflow ceiling prevents wage-driven insolvency, and the :math:`(1 \pm \text{ren})` weighting introduces the same hiring/firing asymmetry seen in production. \end{align}