Skip to content

Commit

Permalink
Rename delta -> disutility_of_work throughout
Browse files Browse the repository at this point in the history
  • Loading branch information
timmens committed Feb 28, 2024
1 parent a61c5dc commit 0a94247
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 31 deletions.
8 changes: 4 additions & 4 deletions src/lcm/get_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def get_model(model: str):
model=PHELPS_DEATON_FIVE_PERIODS,
params={
"beta": 1.0,
"utility": {"delta": 1.0},
"utility": {"disutility_of_work": 1.0},
"next_wealth": {
"interest_rate": 0.05,
"wage": 1.0,
Expand All @@ -115,18 +115,18 @@ def get_model(model: str):
model=ISKHAKOV_2017_FIVE_PERIODS,
params={
"beta": 0.98,
"utility": {"delta": 1.0},
"utility": {"disutility_of_work": 1.0},
"next_wealth": {
"interest_rate": 0.0,
"wage": 20.0,
},
},
),
"iskhakov_2017_low_delta": ModelAndParams(
"iskhakov_2017_low_disutility_of_work": ModelAndParams(
model=ISKHAKOV_2017_THREE_PERIODS,
params={
"beta": 0.98,
"utility": {"delta": 0.1},
"utility": {"disutility_of_work": 0.1},
"next_wealth": {
"interest_rate": 0.0,
"wage": 20.0,
Expand Down
4 changes: 3 additions & 1 deletion tests/test_analytical_solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

TEST_CASES = {
"iskhakov_2017_five_periods": get_model("iskhakov_2017_five_periods"),
"iskhakov_2017_low_delta": get_model("iskhakov_2017_low_delta"),
"iskhakov_2017_low_disutility_of_work": get_model(
"iskhakov_2017_low_disutility_of_work",
),
}


Expand Down
16 changes: 8 additions & 8 deletions tests/test_entry_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def test_create_compute_conditional_continuation_value():

params = {
"beta": 1.0,
"utility": {"delta": 1.0},
"utility": {"disutility_of_work": 1.0},
"next_wealth": {
"interest_rate": 0.05,
"wage": 1.0,
Expand Down Expand Up @@ -176,15 +176,15 @@ def test_create_compute_conditional_continuation_value():
params=params,
vf_arr=None,
)
assert val == utility(consumption=30.0, working=0, delta=1.0)
assert val == utility(consumption=30.0, working=0, disutility_of_work=1.0)


def test_create_compute_conditional_continuation_value_with_discrete_model():
model = process_model(PHELPS_DEATON_FULLY_DISCRETE)

params = {
"beta": 1.0,
"utility": {"delta": 1.0},
"utility": {"disutility_of_work": 1.0},
"next_wealth": {
"interest_rate": 0.05,
"wage": 1.0,
Expand Down Expand Up @@ -219,7 +219,7 @@ def test_create_compute_conditional_continuation_value_with_discrete_model():
params=params,
vf_arr=None,
)
assert val == utility(consumption=2, working=0, delta=1.0)
assert val == utility(consumption=2, working=0, disutility_of_work=1.0)


# ======================================================================================
Expand All @@ -232,7 +232,7 @@ def test_create_compute_conditional_continuation_policy():

params = {
"beta": 1.0,
"utility": {"delta": 1.0},
"utility": {"disutility_of_work": 1.0},
"next_wealth": {
"interest_rate": 0.05,
"wage": 1.0,
Expand Down Expand Up @@ -268,15 +268,15 @@ def test_create_compute_conditional_continuation_policy():
vf_arr=None,
)
assert policy == 2
assert val == utility(consumption=30.0, working=0, delta=1.0)
assert val == utility(consumption=30.0, working=0, disutility_of_work=1.0)


def test_create_compute_conditional_continuation_policy_with_discrete_model():
model = process_model(PHELPS_DEATON_FULLY_DISCRETE)

params = {
"beta": 1.0,
"utility": {"delta": 1.0},
"utility": {"disutility_of_work": 1.0},
"next_wealth": {
"interest_rate": 0.05,
"wage": 1.0,
Expand Down Expand Up @@ -312,4 +312,4 @@ def test_create_compute_conditional_continuation_policy_with_discrete_model():
vf_arr=None,
)
assert policy == 1
assert val == utility(consumption=2, working=0, delta=1.0)
assert val == utility(consumption=2, working=0, disutility_of_work=1.0)
4 changes: 2 additions & 2 deletions tests/test_model_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def test_get_utility_and_feasibility_function():

params = {
"beta": 1.0,
"utility": {"delta": 1.0},
"utility": {"disutility_of_work": 1.0},
"next_wealth": {
"interest_rate": 0.05,
"wage": 1.0,
Expand Down Expand Up @@ -86,7 +86,7 @@ def test_get_utility_and_feasibility_function():
utility(
consumption=consumption,
working=1 - retirement,
delta=1.0,
disutility_of_work=1.0,
),
)
assert_array_equal(f, jnp.array([True, True, False]))
Expand Down
2 changes: 1 addition & 1 deletion tests/test_next_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_get_next_state_function_with_solve_target():

params = {
"beta": 1.0,
"utility": {"delta": 1.0},
"utility": {"disutility_of_work": 1.0},
"next_wealth": {
"interest_rate": 0.05,
},
Expand Down
24 changes: 12 additions & 12 deletions tests/test_simulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def simulate_inputs():
def test_simulate_using_raw_inputs(simulate_inputs):
params = {
"beta": 1.0,
"utility": {"delta": 1.0},
"utility": {"disutility_of_work": 1.0},
"next_wealth": {
"interest_rate": 0.05,
},
Expand Down Expand Up @@ -117,7 +117,7 @@ def _model_solution(n_periods):

params = {
"beta": 1.0,
"utility": {"delta": 1.0},
"utility": {"disutility_of_work": 1.0},
"next_wealth": {
"interest_rate": 0.05,
"wage": 1.0,
Expand Down Expand Up @@ -183,7 +183,7 @@ def test_effect_of_beta_on_last_period():

params = {
"beta": None,
"utility": {"delta": 1.0},
"utility": {"disutility_of_work": 1.0},
"next_wealth": {
"interest_rate": 0.05,
},
Expand All @@ -193,7 +193,7 @@ def test_effect_of_beta_on_last_period():
params_low = params.copy()
params_low["beta"] = 0.5

# high delta
# high disutility_of_work
params_high = params.copy()
params_high["beta"] = 0.99

Expand Down Expand Up @@ -228,7 +228,7 @@ def test_effect_of_beta_on_last_period():
).all()


def test_effect_of_delta():
def test_effect_of_disutility_of_work():
model = {**PHELPS_DEATON, "n_periods": 5}

# Model solutions
Expand All @@ -237,19 +237,19 @@ def test_effect_of_delta():

params = {
"beta": 1.0,
"utility": {"delta": None},
"utility": {"disutility_of_work": None},
"next_wealth": {
"interest_rate": 0.05,
},
}

# low delta
# low disutility_of_work
params_low = params.copy()
params_low["utility"]["delta"] = 0.2
params_low["utility"]["disutility_of_work"] = 0.2

# high delta
# high disutility_of_work
params_high = params.copy()
params_high["utility"]["delta"] = 1.5
params_high["utility"]["disutility_of_work"] = 1.5

# solutions
solution_low = solve_model(params_low)
Expand Down Expand Up @@ -325,7 +325,7 @@ def test_compute_targets():
}

def f_a(a, params):
return a + params["delta"]
return a + params["disutility_of_work"]

def f_b(b, params): # noqa: ARG001
return b
Expand All @@ -336,7 +336,7 @@ def f_b(b, params): # noqa: ARG001
processed_results=processed_results,
targets=["fa", "fb"],
model_functions=model_functions,
params={"delta": -1.0},
params={"disutility_of_work": -1.0},
)
expected = {
"fa": jnp.arange(3) - 1.0,
Expand Down
6 changes: 3 additions & 3 deletions tests/test_stochastic.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ def test_get_lcm_function_with_solve_target():

@pytest.fixture()
def model_and_params():
def utility(consumption, working, health, delta, gamma):
return jnp.log(consumption) + (gamma * health - delta) * working
def utility(consumption, working, health, disutility_of_work, gamma):
return jnp.log(consumption) + (gamma * health - disutility_of_work) * working

def next_wealth(wealth, consumption, working, wage, interest_rate):
return (1 + interest_rate) * (wealth - consumption) + wage * working
Expand Down Expand Up @@ -113,7 +113,7 @@ def consumption_constraint(consumption, wealth):

params = {
"beta": 0.95,
"utility": {"delta": 0.5, "gamma": 0.5},
"utility": {"disutility_of_work": 0.5, "gamma": 0.5},
"next_wealth": {"interest_rate": 0.05, "wage": 10.0},
"next_health": {},
"consumption_constraint": {},
Expand Down

0 comments on commit 0a94247

Please sign in to comment.