def compute_reservation_wage(mcm, return_values=False): """ Computes the reservation wage of an instance of the McCall model by finding the smallest w such that V(w) > U. If V(w) > U for all w, then the reservation wage w_bar is set to the lowest wage in mcm.w_vec. If v(w) < U for all w, then w_bar is set to np.inf. Parameters ---------- mcm : an instance of McCallModel return_values : bool (optional, default=False) Return the value functions as well Returns ------- w_bar : scalar The reservation wage """ V, U = solve_mccall_model(mcm) w_idx = np.searchsorted(V - U, 0) if w_idx == len(V): w_bar = np.inf else: w_bar = mcm.w_vec[w_idx] if return_values == False: return w_bar else: return w_bar, V, U
def compute_reservation_wage(mcm): """ Computes the reservation wage of an instance of the McCall model by finding the smallest w such that V(w) > U. If V(w) > U for all w, then the reservation wage w_bar is set to the lowest wage in mcm.w_vec. If v(w) < U for all w, then w_bar is set to np.inf. Parameters ---------- mcm : an instance of McCallModel Returns ------- w_bar : scalar The reservation wage """ V, U = solve_mccall_model(mcm) w_idx = np.searchsorted(V - U, 0) if w_idx == len(V) + 1: w_bar = np.inf else: w_bar = mcm.w_vec[w_idx] return w_bar
""" Generate plots of value of employment and unemployment in the McCall model. """ import numpy as np import matplotlib.pyplot as plt from mccall_bellman_iteration import McCallModel, solve_mccall_model mcm = McCallModel() V, U = solve_mccall_model(mcm) fig, ax = plt.subplots() ax.plot(mcm.w_vec, V, 'b-', lw=2, alpha=0.7, label='$V$') ax.plot(mcm.w_vec, [U] *len(mcm.w_vec) , 'g-', lw=2, alpha=0.7, label='$U$') ax.legend(loc='upper left') ax.grid() plt.show()