Skip to content

Commit aef973e

Browse files
authored
Merge branch 'main' into update_ak2
2 parents 8d4597f + 2ecd0ff commit aef973e

33 files changed

+2096
-3798
lines changed

environment.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ channels:
44
- conda-forge
55
dependencies:
66
- python=3.11
7-
- anaconda=2024.02
7+
- anaconda=2024.06
88
- pip
99
- pip:
1010
- jupyter-book==0.15.1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"id": "258b4bc9-2964-470a-8010-05c2162f5e05",
7+
"metadata": {},
8+
"outputs": [
9+
{
10+
"name": "stdout",
11+
"output_type": "stream",
12+
"text": [
13+
"Requirement already satisfied: wbgapi in /Users/longye/anaconda3/lib/python3.10/site-packages (1.0.12)\n",
14+
"Requirement already satisfied: plotly in /Users/longye/anaconda3/lib/python3.10/site-packages (5.22.0)\n",
15+
"Requirement already satisfied: requests in /Users/longye/anaconda3/lib/python3.10/site-packages (from wbgapi) (2.31.0)\n",
16+
"Requirement already satisfied: tabulate in /Users/longye/anaconda3/lib/python3.10/site-packages (from wbgapi) (0.9.0)\n",
17+
"Requirement already satisfied: PyYAML in /Users/longye/anaconda3/lib/python3.10/site-packages (from wbgapi) (6.0)\n",
18+
"Requirement already satisfied: tenacity>=6.2.0 in /Users/longye/anaconda3/lib/python3.10/site-packages (from plotly) (8.4.1)\n",
19+
"Requirement already satisfied: packaging in /Users/longye/anaconda3/lib/python3.10/site-packages (from plotly) (23.1)\n",
20+
"Requirement already satisfied: urllib3<3,>=1.21.1 in /Users/longye/anaconda3/lib/python3.10/site-packages (from requests->wbgapi) (1.26.16)\n",
21+
"Requirement already satisfied: charset-normalizer<4,>=2 in /Users/longye/anaconda3/lib/python3.10/site-packages (from requests->wbgapi) (2.0.4)\n",
22+
"Requirement already satisfied: idna<4,>=2.5 in /Users/longye/anaconda3/lib/python3.10/site-packages (from requests->wbgapi) (3.4)\n",
23+
"Requirement already satisfied: certifi>=2017.4.17 in /Users/longye/anaconda3/lib/python3.10/site-packages (from requests->wbgapi) (2024.6.2)\n"
24+
]
25+
}
26+
],
27+
"source": [
28+
"!pip install wbgapi plotly\n",
29+
"\n",
30+
"import pandas as pd\n",
31+
"import numpy as np\n",
32+
"import matplotlib.pyplot as plt\n",
33+
"import random as rd\n",
34+
"import wbgapi as wb\n",
35+
"import plotly.express as px\n",
36+
"\n",
37+
"url = 'https://media.githubusercontent.com/media/QuantEcon/high_dim_data/main/SCF_plus/SCF_plus_mini.csv'\n",
38+
"df = pd.read_csv(url)\n",
39+
"df_income_wealth = df.dropna()"
40+
]
41+
},
42+
{
43+
"cell_type": "code",
44+
"execution_count": 4,
45+
"id": "9630a07a-fce5-474e-92af-104e67e82be5",
46+
"metadata": {},
47+
"outputs": [
48+
{
49+
"name": "stdout",
50+
"output_type": "stream",
51+
"text": [
52+
"Requirement already satisfied: quantecon in /Users/longye/anaconda3/lib/python3.10/site-packages (0.7.1)\n",
53+
"Requirement already satisfied: requests in /Users/longye/anaconda3/lib/python3.10/site-packages (from quantecon) (2.31.0)\n",
54+
"Requirement already satisfied: numpy>=1.17.0 in /Users/longye/anaconda3/lib/python3.10/site-packages (from quantecon) (1.26.3)\n",
55+
"Requirement already satisfied: numba>=0.49.0 in /Users/longye/anaconda3/lib/python3.10/site-packages (from quantecon) (0.59.1)\n",
56+
"Requirement already satisfied: sympy in /Users/longye/anaconda3/lib/python3.10/site-packages (from quantecon) (1.12)\n",
57+
"Requirement already satisfied: scipy>=1.5.0 in /Users/longye/anaconda3/lib/python3.10/site-packages (from quantecon) (1.12.0)\n",
58+
"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",
59+
"Requirement already satisfied: certifi>=2017.4.17 in /Users/longye/anaconda3/lib/python3.10/site-packages (from requests->quantecon) (2024.6.2)\n",
60+
"Requirement already satisfied: idna<4,>=2.5 in /Users/longye/anaconda3/lib/python3.10/site-packages (from requests->quantecon) (3.4)\n",
61+
"Requirement already satisfied: charset-normalizer<4,>=2 in /Users/longye/anaconda3/lib/python3.10/site-packages (from requests->quantecon) (2.0.4)\n",
62+
"Requirement already satisfied: urllib3<3,>=1.21.1 in /Users/longye/anaconda3/lib/python3.10/site-packages (from requests->quantecon) (1.26.16)\n",
63+
"Requirement already satisfied: mpmath>=0.19 in /Users/longye/anaconda3/lib/python3.10/site-packages (from sympy->quantecon) (1.3.0)\n"
64+
]
65+
}
66+
],
67+
"source": [
68+
"!pip install quantecon\n",
69+
"import quantecon as qe\n",
70+
"\n",
71+
"varlist = ['n_wealth', # net wealth \n",
72+
" 't_income', # total income\n",
73+
" 'l_income'] # labor income\n",
74+
"\n",
75+
"df = df_income_wealth\n",
76+
"years = df.year.unique()\n",
77+
"\n",
78+
"# create lists to store Gini for each inequality measure\n",
79+
"results = {}\n",
80+
"\n",
81+
"for var in varlist:\n",
82+
" # create lists to store Gini\n",
83+
" gini_yr = []\n",
84+
" for year in years:\n",
85+
" # repeat the observations according to their weights\n",
86+
" counts = list(round(df[df['year'] == year]['weights'] ))\n",
87+
" y = df[df['year'] == year][var].repeat(counts)\n",
88+
" y = np.asarray(y)\n",
89+
" \n",
90+
" rd.shuffle(y) # shuffle the sequence\n",
91+
" \n",
92+
" # calculate and store Gini\n",
93+
" gini = qe.gini_coefficient(y)\n",
94+
" gini_yr.append(gini)\n",
95+
" \n",
96+
" results[var] = gini_yr\n",
97+
"\n",
98+
"# Convert to DataFrame\n",
99+
"results = pd.DataFrame(results, index=years)\n",
100+
"results.to_csv(\"usa-gini-nwealth-tincome-lincome.csv\", index_label='year')"
101+
]
102+
},
103+
{
104+
"cell_type": "code",
105+
"execution_count": null,
106+
"id": "d59e876b-2f77-4fa7-b79a-8e455ad82d43",
107+
"metadata": {},
108+
"outputs": [],
109+
"source": []
110+
}
111+
],
112+
"metadata": {
113+
"kernelspec": {
114+
"display_name": "Python 3 (ipykernel)",
115+
"language": "python",
116+
"name": "python3"
117+
},
118+
"language_info": {
119+
"codemirror_mode": {
120+
"name": "ipython",
121+
"version": 3
122+
},
123+
"file_extension": ".py",
124+
"mimetype": "text/x-python",
125+
"name": "python",
126+
"nbconvert_exporter": "python",
127+
"pygments_lexer": "ipython3",
128+
"version": "3.10.12"
129+
}
130+
},
131+
"nbformat": 4,
132+
"nbformat_minor": 5
133+
}
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
year,n_wealth,t_income,l_income
2-
1950,0.8257332034366338,0.44248654139458626,0.5342948198773412
3-
1953,0.8059487586599329,0.4264544060935945,0.5158978980963702
4-
1956,0.8121790488050616,0.44426942873399283,0.5349293526208142
5-
1959,0.795206874163792,0.43749348077061573,0.5213985948309416
6-
1962,0.8086945076579359,0.4435843103853645,0.5345127915054341
7-
1965,0.7904149225687935,0.43763715466663444,0.7487860020887753
8-
1968,0.7982885066993497,0.4208620794438902,0.5242396427381545
9-
1971,0.7911574835420259,0.4233344246090255,0.5576454812313466
10-
1977,0.7571418922185215,0.46187678800902543,0.5704448110072049
11-
1983,0.7494335400643013,0.439345618464469,0.5662220844385915
12-
1989,0.7715705301674302,0.5115249581654197,0.601399568747142
13-
1992,0.7508126614055308,0.4740650672076798,0.5983592657979563
14-
1995,0.7569492388110265,0.48965523558400603,0.5969779516716903
15-
1998,0.7603291991801185,0.49117441585168614,0.5774462841723305
16-
2001,0.7816118750507056,0.5239092994681135,0.6042739644967272
17-
2004,0.7700355469522361,0.4884350383903255,0.5981432201792727
18-
2007,0.7821413776486978,0.5197156312086187,0.626345219575322
19-
2010,0.8250825295193438,0.5195972120145615,0.6453653328291903
20-
2013,0.8227698931835303,0.531400174984336,0.6498682917772644
21-
2016,0.8342975903562234,0.5541400068900825,0.6706846793375284
2+
1950,0.8257332034366366,0.44248654139458743,0.534294819877344
3+
1953,0.805948758659935,0.4264544060935942,0.5158978980963682
4+
1956,0.8121790488050612,0.44426942873399367,0.5349293526208106
5+
1959,0.7952068741637912,0.43749348077061534,0.5213985948309414
6+
1962,0.8086945076579386,0.44358431038536356,0.5345127915054446
7+
1965,0.7904149225687949,0.4376371546666344,0.7487860020887701
8+
1968,0.7982885066993503,0.4208620794438885,0.5242396427381534
9+
1971,0.7911574835420282,0.4233344246090255,0.5576454812313462
10+
1977,0.7571418922185215,0.46187678800902554,0.57044481100722
11+
1983,0.749433540064301,0.4393456184644682,0.5662220844385925
12+
1989,0.7715705301674285,0.5115249581654115,0.6013995687471289
13+
1992,0.7508126614055305,0.4740650672076754,0.5983592657979544
14+
1995,0.7569492388110274,0.4896552355840001,0.5969779516717039
15+
1998,0.7603291991801172,0.49117441585168525,0.5774462841723346
16+
2001,0.781611875050703,0.523909299468113,0.6042739644967232
17+
2004,0.7700355469522372,0.48843503839032354,0.5981432201792916
18+
2007,0.782141377648698,0.5197156312086207,0.6263452195753227
19+
2010,0.825082529519342,0.5195972120145641,0.6453653328291843
20+
2013,0.8227698931835299,0.5314001749843426,0.6498682917772886
21+
2016,0.8342975903562537,0.55414000689009,0.6706846793375292

lectures/_static/quant-econ.bib

+22
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,28 @@
22
QuantEcon Bibliography File used in conjuction with sphinxcontrib-bibtex package
33
Note: Extended Information (like abstracts, doi, url's etc.) can be found in quant-econ-extendedinfo.bib file in _static/
44
###
5+
6+
@incollection{keynes1940pay,
7+
title={How to Pay for the War},
8+
author={Keynes, John Maynard},
9+
booktitle={Essays in persuasion},
10+
pages={367--439},
11+
year={1940},
12+
publisher={Springer}
13+
}
14+
15+
@article{bryant1984price,
16+
title={A price discrimination analysis of monetary policy},
17+
author={Bryant, John and Wallace, Neil},
18+
journal={The Review of Economic Studies},
19+
volume={51},
20+
number={2},
21+
pages={279--288},
22+
year={1984},
23+
publisher={Wiley-Blackwell}
24+
}
25+
26+
527
@article{levitt2019did,
628
title={Why did ancient states collapse?: the dysfunctional state},
729
author={Levitt, Malcolm},

lectures/_toc.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ parts:
1111
- file: long_run_growth
1212
- file: business_cycle
1313
- file: inflation_history
14+
- file: french_rev
1415
- file: inequality
1516
- caption: Foundations
1617
numbered: true
@@ -55,7 +56,6 @@ parts:
5556
- file: unpleasant
5657
- file: money_inflation_nonlinear
5758
- file: laffer_adaptive
58-
# - file: french_rev
5959
- file: ak2
6060
- caption: Stochastic Dynamics
6161
numbered: true

0 commit comments

Comments
 (0)