Beispiel #1
0
def _full_solution(wages, nonpecs, continuation_values, period_draws_emax_risk,
                   optim_paras):
    """Calculate the full solution of the model.

    In contrast to approximate solution, the Monte Carlo integration is done for each
    state and not only a subset of states.

    """
    period_expected_value_functions = calculate_expected_value_functions(
        wages,
        nonpecs,
        continuation_values,
        period_draws_emax_risk,
        optim_paras["delta"],
    )

    return period_expected_value_functions
Beispiel #2
0
def _compute_lhs_variable(
    wages,
    nonpec,
    continuation_values,
    max_value_functions,
    not_interpolated,
    draws,
    delta,
):
    """Calculate left-hand side variable for all states which are not interpolated.

    The function computes the full solution for a subset of states. Then, the dependent
    variable is the expected value function minus the maximum of value function with the
    expected shocks.

    Parameters
    ----------
    wages : numpy.ndarray
        Array with shape (n_states_in_period, n_choices).
    nonpec : numpy.ndarray
        Array with shape (n_states_in_period, n_choices).
    continuation_values : numpy.ndarray
        Array with shape (n_states_in_period, n_choices).
    max_value_functions : numpy.ndarray
        Array with shape (n_states_in_period,) containing maximum over all value
        functions computed with the expected value of shocks.
    not_interpolated : numpy.ndarray
        Array with shape (n_states_in_period,) containing indicators for simulated
        continuation_values.
    draws : numpy.ndarray
        Array with shape (n_draws, n_choices) containing draws.
    delta : float
        Discount factor.

    """
    expected_value_functions = calculate_expected_value_functions(
        wages[not_interpolated],
        nonpec[not_interpolated],
        continuation_values[not_interpolated],
        draws,
        delta,
    )
    endogenous = expected_value_functions - max_value_functions[
        not_interpolated]

    return endogenous
from respy.shared import calculate_expected_value_functions
import numpy as np
import pandas as pd

# Set up inputs
wage = np.array([1.46178695e04, 9.70115277e03, 1.00000000e00, 1.00000000e00])
nonpec = np.array([0.0, 0.0, -4000.0, 17750.0])
continuation_values = np.array(
    [359856.6202004, 362415.98557173, 375897.29303581, 353287.24408844])
draws = pd.read_pickle("draws.pickle")
delta = 0.95

# Evaluate the integral
res = calculate_expected_value_functions(wage, nonpec, continuation_values,
                                         draws, delta)
print(res)