Tianhao Zhao
Collocation with the presence of endogeneous Markovian riskIntroductionNotationDiscretized systemTopic: Chocie of interpolation methodsTopic: Recipe of Newton's methodTopic: Optimization step
The collocation method is widely used in macroeconomic modeling to approximate value functions (or policy functions) through interpolation techniques. This approach offers two key advantages:
Many interpolation methods provide greater smoothness than piecewise linear interpolation while requiring fewer supporting nodes.
By projecting the original problem onto a pseudo-linear one in the space of interpolation coefficients, the collocation method enables analytical evaluation of the Jacobian matrix for the approximated system. This Jacobian facilitates the use of gradient-based algorithms, such as Newton’s method, to accelerate convergence.
Despite its advantages, many textbooks and online materials overlook an important scenario: cases where the transition matrix (often assumed to describe a Markov process governing uncertainty in dynamic programming) is exogenous but depends on the current state of the system. This scenario, involving endogenous risk, is highly relevant in economic applications. For instance, an individual’s unemployment risk in general equilibrium may depend on the aggregate unemployment rate, which itself evolves as an aggregate state. Addressing such cases requires specific formulations and methodological adjustments to extend the collocation method.
In this post, I first establish the notation for collocation and outline the construction of the discretized system. I emphasize that endogenous risk, compared to standard exogenous risk, significantly increases the number of equations required to interpolate the expected value function. Specifically, the size of the system expands proportionally to the number of supporting nodes for endogenous states. I then discuss how to solve the resulting pseudo-linear system and compute its Jacobian matrix analytically. Finally, I explore several topics for efficiently implementing the collocation method.
Hint:
I do my best to label the dimension of each vector and matrix such that one can easily translate the math notations to their programs without wasting time in figuring out potential dimesion mismatches.
A vector space
should be always translated to column vector in computer programming.
We consider solving the following time-invariant Bellman equation:
where
Remark: The state vector
, in general equilibrium, consists of individual states AND aggregate states simultaneously.
Here we assume the transition probability
where
Attention: the transition matrix
depends on endogenous states but the matrix itself determines the next period's exogenous states .
Notes: stacking is not necessary to be Cartesian/tensor product. The supporting nodes are not necessary to be uniform or evenly spaced. This assumption allows for sparse grid and other special grids.
Notation: In the following sections, I keep using
to denote an arbitrary point in the state space , and using to denote supporting nodes of the interpolation. A node must be a point, but a point is not necessary to be a node.
Remark: Supporting nodes are necessary in either local interpolation methods or global methods. In global methods, these nodes are sampled and evaluated at to fit the interpolation.
Let's define stackings:
For convenience, let's also define the stacking of policy
Let
Let
where
Thus, the stacked interpolated values can be linearly written as:
Hints: For (univariate or multivariate) piecewise linear interpolation,
and where is the identity matrix.
Now, let's interpolate and stack the expected value function (or Q-function). The expectation operation is defined as:
where the dimensionality of
Remark: An alternative way of defining the interpolant is
which fits many scenarios. However, this alternative method requires further interpolation of a vector-valued function . Its dimensionality , which depends on the number of supporting nodes, is infeasibly high. Our current implementation of Eq ( ) works better at a cost of dimensionality.
Remark: The node set of
can be different from the set of partial from the nodes in , which allows multiple resolution of the interpolation.
For convenience, we define the tensor space of endogenous states
Thanks to the linearity of the expectation operation, we can define the expectation operator as a row-vector such that:
Intuitively, for the following stacked mapping from node stacking
one can define an expectation matrix
Remark: The construction of
, personally speaking, is the hardest part of collocation. Its structure not only depends on the stacking order of your nodes but also depends on the type of your grid. Thus, it is hard to write down mathematically (unless some special cases such as Cartesian nodes and states sorted lexicographically or anti-lexicographically), but it might be easy to implement in computer programs using Hash map or other efficient data structures.
The discretized system is a pseudo linear system of total
accompoanied by
Remark:
The number of equations degenerates to
if is no longer depending on endogeneous states . This happens in stationary equilibrium or purely exogenous risk. The endogeneity of the risk
dramatically increases the number of equations by approximately times.
Plugging the interpolation in:
There are
Remark:
For both global and local interpolation methods,
is usually equal to . Thus, if there is no discontinuity of
, then global methods are always more preferred.
The system is pseudo linear in the coefficients. To solve this system using gradient-based methods such as Newton's method, we define:
Remark: The Eq (
) can be converted to a fixed-point format by left multiplying and to both sides of the equation. The fixed-point format can be directly used to run some iterative algorithms.
There is Jacobian:
With the analytical Jacobian, one can efficiently solve the whole problem in a reasonable time.
Remark: One can quickly figure out that most terms of
can be pre-conditioned except the basis matrix . The reason is that the new endogenous states change by iteration and evaluating it requires doing the optimization step. The optimization step, which also determines of every iteration in , is the bottleneck of the whole algorithm's performance.
The choice of interpolation methods becomes particularly important as the dimensionality of the Bellman equation increases. Since the number of interpolation coefficients must match the number of supporting nodes to exactly determine the coefficients, the projected pseudo-linear system remains subject to the curse of dimensionality (not only the number of states, but also the extra dimensionality due to the endogenous risk!). Thus, one must carefully trade off between different interpolation methods based on their performance characteristics. The following table compares the memory demand of local and global interpolation methods generally given the same accuracy demand.
Method | Required number of nodes | Basis matrix sparsity |
---|---|---|
Local | Large | Sparse |
Global | Not that large | Dense (usually) |
The following table compares some popular interpolation methods:
Method | Type | Time Complexity | Memory Complexity | Notes |
---|---|---|---|---|
Piecewise Linear | Local | Simple, fast, but less smooth; scales well for higher dimensions. | ||
Cubic Spline | Local | Provides smoother approximations than linear interpolation but may struggle in very high dimensions. | ||
Polynomial Basis | Global | Highly smooth but computationally expensive; impractical for high dimensions. | ||
Chebyshev Polynomials | Global | Offers better numerical stability and smoothness; suitable for moderate dimensions. | ||
Radial Basis Functions (RBF) | Global | Flexible and accurate but memory-intensive; more suitable for low-dimensional problems. |
One can quickly realize that the trade-off does not break the curse of dimensionality. To really break it, one can explore other dimensionality reduction techniques such as
Sparse grid: This method uses the idea of optimizing the grid structure. It reduces the number of nodes while keeping the sparsity of the basis matrix. If incorporating node adaption, then the number of required nodes can be further cut
Machine learning: This method employs a highly efficient interpolation/approximation technique, where automatic differentiation and backpropagation can significantly accelerate the iteration process. In fact, it represents a generalized approach to the traditional collocation method.
To solve Eq (
To improve the efficiency by avoiding inverting the Jacobian matrix when
Even though collocation significantly accelerates the convergence of the entire iteration, 90% of the computational cost is still concentrated in the optimization step, where one must solve
The performance depends heavily on the number of control variables and the complexity of the admissible space
It is fast if there is only one control variable (e.g., consumption) and a linear search can handle it efficiently.
It is manageable with two control variables (e.g., consumption and leisure), where the simplex method can still work reasonably well in unconstrained case and with space rectangularization.
It becomes very slow when there are more than three control variables, especially if constraints make the admissible space
Therefore, one must carefully select the optimizer while verifying the interpolation properties used in collocation. For example, the MATLAB function fmincon
is powerful and robust, but it may fail to converge within a reasonable time if the interpolation method causes numerical oscillations or destroys the convexity of the Hamiltonian.