為替操作国日本:ドル円レートとGDPには相関性があるのか?

その買うを、もっとハッピーに。|ハピタス

このサイトを参考にしながら、ドル円レートと日本のGDPには何かしらの相関関係があるのか調べてみることにした。もし相関関係があれば、何で先進国であるはずの日本が薄汚い為替操作国であるのかという理由にもなる。

スポンサーリンク

ドル円レートGDPのグラフ化

from pandas import *
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
plt.rcParams['figure.figsize'] = 20, 12

以下の2つのサイトから為替レートとGDPデータをダウンロードする。
GDPデータ
ドル円レート

yen_dollar = 'DEXJPUS.csv'
jp_gdp = 'JPNNGDP.csv'
exchange = read_csv(yen_dollar)
jp_gdp = read_csv(jp_gdp)
new_table = pd.merge(jp_gdp,exchange)
new_table
DATE JPNNGDP DEXJPUS
0 1995-01-01 505624.7 95.867258
1 1995-04-01 510005.1 84.503906
2 1995-07-01 516283.0 94.251270
3 1995-10-01 517855.7 101.537903
4 1996-01-01 519975.5 105.827097
5 1996-04-01 526473.8 107.455000
6 1996-07-01 526023.0 108.966719
7 1996-10-01 531217.2 112.907903
8 1997-01-01 532366.1 121.158852
9 1997-04-01 534649.6 119.797969
10 1997-07-01 534892.5 118.023125
11 1997-10-01 535670.1 125.392742
12 1998-01-01 529263.7 128.228525
13 1998-04-01 526296.7 135.683906
14 1998-07-01 525335.9 140.007385
15 1998-10-01 530480.0 119.404516
16 1999-01-01 520565.4 116.673607
17 1999-04-01 520528.1 120.795625
18 1999-07-01 520188.4 113.145469
19 1999-10-01 519454.5 104.312857
20 2000-01-01 527257.7 106.964444
21 2000-04-01 526409.2 106.724219
22 2000-07-01 525583.1 107.727460
23 2000-10-01 529004.4 109.849677
24 2001-01-01 532451.1 118.252581
25 2001-04-01 525868.7 122.616563
26 2001-07-01 518804.8 121.627581
27 2001-10-01 515873.0 123.741613
28 2002-01-01 517153.4 132.423607
29 2002-04-01 515853.7 126.922500
66 2011-07-01 495198.6 77.621406
67 2011-10-01 494472.4 77.340656
68 2012-01-01 501487.7 79.402097
69 2012-04-01 494363.0 80.071719
70 2012-07-01 491803.4 78.604603
71 2012-10-01 493015.4 81.205000
72 2013-01-01 498339.9 92.252787
73 2013-04-01 501801.9 98.681094
74 2013-07-01 506782.6 98.888594
75 2013-10-01 506783.8 100.403226
76 2014-01-01 512262.6 102.762295
77 2014-04-01 512468.9 102.103906
78 2014-07-01 513213.5 104.000625
79 2014-10-01 517102.9 114.356721
80 2015-01-01 529329.0 119.182295
81 2015-04-01 531625.7 121.359062
82 2015-07-01 533063.1 122.172188
83 2015-10-01 531290.1 121.406452
84 2016-01-01 536495.2 115.097258
85 2016-04-01 534946.2 107.876875
86 2016-07-01 535913.6 102.340156
87 2016-10-01 536776.1 109.556885
88 2017-01-01 539262.7 113.524098
89 2017-04-01 542762.5 111.113906
90 2017-07-01 548702.3 110.950476
91 2017-10-01 549954.4 112.891803
92 2018-01-01 548340.1 108.270161
93 2018-04-01 550453.5 109.144688
94 2018-07-01 547527.8 111.503333
95 2018-10-01 549743.4 112.770500

96 rows × 3 columns

new_table.columns = ['DATE','JPN_GDP','USD_JPY_EXCHANGE']
new_table.head()
DATE JPN_GDP USD_JPY_EXCHANGE
0 1995-01-01 505624.7 95.867258
1 1995-04-01 510005.1 84.503906
2 1995-07-01 516283.0 94.251270
3 1995-10-01 517855.7 101.537903
4 1996-01-01 519975.5 105.827097
new_table = DataFrame(new_table)
new_table.head()
DATE JPN_GDP USD_JPY_EXCHANGE
0 1995-01-01 505624.7 95.867258
1 1995-04-01 510005.1 84.503906
2 1995-07-01 516283.0 94.251270
3 1995-10-01 517855.7 101.537903
4 1996-01-01 519975.5 105.827097
jp_gdp_exch_scatt = new_table.plot('JPN_GDP','USD_JPY_EXCHANGE',grid=True, kind='scatter', s = 70)

jp_gdp_exch_scatt.set_title('Correlation between Japanese GDP and the Exchange Rate ', fontsize = 20)

jp_gdp_exch_scatt.set_xlabel('Japanese GDP (Billions of Yen)')

jp_gdp_exch_scatt.set_ylabel('Dollar-Yen Exchange Rate (Yen)')
Text(0, 0.5, 'Dollar-Yen Exchange Rate (Yen)')
jp_gdp_plot = new_table[['DATE','JPN_GDP']].set_index('DATE').plot()
jp_gdp_plot.set_title('Japanese GDP 1995 - 2018', fontsize =20)
jp_gdp_plot.set_ylabel('Japanese GDP (Billions of Yen)')
Text(0, 0.5, 'Japanese GDP (Billions of Yen)')
exchange_plot = new_table[['DATE','USD_JPY_EXCHANGE']].set_index('DATE').plot()
exchange_plot.set_title('Dollar Yen Exchange Rate 1995 - 2018', fontsize =20)
exchange_plot.set_ylabel('USD-JPY Exchange Rate (Yen)')
Text(0, 0.5, 'USD-JPY Exchange Rate (Yen)')
from matplotlib.pyplot import *
from matplotlib.font_manager import FontProperties
from matplotlib import rcParams
style.use('ggplot')

rcParams["font.size"] = "17"
fp = FontProperties(fname='/usr/share/fonts/opentype/ipaexfont-gothic/ipaexg.ttf', size=54)
rcParams['font.family'] = fp.get_name()
fig, ax = plt.subplots(figsize=(20,12))
new_table[['DATE','JPN_GDP']].set_index('DATE').plot(ax=ax,color="red")
ax.set_ylabel('GDP (10億円)')
ax.set_title('1995年〜2018のドル円レートとGDPの相関関係 ', fontsize =20)
ax.legend(["GDP"],loc='lower right', prop={'size': 26})
ax2 = ax.twinx()
new_table[['DATE','USD_JPY_EXCHANGE']].set_index('DATE').plot(ax=ax2,color="blue")
ax2.set_ylabel('ドル円レート (円)')
ax2.legend(["ドル円レート"],loc='lower left', prop={'size': 26})
ax2.annotate('リーマンショック', xy=(57,79),  xycoords='data',
             xytext=(-50, -20),textcoords='offset points',
             size=25, ha='right', va="center",
             bbox=dict(boxstyle="round", alpha=0.1),
             arrowprops=dict(arrowstyle="wedge,tail_width=0.5", alpha=0.1))
ax2.annotate('東日本大震災', xy=(64,79),  xycoords='data',
             xytext=(60,280),textcoords='offset points',
             size=25, ha='right', va="center",
             bbox=dict(boxstyle="round", alpha=0.1),
             arrowprops=dict(arrowstyle="wedge,tail_width=0.5", alpha=0.1))
ax2.annotate('異次元緩和', xy=(73,98.681094),  xycoords='data',
             xytext=(145, -100),textcoords='offset points',
             size=25, ha='right', va="center",
             bbox=dict(boxstyle="round", alpha=0.1),
             arrowprops=dict(arrowstyle="wedge,tail_width=0.5", alpha=0.1))
ax2.annotate('消費税増税', xy=(77,102.103906),  xycoords='data',
             xytext=(145, -60),textcoords='offset points',
             size=25, ha='right', va="center",
             bbox=dict(boxstyle="round", alpha=0.1),
             arrowprops=dict(arrowstyle="wedge,tail_width=0.5", alpha=0.1))
ax2.annotate('アジア通貨危機', xy=(10,120),  xycoords='data',
             xytext=(120, -200),textcoords='offset points',
             size=25, ha='right', va="center",
             bbox=dict(boxstyle="round", alpha=0.1),
             arrowprops=dict(arrowstyle="wedge,tail_width=0.5", alpha=0.1))
ax2.annotate('日米協調介入', xy=(14,140),  xycoords='data',
             xytext=(200, -5),textcoords='offset points',
             size=25, ha='right', va="center",
             bbox=dict(boxstyle="round", alpha=0.1),
             arrowprops=dict(arrowstyle="wedge,tail_width=0.5", alpha=0.1))
ax2.annotate('安倍政権誕生', xy=(71,81),  xycoords='data',
             xytext=(200, 5),textcoords='offset points',
             size=25, ha='right', va="center",
             bbox=dict(boxstyle="round", alpha=0.1),
             arrowprops=dict(arrowstyle="wedge,tail_width=0.5", alpha=0.1));

ドル円レートとGDPに相関関係があることは確かだが、時期によってその事情は大いに異なる。奇しくも1997年の消費税増税後のジョージ・ソロスによるタイバーツの空売りで始まったアジア通貨危機時、拓銀・山一ショックと銀行連鎖破綻の恐怖が高まりにより、日本は平成大恐慌前夜にあった。それを救ったのが、政府による思い切った財政出動と銀行救済、日銀のゼロ金利政策だったことは記憶に新しいが、その後もアメリカのドットコムバブル崩壊、911テロにより日本経済は大いに苦しんだ。2003年が平成最悪の超氷河期だったのも納得できよう。この時期だけを見れば、行き過ぎた通貨安が経済に悪影響を与えることが見て取れるだろう。もちろん、基本的には円安時に総じてGDPが上昇傾向にあることも確かである。しかしながら、世界経済が減速傾向にある時は、円安であってもGDPが伸び悩んでいることも事実である。リーマンショック以降、円がスイスフラン並の安全通貨になったことと、アメリカの度重なる金融緩和による円高、さらに東日本大震災によるによりGDPがかなり伸び悩んだ。安倍政権誕生期待で一気に円安に傾き、マジキチ緩和の発動によりGDPはリーマンショック前の水準を取り戻している。しかし、実際は、アベノミクスが成功しているように見せるために、インチキ・粉飾・誤魔化し・水増しやりたい放題でGDPを思いっきり無理くりかさあげしまくっているという説もある。まぁ、令和元年終了時には日銀が500兆円国債買い取って、30兆円を株式市場にぶっ込んでいる事実を考えれば、これだけメチャクチャやってもインチキ粉飾しないとGDPが減る可能性があるという厳然たる事実を、全ての日本国民が真正面から受け止める必要がある。この国はもう完全に詰んでいるという事実を知る時に来ているということだ。

スポンサーリンク

rと最小二乗法による推定係数

What is the relationship between these data sets? Are they even correlated?
これらのデータセットの関係は何なのか?本当に相関性があるのか?

The regression model is: y’ = a + bx
回帰モデルはy’ = a + bx

Where b is the slope and a is the intercept.
bが傾きでaが切片

Therefore: (Yen-Dollar Exchange) = a + b(Japan_GDP)
従って、ドル円レート = a + b(GDP)

jpn_gdp_Column = new_table['JPN_GDP']
exchange_Column = new_table['USD_JPY_EXCHANGE']
jpn_gdp_Column.describe()
count        96.000000
mean     520118.152083
std       15665.885676
min      484691.800000
25%      512417.325000
50%      521672.450000
75%      530664.300000
max      550453.500000
Name: JPN_GDP, dtype: float64
exchange_Column.describe()
count     96.000000
mean     107.973519
std       13.790017
min       77.340656
25%      101.254234
50%      109.621411
75%      118.080489
max      140.007385
Name: USD_JPY_EXCHANGE, dtype: float64
#Sum of X

jpn_gdp_Column.sum()
49931342.6
#Sum of Y

exchange_Column.sum()
10365.457802518427
#Sum of X times Y

x_y = jpn_gdp_Column*exchange_Column
x_y.sum()
5405229437.293641
#Sum of X squared

jpn_gdp_sq = jpn_gdp_Column**2
jpn_gdp_sq.sum()
25993512541682.598
#Sum of Y squared

exchange_sq = exchange_Column**2
exchange_sq.sum()
1137260.5856987718
#Set variables

X = new_table.JPN_GDP

X = np.vstack(new_table.JPN_GDP)

Y = new_table.USD_JPY_EXCHANGE

Y = np.vstack(new_table.USD_JPY_EXCHANGE)
X = np.array([ [value,1] for value in X]).astype(np.float32)
#Find Correlation Coefficients with numpy
# [1
# [correlation(y, x)          1]]

corr = np.corrcoef(jpn_gdp_Column,exchange_Column)

print('The correlational coefficient (r) is %.3f' %corr[0]2)
The correlational coefficient (r) is 0.681
#Use numpy Least Squares (lstsq) to find the Regression Coefficients

regression = np.linalg.lstsq(X,exchange_Column,rcond=-1)
regression
(array([ 5.99045248e-04, -2.03600789e+02]),
 array([9698.95986294]),
 2,
 array([5.09838334e+06, 2.93440400e-01]))
print('The slope is %.4f' %regression[0][0])
print('The y intercept is %.3f' %regression[0]3)
The slope is 0.0006
The y intercept is -203.601
スポンサーリンク

係数推定の正確度を評価する (Get Error)

#Get error

total_error = regression[1]
print('The total error was %.3f' %total_error[0])
The total error was 9698.960
#Get Root Mean Sqaure Error

rmse = np.sqrt(total_error/len(X))
print('The root mean squared error was %.2f' %rmse)
The root mean squared error was 10.05

There’s a 95% chance that any given exchange rate in this time period will be within 2 times this error, or 21 yen away from the fit line.
この時間枠における任意の為替レートがこのエラーの2倍以内、もしくは、適合線から21円それる可能性が95%存在する。

スポンサーリンク

回帰をプロットする

import scipy 
from scipy import stats
from scipy.stats import t
#find t-statistic
r = 0.681
t = ((r)*np.sqrt((96-2)/(1-(r**2))))
print('The t-statistic is %.3f' %t)
The t-statistic is 9.016
from scipy.stats import t

#pass t statistic and degrees of freedom
#checked by hand
pvalue = t.sf(9.016, 2)
print('The p-value is %f' %pvalue)
The p-value is 0.006040
m , b = scipy.linalg.lstsq(X,Y)[0]
#Plot centroid using X and Y means

plt.plot([520118.152083], [107.973519], marker='o', markersize=10, color="red")

#Plot best fit line

plt.plot(jpn_gdp_Column,exchange_Column,'o',color='green')

x = new_table.JPN_GDP

plt.plot(x, m*x + b, 'r')

plt.title('USD-JPY Exchange Rate and Japanese GDP Regression Line',fontsize=20)

plt.xlabel('Japanese GDP (Billions of Yen)')

plt.ylabel('USD-Yen Exchange Rate (Yen)');

2016年以降、ドル円レートに関係なくGDPがうなぎのぼりに伸びているのは、粉飾インチキ水増ししているからだろう。ある著名なエコノミストが、日本の実際のGDPはせいぜい500兆円程度だと言っていたが、その数字が最も真実に近い数字だと思われる。

スポンサーリンク
スポンサーリンク