Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue with HW7 Q5 #72

Open
rhuselid opened this issue May 30, 2019 · 1 comment
Open

issue with HW7 Q5 #72

rhuselid opened this issue May 30, 2019 · 1 comment
Labels
HW7 Discussions related to Homework #7

Comments

@rhuselid
Copy link

I am getting returns for Q5 but it appears to be incorrect. I worked through the logic/structure during office hours, but still running into issues. Do you have any suggestions? Thanks!

state_vals = np.linspace(11, 39, 29)

P = []
for i in range(29):
    probs = np.zeros(29)
    if i == 0:
        probs[0] = 0.5
        probs[1] = 0.5
    elif i == 28:
        probs[28] = 0.5
        probs[27] = 0.5
    else:
        probs[i] = 0.5
        probs[i-1] = 0.25
        probs[i+1] = 0.25
    P.append(probs)

P = np.array(P)


def compute_rwage(c=15, w_vals=state_vals, beta=0.9, max_iter = 10000, tol = 1e-5, n=1000):
    #w = 10 # starting val
    v = w_vals / (1 - beta)
    v_next = np.empty_like(v)
    i = 0
    error = tol + 1 
    
    while error > tol and i < max_iter:
        for j, w in enumerate(w_vals):
            stop_val = w / (1 - beta)
            p_vals = P[i,:]
            exp_val = c + beta * np.sum(v * p_vals)
            v_next = max(stop_val, exp_val)
        error = np.max(np.abs(v_next - v))
        i += 1
        v = v_next
        
    reservation_wages = np.empty_like(w_vals)
    for i, val in enumerate(w_vals):
        p_vals = P[:,i]
        reservation_wages[i] = (1 - beta) *  c + beta * np.sum(v * p_vals)
        
    return reservation_wages, v

result:
e

@jmbejara jmbejara added the HW7 Discussions related to Homework #7 label May 30, 2019
@jmbejara
Copy link
Owner

This looks mostly fine to me. The question doesn't ask anything about a reservation wage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
HW7 Discussions related to Homework #7
Projects
None yet
Development

No branches or pull requests

2 participants