Skip to content

Commit

Permalink
x y in plot + 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
spring-haru committed Aug 11, 2024
1 parent f227fa3 commit 673f290
Show file tree
Hide file tree
Showing 7 changed files with 221 additions and 181 deletions.
95 changes: 59 additions & 36 deletions 19_PPP.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"import statsmodels.formula.api as smf\n",
"\n",
"# numpy v1の表示を使用\n",
"np.set_printoptions(legacy='1.25')\n",
"np.set_printoptions(legacy='1.21')\n",
"# 警告メッセージを非表示\n",
"import warnings\n",
"warnings.filterwarnings(\"ignore\")"
Expand All @@ -44,7 +44,8 @@
"cell_type": "markdown",
"id": "7c0ddd8c",
"metadata": {
"heading_collapsed": true
"heading_collapsed": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"## はじめに"
Expand Down Expand Up @@ -84,7 +85,8 @@
"cell_type": "markdown",
"id": "3647d0a7",
"metadata": {
"heading_collapsed": true
"heading_collapsed": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"## 国内での一物一価"
Expand Down Expand Up @@ -145,7 +147,8 @@
"id": "b0c31a03",
"metadata": {
"heading_collapsed": true,
"hidden": true
"hidden": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"### チョコレート"
Expand Down Expand Up @@ -379,7 +382,7 @@
},
"outputs": [],
"source": [
"choco['mean_deviation'].hist(bins=12, ec='white')\n",
"choco.plot(y='mean_deviation', kind='hist', bins=12, ec='white')\n",
"pass"
]
},
Expand Down Expand Up @@ -513,7 +516,8 @@
"id": "99fbafd9",
"metadata": {
"heading_collapsed": true,
"hidden": true
"hidden": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"### アイスクリーム"
Expand Down Expand Up @@ -676,7 +680,7 @@
"source": [
"ice['mean_deviation'] = ice['price'] / ice['price'].mean() - 1\n",
"\n",
"ice['mean_deviation'].hist(bins=16, ec='white')\n",
"ice.plot(y='mean_deviation', kind='hist', bins=16, ec='white')\n",
"pass"
]
},
Expand Down Expand Up @@ -771,7 +775,8 @@
"id": "b9a17c97",
"metadata": {
"heading_collapsed": true,
"hidden": true
"hidden": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"### ガソリン"
Expand Down Expand Up @@ -934,7 +939,7 @@
"source": [
"gas['mean_deviation'] = gas['price'] / gas['price'].mean() - 1\n",
"\n",
"gas['mean_deviation'].hist(ec='white')\n",
"gas.plot(y='mean_deviation', kind='hist', ec='white')\n",
"pass"
]
},
Expand Down Expand Up @@ -1013,7 +1018,8 @@
"id": "cb38c1aa",
"metadata": {
"heading_collapsed": true,
"hidden": true
"hidden": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"### 結論"
Expand Down Expand Up @@ -1059,7 +1065,8 @@
"cell_type": "markdown",
"id": "0f726eb0",
"metadata": {
"hidden": true
"hidden": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"(sec:19-bigmac)=\n",
Expand Down Expand Up @@ -1107,7 +1114,8 @@
"id": "f65cfb13",
"metadata": {
"heading_collapsed": true,
"hidden": true
"hidden": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"### データ"
Expand Down Expand Up @@ -1527,7 +1535,7 @@
},
"outputs": [],
"source": [
"bigmac['price_yen_deviation'].hist(ec='white')\n",
"bigmac.plot(y='price_yen_deviation', kind='hist', ec='white')\n",
"pass"
]
},
Expand Down Expand Up @@ -1689,7 +1697,8 @@
"id": "c2ef0b6b",
"metadata": {
"heading_collapsed": true,
"hidden": true
"hidden": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"### 所得の影響"
Expand Down Expand Up @@ -1797,7 +1806,7 @@
},
"outputs": [],
"source": [
"ax = bigmac.plot('gdppc_yen', 'price_yen', kind='scatter', logx=True)\n",
"ax = bigmac.plot(x='gdppc_yen', y='price_yen', kind='scatter', logx=True)\n",
"ax.set_xlabel('一人当たり実質GDP(円,常用対数)', fontsize=15)\n",
"ax.set_ylabel('Big Mac価格(円)', fontsize=15)\n",
"pass"
Expand Down Expand Up @@ -1854,7 +1863,8 @@
"id": "69ef4782",
"metadata": {
"heading_collapsed": true,
"hidden": true
"hidden": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"### PPPとは"
Expand Down Expand Up @@ -2002,7 +2012,8 @@
"id": "e0407287",
"metadata": {
"heading_collapsed": true,
"hidden": true
"hidden": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"### PPPレートと市場為替レートのデータ"
Expand Down Expand Up @@ -2288,7 +2299,8 @@
"id": "af458300",
"metadata": {
"heading_collapsed": true,
"hidden": true
"hidden": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"### 相対一般物価水準の分布"
Expand Down Expand Up @@ -2385,7 +2397,7 @@
"source": [
"pwt19['pl_gdpo_log'] = np.log( pwt19['pl_gdpo'] )\n",
"\n",
"pwt19['pl_gdpo_log'].plot(kind='hist', ec='white')\n",
"pwt19.plot(y='pl_gdpo_log', kind='hist', ec='white')\n",
"pass"
]
},
Expand Down Expand Up @@ -2586,7 +2598,8 @@
"id": "639f4d19",
"metadata": {
"heading_collapsed": true,
"hidden": true
"hidden": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"### 所得の影響"
Expand Down Expand Up @@ -2716,7 +2729,7 @@
},
"outputs": [],
"source": [
"ax = pwt19.plot('cgdpo_pc_log', 'pl_gdpo_log', kind='scatter')\n",
"ax = pwt19.plot(x='cgdpo_pc_log', y='pl_gdpo_log', kind='scatter')\n",
"ax.set_xlabel('一人当たりGDP(対数,百万米ドル)', fontsize=15)\n",
"ax.set_ylabel('米国の2017年価格を基準とした\\n2019年相対価格(対数)', fontsize=15)\n",
"pass"
Expand All @@ -2741,7 +2754,8 @@
"id": "76176a3d",
"metadata": {
"heading_collapsed": true,
"hidden": true
"hidden": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"### 所得効果の分離"
Expand Down Expand Up @@ -2874,7 +2888,8 @@
"id": "05a96845",
"metadata": {
"heading_collapsed": true,
"hidden": true
"hidden": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"### 推定"
Expand Down Expand Up @@ -2997,13 +3012,15 @@
"outputs": [],
"source": [
"# 散布図\n",
"ax = pwt19.plot('cgdpo_pc_ratio_log', 'pl_gdpo_log', kind='scatter')\n",
"ax = pwt19.plot(x='cgdpo_pc_ratio_log', y='pl_gdpo_log', kind='scatter')\n",
"ax.set_xlabel('米国を基準とした一人当たりGDP(対数,2019年)', fontsize=15)\n",
"ax.set_ylabel('米国の2017年価格を基準とした\\n2019年相対価格(対数)', fontsize=15)\n",
"\n",
"# 回帰曲線\n",
"ax.plot('cgdpo_pc_ratio_log', 'fitted', color='red',\n",
" data=pwt19.sort_values('cgdpo_pc_ratio_log')) #1\n",
"pwt19.sort_values('cgdpo_pc_ratio_log').plot(x='cgdpo_pc_ratio_log', #1\n",
" y='fitted',\n",
" color='red',\n",
" ax=ax)\n",
"pass"
]
},
Expand All @@ -3024,7 +3041,8 @@
"cell_type": "markdown",
"id": "35b819d4",
"metadata": {
"hidden": true
"hidden": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"### ヒストグラムの比較"
Expand Down Expand Up @@ -3111,7 +3129,8 @@
"id": "9b98e6dd",
"metadata": {
"heading_collapsed": true,
"hidden": true
"hidden": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"### 所得効果の大きさ"
Expand Down Expand Up @@ -3351,7 +3370,8 @@
"cell_type": "markdown",
"id": "33fc0f87",
"metadata": {
"heading_collapsed": true
"heading_collapsed": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"## 所得効果の含意"
Expand Down Expand Up @@ -3412,7 +3432,8 @@
"id": "bc5e0889",
"metadata": {
"heading_collapsed": true,
"hidden": true
"hidden": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"### ペン効果"
Expand Down Expand Up @@ -3490,7 +3511,8 @@
"id": "6d069838",
"metadata": {
"heading_collapsed": true,
"hidden": true
"hidden": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"### 一人当たりGDPの分布"
Expand Down Expand Up @@ -3581,7 +3603,7 @@
},
"outputs": [],
"source": [
"ax = pwt19.plot('cgdpo_pc_log','cgdpo_pc_xr_log', kind='scatter')\n",
"ax = pwt19.plot(x='cgdpo_pc_log', y='cgdpo_pc_xr_log', kind='scatter')\n",
"ax.axline((9, 9), (10, 10), color='red', label='45度線') #1\n",
"ax.set_xlabel('一人当たりGDP(PPPレート)', fontsize=13)\n",
"ax.set_ylabel('一人当たりGDP(市場為替レート)', fontsize=13)\n",
Expand Down Expand Up @@ -3631,7 +3653,7 @@
},
"outputs": [],
"source": [
"ax = pwt19[['cgdpo_pc_log','cgdpo_pc_xr_log']].plot(kind='kde')\n",
"ax = pwt19.plot(y=['cgdpo_pc_log','cgdpo_pc_xr_log'], kind='kde')\n",
"ax.legend(['PPPレート','市場為替レート'], fontsize=13)\n",
"ax.set_title('一人当たりGDP(米ドル,対数)', fontsize=20)\n",
"pass"
Expand Down Expand Up @@ -3715,8 +3737,8 @@
},
"outputs": [],
"source": [
"cc_ppp = pwt19['cgdpo_pc_log'].std()/pwt19['cgdpo_pc_log'].mean()\n",
"cc_xr = pwt19['cgdpo_pc_xr_log'].std()/pwt19['cgdpo_pc_xr_log'].mean()\n",
"cc_ppp = pwt19['cgdpo_pc_log'].std() / pwt19['cgdpo_pc_log'].mean()\n",
"cc_xr = pwt19['cgdpo_pc_xr_log'].std() / pwt19['cgdpo_pc_xr_log'].mean()\n",
"\n",
"print('--- GDPの変動係数 ---')\n",
"print(f'PPPレート:{cc_ppp:>8.3f}')\n",
Expand All @@ -3737,7 +3759,8 @@
"cell_type": "markdown",
"id": "ed7a6eb0",
"metadata": {
"heading_collapsed": true
"heading_collapsed": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"## まとめ"
Expand Down
2 changes: 1 addition & 1 deletion 5a_Development_Accounting.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"import py4macro\n",
"\n",
"# numpy v1の表示を使用\n",
"np.set_printoptions(legacy='1.25')\n",
"np.set_printoptions(legacy='1.21')\n",
"# 警告メッセージを非表示\n",
"import warnings\n",
"warnings.filterwarnings(\"ignore\")"
Expand Down
Loading

0 comments on commit 673f290

Please sign in to comment.