HANS: A Heterogeneous-Agent model Nonlinear Solver
HANS is an open-source toolbox designed to solve nonlinear solutions in discrete-time heterogeneous-agent (HA) models with a continuum of individual decision makers. It excels in scenarios where large deviations from stationary equilibrium values demand highly nonlinear solutions. HANS provides a useful addition to the existing suite of excellent HA modeling toolboxes, especially for researchers addressing highly nonlinear problems.
HANS offers flexibility by accommodating:
Multiple endogenous individual state and choice variables
Discrete individual decision variables
Linearized equilibrium solutions with perfect foresight or with aggregate shocks via the Sequence-Space Jacobian method (Auclert, Bardczy, Rognlie and Straub, 2021)
Nonlinear deterministic transition path solutions through our specialized nonlinear equation solvers
To explore HANS’s capabilities in greater depth, refer to the examples listed below.
HANS takes intuitive model script files as input for automatic code generation (similar to Dynare and GDSGE), compiles C++ binaries for high-performance computations, and offers user-friendly MATLAB interfaces. For example, the model of Krusell and Smith (1998) can be represented with the following toolbox script:
1parameters beta w r;
2beta = 0.99;
3
4var_shock e;
5shock_trans = [0.600000, 0.400000;
6 0.044445, 0.955555];
7e = [0.00, 1.00];
8
9var_state k;
10k = exp(linspace(log(0.25), log(500 + 0.25), 500)) - 0.25;
11
12% allow multiple choice variables
13var_policy c kp;
14initial c 1.0;
15initial kp 0.0;
16
17vfi;
18 budget = (1+r)*k + w*e;
19 u = log(c);
20 % decision problem stated following the Bellman equation
21 Tv = u + beta*EXPECT(v(kp));
22 % allow arbitrary equality/inequality constraints
23 c + kp == budget;
24 kp >= 0.0;
25end;
26
27var_agg K;
28K = 40.0; % initial guess
29L = 1.0; % constant labor
30z = 1.0; % TFP
31alpha = 0.36; % capital share
32delta = 0.025; % depreciation
33
34var_agg_shock z;
35
36model;
37 % aggregate conditions stated like Dynare
38 r = z*alpha*(K(-1)^(alpha-1))*(L^(1-alpha)) - delta;
39 w = z*(1-alpha)*(K(-1)^alpha)*(L^(-alpha));
40 K == kp; % asset demand = asset supply
41 % allow box constraints for aggregate variables
42 K >= 38.0; % make sure VFI converges
43end;
- Home
- Related Heterogenous Agent Toolkits
- Getting Started: Krusell and Smith (1998)
- Solving for Non-linear Transitions: Forward Guidance under ZLB (McKay, Nakamura, Steinsson, 2016)
- Handling Portfolio Choices: Two-asset HANK (Auclert et al, 2021)
- Handling Non-convex Adjustment Costs: Khan and Thomas (2008)
- The Algorithm
- Toolbox API Reference
- How to Contribute Examples