Tools

The Tools submodule provides a set of numerical subroutines such as linear and non-linear interpolation, the Tauchen algorithm to discretize a Gaussian AR-1 process, root-finders and optimizers, wrappers for the schur decomposition, etc.

Some of the functions in detail

BASEforHANK.Tools.TauchenFunction
Tauchen(rho,N,sigma,mue)

Generate a discrete approximation to an AR(1) process, following Tauchen (1987).

Uses importance sampling: each bin has probability 1/N to realize

Arguments

  • rho: autocorrelation coefficient
  • N: number of gridpoints
  • sigma: long-run variance
  • mue: mean of the AR(1) process

Returns

  • grid_vec: state vector grid
  • P: transition matrix
  • bounds: bin bounds
source
BASEforHANK.Tools.distrSummariesFunction
distrSummaries(distr,c_a_star,c_n_star,n_par,inc,incgross,m_par)

Compute distributional summary statistics, e.g. Gini indexes, top-10% income and wealth shares, and 10%, 50%, and 90%-consumption quantiles.

Arguments

  • distr: joint distribution over bonds, capital and income $(m \times k \times y)$
  • c_a_star,c_n_star: optimal consumption policies with [a] or without [n] capital adjustment
  • n_par::NumericalParameters, m_par::ModelParameters
  • inc: vector of (on grid-)incomes, consisting of labor income (scaled by $\frac{\gamma-\tau^P}{1+\gamma}$, plus labor union-profits), rental income, liquid asset income, capital liquidation income, labor income (scaled by $\frac{1-\tau^P}{1+\gamma}$, without labor union-profits), and labor income (without scaling or labor union-profits)
  • incgross: vector of (on grid-) pre-tax incomes, consisting of labor income (without scaling, plus labor union-profits), rental income, liquid asset income, capital liquidation income, labor income (without scaling or labor union-profits)
source
BASEforHANK.Tools.myinterpolate3Function
myinterpolate3(xgrd1, xgrd2, xgrd3, ygrd, xeval1, xeval2, xeval3)

Trilineary project ygrd on (xgrd1,xgrd2,xgrd3) and use it to interpolate value at (xeval1,xeval2,xeval3).

Example

julia> xgrd = [1.0,6.0];
julia> f((x,y,z)) = x+y+z;
julia> ygrd = f.(collect(Iterators.product(xgrid,xgrid,xgrid));
julia> xeval = [3.0,5.0];
julia> mylinearinterpolate3(xgrd,xgrd,xgrd,ygrd,xeval,xeval,xeval)
2x2x2 Array{Float64,3}:
[:,:,1] =
 9.0 11.0
11.0 13.0
[:,:,2] =
11.0 13.0
13.0 15.0
source