Questions


Related Questions:


Questions

Asked By :  vedika rana
Answers1

Econ nbsp 6 3 0 5 coding assignment

ECON 6305: Coding Assignment #1 Aaron Betz abc University 1 Write your own IRF code Suppose you have the following solution to a model from Dolo (Problem 1 is just a Python exercise, you will not actually be using Dolo). You will generate impulse response functions with these formulas. z_(t)=z_(t-1)\rho +(1-\rho )/(b)ar (z)+lon_(t) k_(t)=k_(t-1)(1-\delta )+2.16(z_(t-1)-1)+0.017(k_(t-1)-9.354)+\delta 9.354 1.1 Capital and Z impulses Where \rho =0.9(,)/(b)ar (z)=1 , and \delta =0.025 . You can solve forward to time t=1 from time t=0 (steady state) when z_(0)()/(b)=ar (z)=1 and k_(0)()/(b)=ar (k)=9.354 given some initial shock lon_(0) . To continue to solve forward assume lon_(1)=0 and that every following lon_(t) is zero. Write a Python function to generate an impulse of length n , given an initial shock, lon_(0) . Show your code and graph impulses (for both capital and z ) of length 40 , with an initial shock lon_(0)=0.01 . 1.2 Labor and output impulse Now that you have a 40 period series of all the necessary state variables, k_(t) and z_(t) solve for n_(t) and then y_(t) given the following formulas from Dolo. n_(t)=0.33+0.809(z_(t-1)-1)+0.025(k_(t-1)-9.354) y_(t)=z_(t)n_(t)^(0.67)k_(t-1)^(0.33) Keep in mind you will need to solve for labor, n_(t) , before you solve for output, y_(t) . Once you have solved all 40 periods graph both labor and output over time (use separate graphs). 1




Answers :

0

Sure! Let's break down the task and walk through each part step-by-step. We will write Python code to generate impulse response functions for the given model.

Step 1: Define the Model

Given formulas:

  1. zt=zt1ρ+(1ρ)/(b)ar(z)+lontz_t = z_{t-1} \rho + (1 - \rho)/(b)ar(z) + \text{lon}_t
    • Parameters: ρ=0.9\rho = 0.9, (b)ar(z)=1(b)ar(z) = 1
  2. kt=kt1(1δ)+2.16(zt11)+0.017(kt19.354)+δ×9.354k_t = k_{t-1}(1 - \delta) + 2.16(z_{t-1} - 1) + 0.017(k_{t-1} - 9.354) + \delta \times 9.354
    • Parameters: δ=0.025\delta = 0.025

Step 2: Write Python Function to Generate Impulses

We'll start with a function to generate the impulse response for ztz_t and ktk_t.

import numpy as np
import matplotlib.pyplot as plt

def generate_impulses(n, lon_0):
    # Initialize parameters
    rho = 0.9
    bar_z = 1
    delta = 0.025
    
    # Initial conditions
    z_t = [1]
    k_t = [9.354]
    
    lon = [lon_0] + [0] * (n - 1)
    
    # Generate the series for z_t and k_t
    for t in range(1, n):
        z_t_next = z_t[-1] * rho + (1 - rho) * bar_z + lon[t]
        z_t.append(z_t_next)
        
        k_t_next = k_t[-1] * (1 - delta) + 2.16 * (z_t[-2] - 1) + 0.017 * (k_t[-1] - 9.354) + delta * 9.354
        k_t.append(k_t_next)
    
    return z_t, k_t

# Generate 40 periods with an initial shock lon_0 = 0.01
n = 40
lon_0 = 0.01
z_t, k_t = generate_impulses(n, lon_0)

# Plot the impulses
plt.figure(figsize=(12, 6))

plt.subplot(1, 2, 1)
plt.plot(z_t, label="z_t")
plt.title("Impulse Response of z_t")
plt.xlabel("Periods")
plt.ylabel("z_t")
plt.legend()

plt.subplot(1, 2, 2)
plt.plot(k_t, label="k_t")
plt.title("Impulse Response of k_t")
plt.xlabel("Periods")
plt.ylabel("k_t")
plt.legend()

plt.tight_layout()
plt.show()

Step 3: Calculate ntn_t and yty_t

Given formulas:

  1. nt=0.33+0.809(zt11)+0.025(kt19.354)n_t = 0.33 + 0.809(z_{t-1} - 1) + 0.025(k_{t-1} - 9.354)
  2. yt=ztnt0.67kt10.33y_t = z_t \cdot n_t^{0.67} \cdot k_{t-1}^{0.33}

We'll calculate these and plot them.

def calculate_labor_and_output(z_t, k_t):
    n_t = []
    y_t = []
    
    for t in range(1, len(z_t)):
        n_t_next = 0.33 + 0.809 * (z_t[t-1] - 1) + 0.025 * (k_t[t-1] - 9.354)
        n_t.append(n_t_next)
        
        y_t_next = z_t[t] * (n_t_next**0.67) * (k_t[t-1]**0.33)
        y_t.append(y_t_next)
    
    return n_t, y_t

# Calculate labor and output
n_t, y_t = calculate_labor_and_output(z_t, k_t)

# Plot labor and output
plt.figure(figsize=(12, 6))

plt.subplot(1, 2, 1)
plt.plot(n_t, label="n_t")
plt.title("Labor over Time")
plt.xlabel("Periods")
plt.ylabel("n_t")
plt.legend()

plt.subplot(1, 2, 2)
plt.plot(y_t, label="y_t")
plt.title("Output over Time")
plt.xlabel("Periods")
plt.ylabel("y_t")
plt.legend()

plt.tight_layout()
plt.show()

Summary

  • The first part of the code generates the impulse response functions for ztz_t and ktk_t.
  • The second part calculates ntn_t and yty_t using these values and then plots the results.

This process allows us to visualize the impact of an initial shock over time.


Answered By

Julie Jones

Your Answer



XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Write your answer, be as detailed as possible...

Reply as a guest

Required but never shown

Try Now AI powered Content Automation