我正在尝试使用这个midasr包,但出了点问题。我有月度数据(= y),并希望将它们与每日数据(= x)混合。我设法运行回归没有错误但是当我尝试使用它来预测数据时,我得到以下错误:rep(NA,h)中的错误:无效的'times'参数 我不知道它的NA值在哪里。说实话,我也不知道在哪里看。我提供的数据都是数字。
当我进行追溯()时,我得到以下输出:
8: static_forecast(object, h, insample, outsample, yname)
7: point_forecast.midas_r(object, newdata = newdata, method = method,
insample = insample)
6: forecast.midas_u(reg_s, list(partial_x = partial_xn, partial_com = partial_comn),
method = "static")
5: forecast(reg_s, list(partial_x = partial_xn, partial_com = partial_comn),
method = "static") at taylor.r#201
4: eval(expr, envir, enclos)
3: eval(ei, envir)
2: withVisible(eval(ei, envir))
1: source("M:/semester6/r_taylor/taylor.r", echo = TRUE)
这是代码:
reg_s = midas_u(partial_y ~ partial_x + mls(partial_com, k = 0:(COMMODITY_OBSERVATIONS - 1), m = COMMODITY_OBSERVATIONS))
partial_xn = int_diffs[i + SEC_STAGE_WND_SIZE]
partial_comn = db_oc$COM_SPOT_RATE[(((i + SEC_STAGE_WND_SIZE - 1) * COMMODITY_OBSERVATIONS) + 1):((i + SEC_STAGE_WND_SIZE) * COMMODITY_OBSERVATIONS)]
ret = forecast(reg_s, list(partial_x = partial_xn, partial_com = partial_comn), method = "static")
由于我只想预测下一个值,partial_xn只包含一个数字,而partial_comn再次包含COMMODITY_OBSERVATIONS指定的数字。
我还检查了回归过程中是否出现了问题,但似乎没问题。
Call:
lm(formula = partial_y ~ partial_x + mls(partial_com, k = 0:(COMMODITY_OBSERVATIONS -
1), m = COMMODITY_OBSERVATIONS), data = ee)
Coefficients:
(Intercept)
0.174389
partial_x
0.009113
mls(partial_com, k = 0:(COMMODITY_OBSERVATIONS - 1), m = COMMODITY_OBSERVATIONS)X.0/m
0.007279
mls(partial_com, k = 0:(COMMODITY_OBSERVATIONS - 1), m = COMMODITY_OBSERVATIONS)X.1/m
-0.028900
mls(partial_com, k = 0:(COMMODITY_OBSERVATIONS - 1), m = COMMODITY_OBSERVATIONS)X.2/m
0.015566
有什么想法吗?