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

[geom_series] Add an exercise #524

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d3f3452
[geom_series] Add an exercise
SylviaZhaooo Jul 22, 2024
3dd6648
Update the code
SylviaZhaooo Jul 22, 2024
7de56eb
Update geom_series.md
SylviaZhaooo Jul 22, 2024
f434325
Update geom_series.md
SylviaZhaooo Jul 22, 2024
b80d11e
Merge branch 'main' into update_geom_series
shlff Jul 23, 2024
e121412
split_exercises
shlff Jul 23, 2024
7e791a7
Update geom_series.md
SylviaZhaooo Jul 23, 2024
d3c7528
Merge branch 'main' into update_geom_series
shlff Jul 24, 2024
07ef18f
shu_edits
shlff Jul 24, 2024
44da5e2
fix
shlff Jul 24, 2024
9871f29
Revise context.md
SylviaZhaooo Jul 24, 2024
68b6cd5
Modify context
SylviaZhaooo Jul 24, 2024
2da76f3
Merge branch 'update_geom_series' of https://github.com/QuantEcon/lec…
SylviaZhaooo Jul 24, 2024
6a051d6
edits
shlff Jul 24, 2024
899a2c6
Merge branch 'update_geom_series' of https://github.com/QuantEcon/lec…
shlff Jul 24, 2024
8157577
Merge branch 'main' into update_geom_series
shlff Jul 25, 2024
5c5a86a
Merge branch 'main' into update_geom_series
mmcky Oct 11, 2024
fc61b03
Update lectures/geom_series.md
shlff Oct 11, 2024
8430391
Clarify mentioned values
SylviaZhaooo Oct 11, 2024
87ddfa2
Merge branch 'update_geom_series' of https://github.com/QuantEcon/lec…
SylviaZhaooo Oct 11, 2024
2bc17a4
Update lectures/geom_series.md
SylviaZhaooo Oct 12, 2024
95b5024
Update lectures/geom_series.md
SylviaZhaooo Oct 12, 2024
0244418
Update lectures/geom_series.md
SylviaZhaooo Oct 12, 2024
06fd373
Update lectures/geom_series.md
SylviaZhaooo Oct 12, 2024
eb8da1c
Merge branch 'main' into update_geom_series
mmcky Oct 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 80 additions & 20 deletions lectures/geom_series.md
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ the value of a lease of duration $T$ approaches the value of a
perpetual lease.

Now we consider two different views of what happens as $r$ and
$g$ covary
$g$ covary.

```{code-cell} ipython3
---
Expand Down Expand Up @@ -852,17 +852,40 @@ so $\frac{\partial p_0}{\partial r}$ will always be negative.
Similarly, $\frac{\partial p_0}{\partial g}>0$ as long as $r>g$, $r>0$ and $g>0$ and $x_0$ is positive, so $\frac{\partial p_0}{\partial g}$
will always be positive.

## Back to the Keynesian multiplier
## Exercises

We will now go back to the case of the Keynesian multiplier and plot the
time path of $y_t$, given that consumption is a constant fraction
of national income, and investment is fixed.
```{exercise-start}
:label: geom_ex1
```
Consider a dynamic Keynesian multiplier model

$$
y_t = c_t + i_t + g_t \ \ \textrm { and } \ \ c_t = b y_{t-1}.
$$

Assume that $i_t=i_0$ and $g_t=g_0$ for all $t \geq 0$.

Plot the time path of $y_t$ with the following initial values:

```{code-cell} ipython3
i_0 = 0.3
g_0 = 0.3
b = 2/3
y_init = 0
T = 100
```

```{exercise-end}
```

```{solution-start} geom_ex1
:class: dropdown
```
SylviaZhaooo marked this conversation as resolved.
Show resolved Hide resolved
```{code-cell} ipython3
---
mystnb:
figure:
caption: "Path of aggregate output tver time"
caption: "Path of aggregate output over time"
name: path_of_aggregate_output_over_time
---
# Function that calculates a path of y
Expand All @@ -873,14 +896,6 @@ def calculate_y(i, b, g, T, y_init):
y[t] = b * y[t-1] + i + g
return y

# Initial values
i_0 = 0.3
g_0 = 0.3
# 2/3 of income goes towards consumption
b = 2/3
y_init = 0
T = 100

fig, ax = plt.subplots()
ax.set_xlabel('$t$')
ax.set_ylabel('$y_t$')
Expand All @@ -893,9 +908,29 @@ plt.show()
In this model, income grows over time, until it gradually converges to
the infinite geometric series sum of income.

We now examine what will
happen if we vary the so-called **marginal propensity to consume**,
i.e., the fraction of income that is consumed
```{solution-end}
```

```{exercise-start}
:label: geom_ex2
```

As an extension to {ref}`geom_ex1`.

Plot the time paths of $y_t$ with the same initial values but varying $b$ values:

```{code-cell} ipython3
bs = (1/3, 2/3, 5/6, 0.9)
```

Interpret the economic effect on $y_t$ of increasing $b$.

```{exercise-end}
```

```{solution-start} geom_ex2
:class: dropdown
```

```{code-cell} ipython3
---
Expand All @@ -904,7 +939,6 @@ mystnb:
caption: "Changing consumption as a fraction of income"
name: changing_consumption_as_fraction_of_income
---
bs = (1/3, 2/3, 5/6, 0.9)

fig,ax = plt.subplots()
ax.set_ylabel('$y_t$')
Expand All @@ -920,7 +954,31 @@ plt.show()
Increasing the marginal propensity to consume $b$ increases the
path of output over time.

Now we will compare the effects on output of increases in investment and government spending.
```{solution-end}
```


```{exercise-start}
:label: geom_ex3
```
Continue from {ref}`geom_ex1`.
First, plot the time paths of $y_t$ using the same initial values but with $i$
taking the values below.
```{code-cell} ipython3
values = [0.3, 0.4]
```


Next, plot the time paths of $y_t$ with the same initial values but let $g$ take
the values mentioned above.
SylviaZhaooo marked this conversation as resolved.
Show resolved Hide resolved

Are the effects on $y_t$ of increasing $i$ and $g$ in these plots the same?
```{exercise-end}
```

```{solution-start} geom_ex3
:class: dropdown
```

```{code-cell} ipython3
---
Expand All @@ -933,7 +991,6 @@ fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(6, 10))
fig.subplots_adjust(hspace=0.3)

x = np.arange(0, T+1)
values = [0.3, 0.4]

for i in values:
y = calculate_y(i, b, g_0, T, y_init)
Expand All @@ -955,3 +1012,6 @@ plt.show()
Notice here, whether government spending increases from 0.3 to 0.4 or
investment increases from 0.3 to 0.4, the shifts in the graphs are
identical.

```{solution-end}
```