and after doing that for all groups, still be able to recover an estimate of the Hessian. Thus, the computational cost for computing the Hessian grows with the number of groups, not the number of parameters. Because the household-level parameters are conditionally independent, we do not need to add groups as we add households. For the Hessian sparsity pattern in Figure 7, we need only four groups: one for each of the heterogeneous parameters across all of the households, and one for each of the two population-level parameters. In the upcoming binary choice example in Section 4.4, for which k = 3, there are 1 2 $^{(}$k $^{2}$+ 5 k $^{)}$= 12 groups, no matter how many households we have in the dataset. 

Curtis et al. (1974) introduce the idea of reducing the number of evaluations to estimate sparse Jacobians. Powell and Toint (1979) describe how to partition variables into appropriate groups, and how to recover Hessian information through back-substitution. Coleman and Moré (1983) show that the task of grouping the variables amounts to a classic graph-coloring problem. Most AD software applies this general principle to computing sparse Hessians. Alternatively, R users can use the sparseHessianFD package (Braun 2013b) to efficiently estimate sparse Hessians through finite differences of the gradient, as long as the sparsity pattern is known in advance, and as long as the gradient was not itself estimated through finite differencing. This package is an interface to the algorithms in Coleman et al. (1985b) and Coleman et al. (1985a). 

## 4.2 Finding the posterior mode 

For simple models and small datasets, standard default algorithms (like the optim function in R ) are sufficient for finding posterior modes and estimating Hessians. For larger problems, one should choose optimization tools more thoughtfully. For example, many of the R optimization algorithms default to finite differencing of gradients when a gradient function is not provided explicitly. Even if the user can provide the gradient, many algorithms will store a Hessian, or an approximation to it, densely. Neither feature is attractive when the number of households is large. 

For this section, let’s assume that the log posterior is twice-differentiable and unimodal. 6 There are two approaches that one can take. The first is to use a “limited memory” optimization algo- rithm that approximates the curvature of the log posterior over successive iterations. Several 

