Skip to content

Commit

Permalink
Merge branch 'main' into update_markov_chain_I
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiarui-ZH authored Oct 11, 2024
2 parents ab23359 + 905b7f9 commit 7420047
Show file tree
Hide file tree
Showing 47 changed files with 2,581 additions and 5,392 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/collab.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Install Build Software
shell: bash -l {0}
run: |
pip install jupyter-book==0.15.1 docutils==0.17.1 quantecon-book-theme==0.7.1 sphinx-tojupyter==0.3.0 sphinxext-rediraffe==0.2.7 sphinx-exercise==0.4.1 sphinxcontrib-youtube==1.1.0 sphinx-togglebutton==0.3.1 arviz==0.13.0 sphinx_proof==0.1.3
pip install jupyter-book==0.15.1 docutils==0.17.1 quantecon-book-theme==0.7.2 sphinx-tojupyter==0.3.0 sphinxext-rediraffe==0.2.7 sphinx-exercise==0.4.1 sphinxcontrib-youtube==1.1.0 sphinx-togglebutton==0.3.1 arviz==0.13.0 sphinx_proof==0.2.0 sphinx_reredirects==0.1.3
# Build of HTML (Execution Testing)
- name: Build HTML
shell: bash -l {0}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
- name: Deploy website to gh-pages
uses: peaceiris/actions-gh-pages@v3
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: _build/html/
Expand Down
7 changes: 4 additions & 3 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@ channels:
- conda-forge
dependencies:
- python=3.11
- anaconda=2024.02
- anaconda=2024.06
- pip
- pip:
- jupyter-book==0.15.1
- docutils==0.17.1
- quantecon-book-theme==0.7.1
- quantecon-book-theme==0.7.2
- sphinx-tojupyter==0.3.0
- sphinxext-rediraffe==0.2.7
- sphinx-exercise==0.4.1
- sphinx-proof==0.1.3
- sphinx-proof==0.2.0
- ghp-import==1.1.0
- sphinxcontrib-youtube==1.1.0
- sphinx-togglebutton==0.3.1
- sphinx_reredirects==0.1.3
# Sandpit Requirements
# - PuLP
# - cvxpy
Expand Down
11 changes: 8 additions & 3 deletions lectures/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ latex:
targetname: quantecon-python-intro.tex

sphinx:
extra_extensions: [sphinx_multitoc_numbering, sphinxext.rediraffe, sphinx_exercise, sphinx_togglebutton, sphinx.ext.intersphinx, sphinx_proof, sphinx_tojupyter]
extra_extensions: [sphinx_multitoc_numbering, sphinxext.rediraffe, sphinx_exercise, sphinx_togglebutton, sphinx.ext.intersphinx, sphinx_proof, sphinx_tojupyter, sphinx_reredirects]
config:
bibtex_reference_style: author_year
# false-positive links
Expand All @@ -45,6 +45,7 @@ sphinx:
width: 80%
nb_code_prompt_show: "Show {type}"
suppress_warnings: [mystnb.unknown_mime_type, myst.domains]
proof_minimal_theme: true
# -------------
html_js_files:
- https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js
Expand All @@ -70,11 +71,12 @@ sphinx:
analytics:
google_analytics_id: G-QDS1YRJNGM
launch_buttons:
notebook_interface : classic # The interface interactive links will activate ["classic", "jupyterlab"]
binderhub_url : https://mybinder.org # The URL of the BinderHub (e.g., https://mybinder.org)
colab_url : https://colab.research.google.com
thebe : false # Add a thebe button to pages (requires the repository to run on Binder)
intersphinx_mapping:
intermediate:
- https://python.quantecon.org/
- null
pyprog:
- https://python-programming.quantecon.org/
- null
Expand Down Expand Up @@ -107,6 +109,9 @@ sphinx:
mathjax_path: https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js
rediraffe_redirects:
index_toc.md: intro.md
# Remote Redirects
redirects:
ak2: https://python.quantecon.org/ak2.html
tojupyter_static_file_path: ["_static"]
tojupyter_target_html: true
tojupyter_urlpath: "https://intro.quantecon.org/"
Expand Down
133 changes: 133 additions & 0 deletions lectures/_static/lecture_specific/inequality/data.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "258b4bc9-2964-470a-8010-05c2162f5e05",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: wbgapi in /Users/longye/anaconda3/lib/python3.10/site-packages (1.0.12)\n",
"Requirement already satisfied: plotly in /Users/longye/anaconda3/lib/python3.10/site-packages (5.22.0)\n",
"Requirement already satisfied: requests in /Users/longye/anaconda3/lib/python3.10/site-packages (from wbgapi) (2.31.0)\n",
"Requirement already satisfied: tabulate in /Users/longye/anaconda3/lib/python3.10/site-packages (from wbgapi) (0.9.0)\n",
"Requirement already satisfied: PyYAML in /Users/longye/anaconda3/lib/python3.10/site-packages (from wbgapi) (6.0)\n",
"Requirement already satisfied: tenacity>=6.2.0 in /Users/longye/anaconda3/lib/python3.10/site-packages (from plotly) (8.4.1)\n",
"Requirement already satisfied: packaging in /Users/longye/anaconda3/lib/python3.10/site-packages (from plotly) (23.1)\n",
"Requirement already satisfied: urllib3<3,>=1.21.1 in /Users/longye/anaconda3/lib/python3.10/site-packages (from requests->wbgapi) (1.26.16)\n",
"Requirement already satisfied: charset-normalizer<4,>=2 in /Users/longye/anaconda3/lib/python3.10/site-packages (from requests->wbgapi) (2.0.4)\n",
"Requirement already satisfied: idna<4,>=2.5 in /Users/longye/anaconda3/lib/python3.10/site-packages (from requests->wbgapi) (3.4)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /Users/longye/anaconda3/lib/python3.10/site-packages (from requests->wbgapi) (2024.6.2)\n"
]
}
],
"source": [
"!pip install wbgapi plotly\n",
"\n",
"import pandas as pd\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import random as rd\n",
"import wbgapi as wb\n",
"import plotly.express as px\n",
"\n",
"url = 'https://media.githubusercontent.com/media/QuantEcon/high_dim_data/main/SCF_plus/SCF_plus_mini.csv'\n",
"df = pd.read_csv(url)\n",
"df_income_wealth = df.dropna()"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "9630a07a-fce5-474e-92af-104e67e82be5",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: quantecon in /Users/longye/anaconda3/lib/python3.10/site-packages (0.7.1)\n",
"Requirement already satisfied: requests in /Users/longye/anaconda3/lib/python3.10/site-packages (from quantecon) (2.31.0)\n",
"Requirement already satisfied: numpy>=1.17.0 in /Users/longye/anaconda3/lib/python3.10/site-packages (from quantecon) (1.26.3)\n",
"Requirement already satisfied: numba>=0.49.0 in /Users/longye/anaconda3/lib/python3.10/site-packages (from quantecon) (0.59.1)\n",
"Requirement already satisfied: sympy in /Users/longye/anaconda3/lib/python3.10/site-packages (from quantecon) (1.12)\n",
"Requirement already satisfied: scipy>=1.5.0 in /Users/longye/anaconda3/lib/python3.10/site-packages (from quantecon) (1.12.0)\n",
"Requirement already satisfied: llvmlite<0.43,>=0.42.0dev0 in /Users/longye/anaconda3/lib/python3.10/site-packages (from numba>=0.49.0->quantecon) (0.42.0)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /Users/longye/anaconda3/lib/python3.10/site-packages (from requests->quantecon) (2024.6.2)\n",
"Requirement already satisfied: idna<4,>=2.5 in /Users/longye/anaconda3/lib/python3.10/site-packages (from requests->quantecon) (3.4)\n",
"Requirement already satisfied: charset-normalizer<4,>=2 in /Users/longye/anaconda3/lib/python3.10/site-packages (from requests->quantecon) (2.0.4)\n",
"Requirement already satisfied: urllib3<3,>=1.21.1 in /Users/longye/anaconda3/lib/python3.10/site-packages (from requests->quantecon) (1.26.16)\n",
"Requirement already satisfied: mpmath>=0.19 in /Users/longye/anaconda3/lib/python3.10/site-packages (from sympy->quantecon) (1.3.0)\n"
]
}
],
"source": [
"!pip install quantecon\n",
"import quantecon as qe\n",
"\n",
"varlist = ['n_wealth', # net wealth \n",
" 't_income', # total income\n",
" 'l_income'] # labor income\n",
"\n",
"df = df_income_wealth\n",
"years = df.year.unique()\n",
"\n",
"# create lists to store Gini for each inequality measure\n",
"results = {}\n",
"\n",
"for var in varlist:\n",
" # create lists to store Gini\n",
" gini_yr = []\n",
" for year in years:\n",
" # repeat the observations according to their weights\n",
" counts = list(round(df[df['year'] == year]['weights'] ))\n",
" y = df[df['year'] == year][var].repeat(counts)\n",
" y = np.asarray(y)\n",
" \n",
" rd.shuffle(y) # shuffle the sequence\n",
" \n",
" # calculate and store Gini\n",
" gini = qe.gini_coefficient(y)\n",
" gini_yr.append(gini)\n",
" \n",
" results[var] = gini_yr\n",
"\n",
"# Convert to DataFrame\n",
"results = pd.DataFrame(results, index=years)\n",
"results.to_csv(\"usa-gini-nwealth-tincome-lincome.csv\", index_label='year')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d59e876b-2f77-4fa7-b79a-8e455ad82d43",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
year,n_wealth,t_income,l_income
1950,0.8257332034366338,0.44248654139458626,0.5342948198773412
1953,0.8059487586599329,0.4264544060935945,0.5158978980963702
1956,0.8121790488050616,0.44426942873399283,0.5349293526208142
1959,0.795206874163792,0.43749348077061573,0.5213985948309416
1962,0.8086945076579359,0.4435843103853645,0.5345127915054341
1965,0.7904149225687935,0.43763715466663444,0.7487860020887753
1968,0.7982885066993497,0.4208620794438902,0.5242396427381545
1971,0.7911574835420259,0.4233344246090255,0.5576454812313466
1977,0.7571418922185215,0.46187678800902543,0.5704448110072049
1983,0.7494335400643013,0.439345618464469,0.5662220844385915
1989,0.7715705301674302,0.5115249581654197,0.601399568747142
1992,0.7508126614055308,0.4740650672076798,0.5983592657979563
1995,0.7569492388110265,0.48965523558400603,0.5969779516716903
1998,0.7603291991801185,0.49117441585168614,0.5774462841723305
2001,0.7816118750507056,0.5239092994681135,0.6042739644967272
2004,0.7700355469522361,0.4884350383903255,0.5981432201792727
2007,0.7821413776486978,0.5197156312086187,0.626345219575322
2010,0.8250825295193438,0.5195972120145615,0.6453653328291903
2013,0.8227698931835303,0.531400174984336,0.6498682917772644
2016,0.8342975903562234,0.5541400068900825,0.6706846793375284
1950,0.8257332034366366,0.44248654139458743,0.534294819877344
1953,0.805948758659935,0.4264544060935942,0.5158978980963682
1956,0.8121790488050612,0.44426942873399367,0.5349293526208106
1959,0.7952068741637912,0.43749348077061534,0.5213985948309414
1962,0.8086945076579386,0.44358431038536356,0.5345127915054446
1965,0.7904149225687949,0.4376371546666344,0.7487860020887701
1968,0.7982885066993503,0.4208620794438885,0.5242396427381534
1971,0.7911574835420282,0.4233344246090255,0.5576454812313462
1977,0.7571418922185215,0.46187678800902554,0.57044481100722
1983,0.749433540064301,0.4393456184644682,0.5662220844385925
1989,0.7715705301674285,0.5115249581654115,0.6013995687471289
1992,0.7508126614055305,0.4740650672076754,0.5983592657979544
1995,0.7569492388110274,0.4896552355840001,0.5969779516717039
1998,0.7603291991801172,0.49117441585168525,0.5774462841723346
2001,0.781611875050703,0.523909299468113,0.6042739644967232
2004,0.7700355469522372,0.48843503839032354,0.5981432201792916
2007,0.782141377648698,0.5197156312086207,0.6263452195753227
2010,0.825082529519342,0.5195972120145641,0.6453653328291843
2013,0.8227698931835299,0.5314001749843426,0.6498682917772886
2016,0.8342975903562537,0.55414000689009,0.6706846793375292
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions lectures/_static/quant-econ.bib
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,47 @@
QuantEcon Bibliography File used in conjuction with sphinxcontrib-bibtex package
Note: Extended Information (like abstracts, doi, url's etc.) can be found in quant-econ-extendedinfo.bib file in _static/
###
@book{russell2004history,
title={History of western philosophy},
author={Russell, Bertrand},
year={2004},
publisher={Routledge}
}

@article{north1989,
title={Constitutions and commitment: the evolution of institutions governing public choice in seventeenth-century England},
author={North, Douglass C and Weingast, Barry R},
journal={The journal of economic history},
volume={49},
number={4},
pages={803--832},
year={1989},
publisher={Cambridge University Press}
}

@incollection{keynes1940pay,
title={How to Pay for the War},
author={Keynes, John Maynard},
booktitle={Essays in persuasion},
pages={367--439},
year={1940},
publisher={Springer}
}

@article{bryant1984price,
title={A price discrimination analysis of monetary policy},
author={Bryant, John and Wallace, Neil},
journal={The Review of Economic Studies},
volume={51},
number={2},
pages={279--288},
year={1984},
publisher={Wiley-Blackwell}
}


@article{levitt2019did,
title={Why did ancient states collapse?: the dysfunctional state},
author={Levitt, Malcolm},
Expand Down
3 changes: 1 addition & 2 deletions lectures/_toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ parts:
- file: long_run_growth
- file: business_cycle
- file: inflation_history
- file: french_rev
- file: inequality
- caption: Foundations
numbered: true
Expand Down Expand Up @@ -55,8 +56,6 @@ parts:
- file: unpleasant
- file: money_inflation_nonlinear
- file: laffer_adaptive
# - file: french_rev
- file: ak2
- caption: Stochastic Dynamics
numbered: true
chapters:
Expand Down
Loading

0 comments on commit 7420047

Please sign in to comment.