Technical Documentation

Methodology

Technical documentation of CrashLab's agent-based macroeconomic model. Full equations, parameters, and design decisions.

1. Model Overview

CrashLab implements a stock-flow consistent agent-based macroeconomic model (SFC-ABM) following the research tradition of Delli Gatti et al. (2011), Caiani et al. (2016), and the "Macroeconomics from the Bottom-up" framework.

Key Characteristics

  • Heterogeneous agents: Each household and firm is a distinct entity with individual state variables
  • Bounded rationality: Agents use simple adaptive rules, not rational expectations
  • Disequilibrium: Markets may not clear; quantities adjust alongside prices
  • Emergent dynamics: Macro patterns (business cycles, unemployment) emerge from micro interactions
  • Stock-flow consistency: All financial flows are tracked; one agent's asset is another's liability

Model Architecture

┌─────────────────────────────────────────────────────────────────┐
│                        EconSim Core                             │
├─────────────────────────────────────────────────────────────────┤
│  AGENTS                                                         │
│  • Households (N=1M)    — workers, consumers, savers            │
│  • Firms (N=50K)        — producers, employers, investors       │
│  • Government (N=1)     — fiscal authority                      │
│  • Banks (N=3)          — credit intermediaries                 │
├─────────────────────────────────────────────────────────────────┤
│  MARKETS                                                        │
│  • Labor market         — decentralized matching, wage posting  │
│  • Goods market         — price competition, inventory buffers  │
│  • Credit market        — working capital, investment loans     │
├─────────────────────────────────────────────────────────────────┤
│  TIME STEP: 1 month (18 phases per step)                        │
└─────────────────────────────────────────────────────────────────┘

2. Agent Specification

2.1 Households

Each household h ∈ {1, ..., H} is characterized by:

VariableDescriptionInitialization
WhW_hWealth (savings)LogNormal(μ=100, σ=0.5)
whw_hWage (if employed)Firm's posted wage
MPChMPC_hMarginal propensity to consumeUniform[0.5, 0.95]
ehe_hEmployment status{0, 1}
emphemp_hEmployer IDFirm ID or null

Consumption Decision

Household consumption follows a linear rule with wealth draw:

Ch=MPCh×Yh+0.02×WhC_h = MPC_h \times Y_h + 0.02 \times W_h

where YhY_h is total income (wages + dividends + landlord profits + transfer payments). The 2% wealth draw prevents indefinite wealth accumulation.

2.2 Firms

Each firm f ∈ {1, ..., F} is characterized by:

VariableDescriptionInitialization
KfK_fCapital stock1000
LfL_fNumber of employeesH/F = 10
IfI_fInventory stock2 × expected demand
pfp_fPricecost×(1+μf)\text{cost} \times (1 + \mu_f)
wfpw^p_fPosted wageBase wage × (1 ± 0.15)
μf\mu_fMarkupUniform[0.15, 0.25]
AfA_fProductivity (TFP)1.0
cashfcash_fCash holdings1000

Production Function

Output follows a Leontief (fixed proportions) technology:

Yf=min(Af×Lf,Kf/κ)Y_f = \min(A_f \times L_f, K_f / \kappa)

where κ\kappa is the capital-labor ratio. The Leontief form implies no factor substitution—both labor and capital are essential, reflecting short-run production constraints.

Pricing Rule

Prices are set as a markup over unit labor costs with sticky adjustment:

pf=wfAf×(1+μf)p^*_f = \frac{w_f}{A_f} \times (1 + \mu_f)
pf(t+1)=pf(t)+0.03×(pfpf(t))p_f(t+1) = p_f(t) + 0.03 \times (p^*_f - p_f(t))

The 3% adjustment speed creates price stickiness, preventing deflationary spirals when productivity rises.

2.3 Government

The government sector collects taxes and provides transfers:

  • Income tax: τy\tau_y = 16% of wage income
  • Corporate tax: τπ\tau_\pi = 10% of positive profits
  • Base spending: G0G_0 = 16% of potential GDP
  • Counter-cyclical adjustment based on output gap

2.4 Banking System

The banking system provides credit under Basel-like constraints:

  • Deposit rate: 3% annual
  • Lending rate: 7% annual
  • Reserve ratio: 10%
  • Capital requirement: 8%
  • Maximum LTV: 80%

3. Market Mechanisms

3.1 Labor Market

The labor market follows a decentralized search and matching framework inspired by Mortensen-Pissarides (2010 Nobel) and Burdett-Mortensen (1998).

Job Search (Employed Workers)

For each employed worker h with tenure > 3 months:
  With probability 0.10:
    Sample 3 random firms
    best_offer = max(sampled firms' posted wages)
    if best_offer > current_wage × 1.10:
      QUIT current job
      Get hired at best-offer firm

Wage Posting (Firms)

Firms adjust posted wages based on labor market signals:

  • High turnover → raise wage (max +0.5%/month)
  • Few applicants → raise wage
  • Many applicants → may lower wage (max -0.15%/month, sticky downward)

Hiring Decision

Target employment based on expected demand with asymmetric adjustment:

Lf=E[Df]×(1+buffer)AfL^*_f = \frac{E[D_f] \times (1 + \text{buffer})}{A_f}
  • Hiring: 85% smoothing, max +15%/period
  • Firing: 60% smoothing, max -25%/period (faster cuts to prevent bleeding)

3.2 Goods Market

Consumers allocate spending across firms using a logit demand model:

sf=exp(β×pf)jexp(β×pj)s_f = \frac{\exp(-\beta \times p_f)}{\sum_j \exp(-\beta \times p_j)}

where β=2.0\beta = 2.0 is the price sensitivity parameter. This creates imperfect competition— lower prices attract more demand, but firms retain some market power.

Inventory Management

  • Target coverage: 2 months of expected sales
  • Markup adjustment: +2% if inventory < 1 month, -2% if > 2 months
  • Depreciation: 2%/month spoilage

3.3 Credit Market

Firms borrow for working capital (wage shortfalls) and investment:

  • Working capital: automatic if cash < wage bill, 7% interest
  • Investment loans: if profitable and capacity-constrained, 5% interest, 5-year amortization
  • Collateral: LTV ≤ 80% of capital stock

4. Dynamic Processes

4.1 Simulation Step Sequence

Each monthly step consists of 18 ordered phases:

#PhaseKey Actions
1ObservationCollect last period metrics
2BankingPay deposit interest (3%)
3CreditProcess loan requests/payments
4InvestmentFirms invest in capital
5ProductionOutput with sticky prices
5eJob SearchWorkers search, quit if better offer
5fWage PostingFirms adjust posted wages
6Wage DynamicsSecondary wage adjustment
7Labor MarketHire/fire based on demand forecast
8Wage PaymentFirms pay employees
9FiscalCollect taxes
9bHousingCollect rent, distribute profits
10ConsumptionCalculate demand
11Market ClearingExecute transactions
12InventoryUpdate production targets
13Profit CalcRevenue - costs
13bDividendsDynamic distribution (0-50%)
14Firm DynamicsBankruptcies, entry

4.2 Firm Entry and Exit

Exit Conditions

A firm exits (bankruptcy) if:

  • 12 consecutive months of losses, AND
  • Cash < 0 or cannot meet wage bill

Entry Conditions

New firms enter when:

  • Active firms < 150
  • Credit available > $1,000
  • Unemployment > 3%
  • AND at least one of:
    • Industry profit rate > 5% (profit signal)
    • Capacity utilization > 90% AND inventory < 1 month (supply shortage)
    • Unemployment > 10% AND firms < 80 (crisis entry)

4.3 Productivity Dynamics

Baseline total factor productivity (TFP) growth:

A(t+1)=A(t)×(1+0.0005)A(t+1) = A(t) \times (1 + 0.0005)

This 0.05%/month growth represents ~0.6% annual productivity improvement, consistent with historical averages. TFP is capped at 10× base to prevent runaway growth.

5. Automatic Stabilizers

5.1 Unemployment Insurance Fund

  • Contribution: 2% payroll tax on all wages
  • Benefits: 40% of average wage to unemployed
  • Government backstop if fund depleted

5.2 Counter-cyclical Fiscal Policy

G=G0×(1+0.5×output_gap)G = G_0 \times (1 + 0.5 \times \text{output\_gap})

Government spending rises when GDP falls below potential, providing automatic demand support.

5.3 Bank Recapitalization

The government recapitalizes the banking system when:

  • Bank capital < 0 (emergency)
  • Lending capacity < $5,000 (proactive)
  • Capital ratio < Basel minimum

This prevents credit crunch death spirals where banks can't lend → firms fail → banks lose more.

5.4 Government Employment

When unemployment exceeds 10%:

  • Government hires 20% of excess unemployed per period
  • Wage: 60% of market average (incentivizes private sector)
  • Cap: 30% of workforce (prevents crowding out)

5.5 Debt Ceiling

Tiered fiscal brake to prevent unsustainable debt accumulation:

Debt/GDPAction
> 80%Spending × 0.97
> 100%Spending × 0.90
> 150%Spending × 0.75
> 200%Spending ≤ Revenue × 1.05
> 300%Debt restructuring to 250%

6. Parameter Values

Key calibrated parameters (see docs/PARAMETERS.md for complete list):

Labor Market

ParameterValueSource/Rationale
Search probability (employed)10%/monthFallick & Fleischman (2004)
Quit threshold10%Calibrated for 2-3% turnover
Wage adjustment speed±0.5%/monthSticky wage literature
Downward stickiness3:1 ratioBewley (1999)

Fiscal Parameters

ParameterValueSource/Rationale
Income tax rate16%US effective average
Corporate tax rate10%Lower due to deductions
Base G/GDP16%US federal non-defense
UI replacement rate40%US average

Financial Parameters

ParameterValueSource/Rationale
Deposit rate3%Historical average
Lending rate7%Prime + spread
Capital requirement8%Basel II
Depreciation1%/month~11% annual (equipment)

7. Comparison to DSGE Models

The dominant framework in mainstream macroeconomics is Dynamic Stochastic General Equilibrium (DSGE). CrashLab's ABM approach differs in several fundamental ways:

AspectDSGECrashLab ABM
Representative agentSingle household, single firm1 million households, 50,000 firms, 3 banks, 1 government
ExpectationsRational expectationsAdaptive expectations, simple rules
EquilibriumAlways at/near equilibriumPersistent disequilibrium possible
Market clearingPrices adjust to clearQuantities may ration; queues form
AggregationTop-down (macro → micro)Bottom-up (micro → macro)
CrisesExogenous shocks requiredEndogenous instability possible

Limitations of This Model

  • No international trade: Closed economy assumption
  • Simplified finance: Single commercial bank, no asset markets
  • No expectations heterogeneity: All agents use similar forecasting rules
  • Calibration uncertainty: Many parameters lack empirical micro-foundations
  • Scale effects: Even 1M households is 1/130th of the US economy

8. References

Bewley, T. F. (1999). Why Wages Don't Fall During a Recession. Harvard University Press.

Burdett, K., & Mortensen, D. T. (1998). Wage differentials, employer size, and unemployment. International Economic Review, 39(2), 257-273.

Caiani, A., Godin, A., Caverzasi, E., Gallegati, M., Kinsella, S., & Stiglitz, J. E. (2016). Agent-based stock-flow consistent macroeconomics. Journal of Economic Dynamics and Control, 69, 375-408.

Delli Gatti, D., Gaffeo, E., Gallegati, M., Giulioni, G., & Palestrini, A. (2008). Emergent Macroeconomics: An Agent-Based Approach to Business Fluctuations. Springer.

Dosi, G., Fagiolo, G., Napoletano, M., & Roventini, A. (2013). Income distribution, credit and fiscal policies in an agent-based Keynesian model. Journal of Economic Dynamics and Control, 37(8), 1598-1625.

Farmer, J. D., & Foley, D. (2009). The economy needs agent-based modelling. Nature, 460(7256), 685-686.

Lengnick, M. (2013). Agent-based macroeconomics: A baseline model. Journal of Economic Behavior & Organization, 86, 102-120.

Mortensen, D. T., & Pissarides, C. A. (1994). Job creation and job destruction in the theory of unemployment. Review of Economic Studies, 61(3), 397-415.

Tesfatsion, L. (2006). Agent-based computational economics: A constructive approach to economic theory. Handbook of Computational Economics, 2, 831-880.