diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f31637e96..b2bb5452f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,6 +32,11 @@ jobs: shell: bash -l {0} run: | jb build lectures --path-output ./ + - name: Save Build as Artifact + uses: actions/upload-artifact@v1 + with: + name: _build + path: _build - name: Preview Deploy to Netlify uses: nwtgck/actions-netlify@v1.1 with: diff --git a/.gitignore b/.gitignore index bb4c651eb..cd43ec824 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -lectures/_build \ No newline at end of file +_build/ +lectures/_build/ diff --git a/lectures/_config.yml b/lectures/_config.yml index a26ef5563..b1b3e26de 100644 --- a/lectures/_config.yml +++ b/lectures/_config.yml @@ -5,7 +5,10 @@ description: This website presents a set of lectures on quantitative economic mo execute: execute_notebooks: "cache" - timeout: 60 + timeout: 600 + +bibtex_bibfiles: + - _static/quant-econ.bib bibtex_bibfiles: - _static/quant-econ.bib @@ -50,6 +53,7 @@ sphinx: og_logo_url: https://assets.quantecon.org/img/qe-og-logo.png description: This website presents a set of lectures on quantitative economic modeling, designed and written by Thomas J. Sargent and John Stachurski. keywords: Python, QuantEcon, Quantitative Economics, Economics, Sloan, Alfred P. Sloan Foundation, Tom J. Sargent, John Stachurski + mathjax_path: https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js rediraffe_redirects: index_toc.md: intro.md tojupyter_static_file_path: ["source/_static", "_static"] diff --git a/lectures/cake_eating_numerical.md b/lectures/cake_eating_numerical.md index f9b1eae7f..108a5f2c2 100644 --- a/lectures/cake_eating_numerical.md +++ b/lectures/cake_eating_numerical.md @@ -72,7 +72,8 @@ where $u$ is the CRRA utility function. The analytical solutions for the value function and optimal policy were found to be as follows. -```{literalinclude} _static/lecture_specific/cake_eating_numerical/analytical.py +```{code-cell} python3 +:load: _static/lecture_specific/cake_eating_numerical/analytical.py ``` Our first aim is to obtain these analytical solutions numerically. diff --git a/lectures/coleman_policy_iter.md b/lectures/coleman_policy_iter.md index f1920f0f2..4ef3b82e3 100644 --- a/lectures/coleman_policy_iter.md +++ b/lectures/coleman_policy_iter.md @@ -267,7 +267,8 @@ As in our {doc}`previous study `, we continue to assume that This will allow us to compare our results to the analytical solutions -```{literalinclude} _static/lecture_specific/optgrowth/cd_analytical.py +```{code-cell} python3 +:load: _static/lecture_specific/optgrowth/cd_analytical.py ``` As discussed above, our plan is to solve the model using time iteration, which @@ -278,7 +279,8 @@ For this we need access to the functions $u'$ and $f, f'$. These are available in a class called `OptimalGrowthModel` that we constructed in an {doc}`earlier lecture `. -```{literalinclude} _static/lecture_specific/optgrowth_fast/ogm.py +```{code-cell} python3 +:load: _static/lecture_specific/optgrowth_fast/ogm.py ``` Now we implement a method called `euler_diff`, which returns @@ -374,7 +376,8 @@ Here is a function called `solve_model_time_iter` that takes an instance of `OptimalGrowthModel` and returns an approximation to the optimal policy, using time iteration. -```{literalinclude} _static/lecture_specific/coleman_policy_iter/solve_time_iter.py +```{code-cell} python3 +:load: _static/lecture_specific/coleman_policy_iter/solve_time_iter.py ``` Let's call it: @@ -439,7 +442,8 @@ Compute and plot the optimal policy. We use the class `OptimalGrowthModel_CRRA` from our {doc}`VFI lecture `. -```{literalinclude} _static/lecture_specific/optgrowth_fast/ogm_crra.py +```{code-cell} python3 +:load: _static/lecture_specific/optgrowth_fast/ogm_crra.py ``` Let's create an instance: diff --git a/lectures/egm_policy_iter.md b/lectures/egm_policy_iter.md index e9690c6d4..5b6a4f1b1 100644 --- a/lectures/egm_policy_iter.md +++ b/lectures/egm_policy_iter.md @@ -160,12 +160,14 @@ where This will allow us to make comparisons with the analytical solutions -```{literalinclude} _static/lecture_specific/optgrowth/cd_analytical.py +```{code-cell} python3 +:load: _static/lecture_specific/optgrowth/cd_analytical.py ``` We reuse the `OptimalGrowthModel` class -```{literalinclude} _static/lecture_specific/optgrowth_fast/ogm.py +```{code-cell} python3 +:load: _static/lecture_specific/optgrowth_fast/ogm.py ``` ### The Operator @@ -216,7 +218,8 @@ grid = og.grid Here's our solver routine: -```{literalinclude} _static/lecture_specific/coleman_policy_iter/solve_time_iter.py +```{code-cell} python3 +:load: _static/lecture_specific/coleman_policy_iter/solve_time_iter.py ``` Let's call it: diff --git a/lectures/ifp.md b/lectures/ifp.md index 429759d72..0820b7beb 100644 --- a/lectures/ifp.md +++ b/lectures/ifp.md @@ -475,7 +475,8 @@ start to iterate. The following function iterates to convergence and returns the approximate optimal policy. -```{literalinclude} _static/lecture_specific/coleman_policy_iter/solve_time_iter.py +```{code-cell} python3 +:load: _static/lecture_specific/coleman_policy_iter/solve_time_iter.py ``` Let's carry this out using the default parameters of the `IFP` class: @@ -518,7 +519,8 @@ In this case, our income fluctuation problem is just a cake eating problem. We know that, in this case, the value function and optimal consumption policy are given by -```{literalinclude} _static/lecture_specific/cake_eating_numerical/analytical.py +```{code-cell} python3 +:load: _static/lecture_specific/cake_eating_numerical/analytical.py ``` Let's see if we match up: diff --git a/lectures/markov_perf.md b/lectures/markov_perf.md index 3721e2c12..fc4a920e5 100644 --- a/lectures/markov_perf.md +++ b/lectures/markov_perf.md @@ -431,7 +431,8 @@ Consider the previously presented duopoly model with parameter values of: From these, we compute the infinite horizon MPE using the preceding code -```{literalinclude} _static/lecture_specific/markov_perf/duopoly_mpe.py +```{code-cell} python3 +:load: _static/lecture_specific/markov_perf/duopoly_mpe.py ``` Running the code produces the following output. diff --git a/lectures/optgrowth.md b/lectures/optgrowth.md index 8da671358..c1ed2e4a5 100644 --- a/lectures/optgrowth.md +++ b/lectures/optgrowth.md @@ -624,7 +624,8 @@ whether our code works for this particular case. In Python, the functions above can be expressed as: -```{literalinclude} _static/lecture_specific/optgrowth/cd_analytical.py +```{code-cell} python3 +:load: _static/lecture_specific/optgrowth/cd_analytical.py ``` Next let's create an instance of the model with the above primitives and assign it to the variable `og`. @@ -700,7 +701,8 @@ We are clearly getting closer. We can write a function that iterates until the difference is below a particular tolerance level. -```{literalinclude} _static/lecture_specific/optgrowth/solve_model.py +```{code-cell} python3 +:load: _static/lecture_specific/optgrowth/solve_model.py ``` Let's use this function to compute an approximate solution at the defaults. diff --git a/lectures/optgrowth_fast.md b/lectures/optgrowth_fast.md index fb8d8d31f..eeea025b4 100644 --- a/lectures/optgrowth_fast.md +++ b/lectures/optgrowth_fast.md @@ -103,7 +103,8 @@ In particular, the algorithm is unchanged, and the only difference is in the imp As before, we will be able to compare with the true solutions -```{literalinclude} _static/lecture_specific/optgrowth/cd_analytical.py +```{code-cell} python3 +:load: _static/lecture_specific/optgrowth/cd_analytical.py ``` ## Computation @@ -125,7 +126,8 @@ class. This is where we sacrifice flexibility in order to gain more speed. -```{literalinclude} _static/lecture_specific/optgrowth_fast/ogm.py +```{code-cell} python3 +:load: _static/lecture_specific/optgrowth_fast/ogm.py ``` The class includes some methods such as `u_prime` that we do not need now @@ -186,7 +188,8 @@ def T(v, og): We use the `solve_model` function to perform iteration until convergence. -```{literalinclude} _static/lecture_specific/optgrowth/solve_model.py +```{code-cell} python3 +:load: _static/lecture_specific/optgrowth/solve_model.py ``` Let's compute the approximate solution at the default parameters. @@ -317,7 +320,8 @@ value function iteration, the JIT-compiled code is usually an order of magnitude Here's our CRRA version of `OptimalGrowthModel`: -```{literalinclude} _static/lecture_specific/optgrowth_fast/ogm_crra.py +```{code-cell} python3 +:load: _static/lecture_specific/optgrowth_fast/ogm_crra.py ``` Let's create an instance: