Skip to content

Commit

Permalink
x y in plot + 1.21 legacy
Browse files Browse the repository at this point in the history
  • Loading branch information
spring-haru committed Aug 10, 2024
1 parent 29a36b8 commit 822c07a
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 67 deletions.
63 changes: 39 additions & 24 deletions 13_random_TFP.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,17 @@
"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\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"## はじめに"
]
Expand Down Expand Up @@ -101,7 +103,8 @@
{
"cell_type": "markdown",
"metadata": {
"hidden": true
"hidden": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"### ホワイト・ノイズ"
Expand Down Expand Up @@ -180,7 +183,8 @@
{
"cell_type": "markdown",
"metadata": {
"hidden": true
"hidden": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"#### 図示"
Expand Down Expand Up @@ -279,7 +283,8 @@
{
"cell_type": "markdown",
"metadata": {
"hidden": true
"hidden": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"#### 自己共分散(自己相関)"
Expand Down Expand Up @@ -430,7 +435,8 @@
"cell_type": "markdown",
"metadata": {
"heading_collapsed": true,
"hidden": true
"hidden": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"### 自己回帰モデル:AR(1)"
Expand All @@ -440,7 +446,8 @@
"cell_type": "markdown",
"metadata": {
"heading_collapsed": true,
"hidden": true
"hidden": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"#### 説明"
Expand Down Expand Up @@ -470,7 +477,8 @@
"cell_type": "markdown",
"metadata": {
"heading_collapsed": true,
"hidden": true
"hidden": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"#### 3つの例:持続性の違い"
Expand Down Expand Up @@ -622,7 +630,8 @@
"cell_type": "markdown",
"metadata": {
"heading_collapsed": true,
"hidden": true
"hidden": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"### 説明"
Expand All @@ -647,7 +656,8 @@
"cell_type": "markdown",
"metadata": {
"heading_collapsed": true,
"hidden": true
"hidden": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"### データ"
Expand Down Expand Up @@ -696,7 +706,8 @@
"cell_type": "markdown",
"metadata": {
"heading_collapsed": true,
"hidden": true
"hidden": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"### 労働時間と雇用の特徴"
Expand Down Expand Up @@ -757,7 +768,7 @@
},
"outputs": [],
"source": [
"df[['hours','hours_trend']].plot()\n",
"df.plot(y=['hours','hours_trend'])\n",
"pass"
]
},
Expand All @@ -778,7 +789,7 @@
},
"outputs": [],
"source": [
"df[['employed','employed_trend']].plot()\n",
"df.plot(y=['employed','employed_trend'])\n",
"pass"
]
},
Expand All @@ -799,7 +810,7 @@
},
"outputs": [],
"source": [
"df[['total_hours','total_hours_trend']].plot()\n",
"df.plot(y=['total_hours','total_hours_trend'])\n",
"pass"
]
},
Expand All @@ -822,7 +833,7 @@
},
"outputs": [],
"source": [
"ax_ = df[['hours_cycle','employed_cycle']].plot()\n",
"ax_ = df.plot(y=['hours_cycle','employed_cycle'])\n",
"ax_.axhline(0, c='red', lw=0.5)\n",
"pass"
]
Expand Down Expand Up @@ -911,7 +922,8 @@
"cell_type": "markdown",
"metadata": {
"heading_collapsed": true,
"hidden": true
"hidden": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"### TFPの特徴"
Expand Down Expand Up @@ -955,7 +967,7 @@
"df['tfp_cycle'] = df['tfp_log'] - df['tfp_log_trend']\n",
"\n",
"# 全要素生産性とトレンドのプロット\n",
"ax = df[['tfp_log','tfp_log_trend']].plot()\n",
"ax = df.plot(y=['tfp_log','tfp_log_trend'])\n",
"ax.set_title('全要素生産性とトレンド(対数)', size=20)\n",
"pass"
]
Expand All @@ -977,7 +989,7 @@
},
"outputs": [],
"source": [
"ax = (100 * df['tfp_cycle']).plot()\n",
"ax = ( 100 * df['tfp_cycle'] ).plot()\n",
"ax.axhline(0, c='red')\n",
"ax.set_title('全要素生産性の変動(%)', size=20)\n",
"pass"
Expand Down Expand Up @@ -1022,7 +1034,7 @@
},
"outputs": [],
"source": [
"ax_ = (100 * df[['gdp_cycle','tfp_cycle']]).plot()\n",
"ax_ = ( 100 * df[['gdp_cycle','tfp_cycle']] ).plot()\n",
"ax_.set_title('GDPとTFPの変動(%)',size=20)\n",
"pass"
]
Expand Down Expand Up @@ -1102,7 +1114,8 @@
"cell_type": "markdown",
"metadata": {
"heading_collapsed": true,
"hidden": true
"hidden": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"### AR(1)としてのTFP"
Expand Down Expand Up @@ -1296,8 +1309,7 @@
{
"cell_type": "markdown",
"metadata": {
"heading_collapsed": true,
"jp-MarkdownHeadingCollapsed": true
"heading_collapsed": true
},
"source": [
"### 説明"
Expand Down Expand Up @@ -1592,7 +1604,7 @@
"metadata": {},
"outputs": [],
"source": [
"s = (df['investment']/df['gdp']).mean()\n",
"s = ( df['investment']/df['gdp'] ).mean()\n",
"s"
]
},
Expand Down Expand Up @@ -1781,7 +1793,7 @@
},
"outputs": [],
"source": [
"np.log(df_sim['Y']).plot(title='シミュレーション:Yとトレンド(対数)')\n",
"np.log( df_sim['Y'] ).plot(title='シミュレーション:Yとトレンド(対数)')\n",
"df_sim['Y_log_trend'].plot()\n",
"pass"
]
Expand Down Expand Up @@ -1857,6 +1869,7 @@
"print('\\n--- シミュレーション:変動の自己相関係数 ---\\n')\n",
"\n",
"for v in var_list:\n",
" \n",
" ac = df_sim[f'{v}の変動'].autocorr()\n",
" print(f'{v}の変動: {ac:.3f}')"
]
Expand Down Expand Up @@ -1892,6 +1905,7 @@
"data_var_list = ['consumption','investment','capital']\n",
"\n",
"for v in data_var_list:\n",
" \n",
" df[f'{v}_cycle'] = np.log( df[v]/py4macro.trend(df[v]) )"
]
},
Expand Down Expand Up @@ -1926,6 +1940,7 @@
"print('\\n--- データ:変動の自己相関係数 ---\\n')\n",
"\n",
"for v in data_var_list:\n",
" \n",
" ac = df[f'{v}_cycle'].autocorr()\n",
" print(f'{v:>11}の変動: {ac:>5.3f}') # 1"
]
Expand Down
2 changes: 1 addition & 1 deletion 14_linearsolve.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"import pandas as pd\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 822c07a

Please sign in to comment.