Greetings:

As something of a pedagogical exercise, I am taking the Aiyagari model from the Python leture and adding preference shocks with index l_i, following a Markov process independent of that of the income shocks. I adapt the aiyagari_household file accordingly. The main challenge is that functions that admit jit compilation with the option nopython=True give rise to an UntypedAttributeError. The error results from a type inference problem when the command “ravel_multi_index” is called:

UntypedAttributeError: Unknown attribute “ravel_multi_index” of type Module(<module ‘numpy’

To give an example, the populate_Q function looks as follows:

def populate_Q(Q, a_size, z_size, l_size, Pi, Pi_l):

n = a_size * z_size *l_size

for s_i in range(n):

a_i, z_i, l_i = np.unravel_index(s_i, (a_size, z_size, l_size))

for a_i in range(a_size):

for next_z_i in range(z_size):

for next_l_i in range(l_size):

s_i_new = np.ravel_multi_index((a_i, next_z_i, next_l_i),(a_size, z_size, l_size))

Q[s_i, a_i, s_i_new] = Pi[z_i, next_z_i]*Pi_l[l_i, next_l_i]