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:
| Variable | Description | Initialization |
|---|---|---|
| Wealth (savings) | LogNormal(μ=100, σ=0.5) | |
| Wage (if employed) | Firm's posted wage | |
| Marginal propensity to consume | Uniform[0.5, 0.95] | |
| Employment status | {0, 1} | |
| Employer ID | Firm ID or null |
Consumption Decision
Household consumption follows a linear rule with wealth draw:
where 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:
| Variable | Description | Initialization |
|---|---|---|
| Capital stock | 1000 | |
| Number of employees | H/F = 10 | |
| Inventory stock | 2 × expected demand | |
| Price | ||
| Posted wage | Base wage × (1 ± 0.15) | |
| Markup | Uniform[0.15, 0.25] | |
| Productivity (TFP) | 1.0 | |
| Cash holdings | 1000 |
Production Function
Output follows a Leontief (fixed proportions) technology:
where 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:
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: = 16% of wage income
- Corporate tax: = 10% of positive profits
- Base spending: = 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 firmWage 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:
- 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:
where 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:
| # | Phase | Key Actions |
|---|---|---|
| 1 | Observation | Collect last period metrics |
| 2 | Banking | Pay deposit interest (3%) |
| 3 | Credit | Process loan requests/payments |
| 4 | Investment | Firms invest in capital |
| 5 | Production | Output with sticky prices |
| 5e | Job Search | Workers search, quit if better offer |
| 5f | Wage Posting | Firms adjust posted wages |
| 6 | Wage Dynamics | Secondary wage adjustment |
| 7 | Labor Market | Hire/fire based on demand forecast |
| 8 | Wage Payment | Firms pay employees |
| 9 | Fiscal | Collect taxes |
| 9b | Housing | Collect rent, distribute profits |
| 10 | Consumption | Calculate demand |
| 11 | Market Clearing | Execute transactions |
| 12 | Inventory | Update production targets |
| 13 | Profit Calc | Revenue - costs |
| 13b | Dividends | Dynamic distribution (0-50%) |
| 14 | Firm Dynamics | Bankruptcies, 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:
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
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/GDP | Action |
|---|---|
| > 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
| Parameter | Value | Source/Rationale |
|---|---|---|
| Search probability (employed) | 10%/month | Fallick & Fleischman (2004) |
| Quit threshold | 10% | Calibrated for 2-3% turnover |
| Wage adjustment speed | ±0.5%/month | Sticky wage literature |
| Downward stickiness | 3:1 ratio | Bewley (1999) |
Fiscal Parameters
| Parameter | Value | Source/Rationale |
|---|---|---|
| Income tax rate | 16% | US effective average |
| Corporate tax rate | 10% | Lower due to deductions |
| Base G/GDP | 16% | US federal non-defense |
| UI replacement rate | 40% | US average |
Financial Parameters
| Parameter | Value | Source/Rationale |
|---|---|---|
| Deposit rate | 3% | Historical average |
| Lending rate | 7% | Prime + spread |
| Capital requirement | 8% | Basel II |
| Depreciation | 1%/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:
| Aspect | DSGE | CrashLab ABM |
|---|---|---|
| Representative agent | Single household, single firm | 1 million households, 50,000 firms, 3 banks, 1 government |
| Expectations | Rational expectations | Adaptive expectations, simple rules |
| Equilibrium | Always at/near equilibrium | Persistent disequilibrium possible |
| Market clearing | Prices adjust to clear | Quantities may ration; queues form |
| Aggregation | Top-down (macro → micro) | Bottom-up (micro → macro) |
| Crises | Exogenous shocks required | Endogenous 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.