-
-
Notifications
You must be signed in to change notification settings - Fork 26
[geom_series] Add an exercise #524
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
Open
SylviaZhaooo
wants to merge
25
commits into
main
Choose a base branch
from
update_geom_series
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 17 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
d3f3452
[geom_series] Add an exercise
SylviaZhaooo 3dd6648
Update the code
SylviaZhaooo 7de56eb
Update geom_series.md
SylviaZhaooo f434325
Update geom_series.md
SylviaZhaooo b80d11e
Merge branch 'main' into update_geom_series
shlff e121412
split_exercises
shlff 7e791a7
Update geom_series.md
SylviaZhaooo d3c7528
Merge branch 'main' into update_geom_series
shlff 07ef18f
shu_edits
shlff 44da5e2
fix
shlff 9871f29
Revise context.md
SylviaZhaooo 68b6cd5
Modify context
SylviaZhaooo 2da76f3
Merge branch 'update_geom_series' of https://github.com/QuantEcon/lec…
SylviaZhaooo 6a051d6
edits
shlff 899a2c6
Merge branch 'update_geom_series' of https://github.com/QuantEcon/lec…
shlff 8157577
Merge branch 'main' into update_geom_series
shlff 5c5a86a
Merge branch 'main' into update_geom_series
mmcky fc61b03
Update lectures/geom_series.md
shlff 8430391
Clarify mentioned values
SylviaZhaooo 87ddfa2
Merge branch 'update_geom_series' of https://github.com/QuantEcon/lec…
SylviaZhaooo 2bc17a4
Update lectures/geom_series.md
SylviaZhaooo 95b5024
Update lectures/geom_series.md
SylviaZhaooo 0244418
Update lectures/geom_series.md
SylviaZhaooo 06fd373
Update lectures/geom_series.md
SylviaZhaooo eb8da1c
Merge branch 'main' into update_geom_series
mmcky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
--- | ||
|
@@ -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 | ||
``` | ||
```{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 | ||
|
@@ -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$') | ||
|
@@ -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 | ||
--- | ||
|
@@ -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$') | ||
|
@@ -920,7 +954,32 @@ 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` with the following values | ||
SylviaZhaooo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
SylviaZhaooo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
```{code-cell} ipython3 | ||
values = [0.3, 0.4] | ||
``` | ||
|
||
First, plot the time paths of $y_t$ using the same initial values but with $i$ | ||
SylviaZhaooo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
taking the values mentioned above. | ||
shlff marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Next, plot the time paths of $y_t$ with the same initial values but let $g$ take | ||
the values abovementioned. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @SylviaZhaooo not 100% sure which values |
||
|
||
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 | ||
--- | ||
|
@@ -933,7 +992,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) | ||
|
@@ -955,3 +1013,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} | ||
``` |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.