I develop an algorithm for solving dynamic models in which individual
decision rules and the cross-sectional distribution of agents'
characteristics influence each other. To illustrate the algorithm, I
solve an endowment economy with incomplete markets, a continuum of
heterogeneous agents, and aggregate shocks. The key innovation of the
algorithm is to parameterize the (cross-sectional) density with a
flexible functional form, which makes it possible to avoid simulation
techniques. The paper shows how to check for accuracy and establishes
links between the properties of the incomplete-markets economy and
the aspects involved in obtaining a numerical solution.