Initial guess in value function iteration

Hi all,

I am reading the code replicating Arellano (2008) (

This code uses value function iteration. I feel confused where did they set the initial value for the value function. I could not see the initial guess around the for loop of iteration.

They only do some kinds of allocating memory for value functions. This is on the part of def init(self, …), at the beginning of the code.
So I wonder, whether this is indeed the initial guess for value functions?, which set all value functions are zeros matrix?

Allocate memory

    self.Vd = np.zeros(ny)
    self.Vc = np.zeros((ny, nB))
    self.V = np.zeros((ny, nB))
    self.Q = np.ones((ny, nB)) * .95  # Initial guess for prices
    self.default_prob = np.empty((ny, nB))

And if they are the inital guess, can I put them inside the loop, rather than in the def__init(…)
so that I do not need to put self. before Vd, Vc,…?

Thank you,

Hi @sunflower2010,

In this model, there are three value functions. There’s the value of paying (Vc), the value of defaulting (Vd), and the overall value of optimizing over the two (V). We can see this by looking at the error calculation in solve().

dist = np.max(np.abs(V_upd - self.V)) 
# where V_upd = np.maximum(self.Vc, Vd_compat)

These are also explained a few lines above equation (4).

As for the initial values, the key is that the pre-allocation is done with specified values (as opposed to junk ones, such as what you might get from running Array{Float64}(undef, 10) in Julia, i.e.):

julia> Array{Float64}(undef, 10)
10-element Array{Float64,1}:

So, in this case, the initial guess for each vector is to make them identically zero. Note that these vectors are repeated/reshaped to account for the B grid, instead of just the y one.

As for your question about the def__init(...)__, I’ll defer to someone who’s more fluent in Python.

— Arnav

1 Like

Thanks @arnavs for your help!

1 Like