【问题标题】:How to forecast using ragged edge data in a MIDAS model using the MIDASR package?如何使用 MIDASR 包在 MIDAS 模型中使用参差不齐的边缘数据进行预测?
【发布时间】:2015-03-12 11:01:25
【问题描述】:

我正在尝试使用带有 midasr 包的每月变量生成季度变量的提前 1 步预测。我遇到的问题是,当样本中的每月观察次数恰好是季度观察次数的 3 倍时,我只能估计 MIDAS 模型。

当月度观测值的数量不是季度观测值的精确倍数时(例如,当我有一个新的月度数据点要用于更新预测时),我如何在 midasr 包中进行预测?

例如,假设当我有(n) 季度观测值和(3*n) 月度观测值时,我运行以下代码来生成提前1 步预测:

#first I create the quarterly and monthly variables
n <- 20
qrt <- rnorm(n)
mth <- rnorm(3*n)

#I convert the data to time series format
qrt <- ts(qrt, start = c(2009, 1), frequency = 4)
mth <- ts(mth, start = c(2009, 1), frequency = 12)

#now I estimate the midas model and generate a 1-step ahead forecast 
library(midasr)
reg <- midas_r(qrt ~ mls(qrt, 1, 1) + mls(mth, 3:6, m = 3, nealmon), start = list(mth = c(1, 1, -1)))
forecast(reg, newdata = list(qrt = c(NA), mth =c(NA, NA, NA)))

此代码运行良好。现在假设我想要包含一个新的月度数据点,因此新的月度数据是:

nmth <- rnorm(3*n +1)

我尝试运行以下代码来估计新模型:

reg <- midas_r(qrt ~ mls(qrt, 1, 1) + mls(nmth, 2:7, m = 3, nealmon), start = list(mth = c(1, 1, -1))) #I now use 2 lags instead 3 with the new monthly data

但是我收到一条错误消息:'Error in mls(nmth, 2:7, m = 3, nealmon) : Incomplete high frequency data'

我在网上找不到有关如何处理此问题的任何信息。

【问题讨论】:

    标签: r forecasting ragged


    【解决方案1】:

    不久前I had to do 有类似的问题。如果我没记错的话,您首先需要使用具有减少滞后的旧数据集来估计模型,因此使用3:6 滞后您应该使用2:6 滞后:

    reg <- midas_r(qrt ~ mls(qrt, 1, 1) + mls(mth, 2:6, m = 3, nealmon), start = list(mth = c(1, 1, -1)))
    

    然后假设您观察到更高频率数据的新值 - new_value

    new_value <- rnorm(1)
    

    然后您可以使用这个新观察到的值来预测较低频率的变量,如下所示:

    forecast(reg, newdata = list(mth = c(new_value, rep(NA, 2))))
    

    【讨论】:

      猜你喜欢
      • 2018-08-27
      • 2021-07-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-24
      • 1970-01-01
      • 2017-08-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多