1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

MIDASを用いた我が国GDPのナウキャスティング

Last updated at Posted at 2021-04-28

目的

『わが国のGDPのナウキャスティングに関する検討』の再現性の確認(MIDAS手法とブリッジ方程式手法のみ)

わが国のGDPのナウキャスティングに関する検討

repositoryはこちら

前書き

混合データサンプリング法(以下、MIDAS(マイダス)と記す)の有効性を調査するため、MIDASとブリッジ方程式を使用した。
使用した指数は鉱工業指数(生産指数) 鉱工業総合(以下、iipと記す)とGDPの四半期速報値である。
なお、使用したデータは、e-statのデータを前処理を行なった上で使用した。

gdpandiip.png

ブリッジ方程式

y_t = \alpha + \sum_{i=1}^{N} \beta_i x^Q_{i,t} + \varepsilon _t \\
x^Q_{i,t} = \frac{1}{3}(x^M_{i,3t} + 2 x^M_{i,3t-1} + 3 x^M_{i,3t-2} + 2 x^M_{i,3t-3} + x^M_{i,3t-4})

[1]より参照

# ブリッジ方程式モデル(単回帰分析)
df4 = pd.merge(gdp, iip, left_index=True, right_index=True, how='outer')
df5 = pd.DataFrame(columns=['BRIDGE'])

x = np.array([])
flag = False
for date, IIP_YOY in zip(df4.index, df4['IIP_YOY']):

    x = np.append(x, IIP_YOY)
    if flag == False:
        if date == '2013-07-01':
            flag = True

    if flag:
        x3t = x[-1]
        x3tm1 = x[-2]
        x3tm2 = x[-3]
        x3tm3 = x[-4]
        x3tm4 = x[-5]
        xt = (x3t + 2*x3tm1 + 3*x3tm2 + 2*x3tm3 + x3tm4)/3
        record = pd.Series([xt],
                           index=df5.columns, name=date)
        df5 = df5.append(record)

df5.index.name = 'DATE'
df6 = pd.merge(df4, df5, left_index=True, right_index=True, how='outer')
df6 = df6.dropna()

# 目的変数(Y)、説明変数(X)
Y2 = df6['GDP_CYOY']
X2 = df6[['BRIDGE']]

# 線形回帰をする
model = linear_model.LinearRegression()
model.fit(X2, Y2)

# パラメータ算出
reg_a = model.coef_[0]
reg_b = model.intercept_

df6['NOWCAST'] = df6.apply(lambda x: reg_b + reg_a*x['BRIDGE'], axis=1)

nowcaste_bridge.png

MIDAS

y_t = \alpha + \sum_{i=1}^{K} \sum_{j=0}^{l_i} \beta_{i,j} x^M_{i,3t - j} + \varepsilon _t
# 日本の会計年度が4月始まりのため、4月を起点としている。
df['period'] = pd.to_datetime(df.index.to_series()).apply(
    lambda x: 3 if x.month in [1, 4, 7, 10] else (1 if x.month in [2, 5, 8, 11] else 2))

df = df[df.index != '2013-01-01']

df2 = pd.DataFrame(columns=[
                   'GDP_CYOY', 'IIP_YOY_Q1', 'IIP_YOY_Q2', 'IIP_YOY_Q3'])
for date, GDP_CYOY, IIP_YOY, period in zip(df.index, df.GDP_CYOY, df.IIP_YOY, df.period):

    if period == 1:
        q1 = IIP_YOY
    elif period == 2:
        q2 = IIP_YOY
    else:
        record = pd.Series([GDP_CYOY, q1, q2, IIP_YOY],
                           index=df2.columns, name=date)
        df2 = df2.append(record)

df2.index.name = 'DATE'


# 目的変数(Y)、説明変数(X)
Y = np.array(df2['GDP_CYOY'])
X = np.array(df2[['IIP_YOY_Q1', 'IIP_YOY_Q2', 'IIP_YOY_Q3']])

# 予測モデルを作成
clf.fit(X, Y)

# 偏回帰係数
ab = pd.DataFrame({"Name": ['IIP_YOY_Q1', 'IIP_YOY_Q2', 'IIP_YOY_Q3'],
                  "Coefficients": clf.coef_}).sort_values(by='Coefficients')
for index, row in ab.iterrows():
    if row.Name == 'IIP_YOY_Q3':
        b3 = row.Coefficients
    elif row.Name == 'IIP_YOY_Q2':
        b2 = row.Coefficients
    else:
        b1 = row.Coefficients
# 切片
print(clf.intercept_)
a = clf.intercept_

df2['NOWCAST'] = df2.apply(lambda x: a + b1*x['IIP_YOY_Q1'] +
                           b2*x['IIP_YOY_Q2'] + b3*x['IIP_YOY_Q3'], axis=1)

nowcaste.png

参考文献

[1]

[2]

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?