Initial guess in value function iteration


#1

Hi all,

I am reading the code replicating Arellano (2008) (https://lectures.quantecon.org/py/arellano.html#Computation)

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,


#2

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}:
 4.531516185190089e217 
 3.582491196956299e246 
 3.033892022055688e-152
 5.812416441578188e180 
 5.815436000672467e180 
 9.831979556081223e242 
 8.307442184459752e-72 
 5.464537352776783e-95 
 1.817364626991996e-152
 5.519718676694e-311   

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


#3

Thanks @arnavs for your help!