I am trying to calculate forecasts one step ahead using the so-called MIDAS concept. Within the framework of this concept, forecasts are calculated depending on high-frequency data. For example, a dependent variable ycan be recorded annually and explained using an independent variable xthat can be selected, for example, quarterly.
There is a package called midasrthat offers many features. I can calculate forecasts with one step forward, using the function select_and_forecastfrom the mentioned package as follows (using the simulated data, which is a simplified version of the example, from the package user guide midasr):
Data Generation:
library(midasr)
set.seed(1001)
n <- 250
trend <- c(1:n)
x <- rnorm(4 * n)
z <- rnorm(12 * n)
fn.x <- nealmon(p = c(1, -0.5), d = 8)
y <- 2 + 0.1 * trend + mls(x, 0:7, 4) %*% fn.x + rnorm(n)
Calculation of forecasts (the forecast horizon outside the sample is controlled by an argument outsample, so in my example I calculate 10 forecasts from 240 to 250)
select_and_forecast(y~trend+mls(y,1,1,"*")+mls(x,0,4),
from=list(x=c(4)),
to=list(x=rbind(c(14,19))),
insample=1:250,outsample=240:250,
weights=list(x=c("nealmon","almonp")),
wstart=list(nealmon=rep(1,3),almonp=rep(1,3)),
IC="AIC",
seltype="restricted",
ftype="recursive",
measures=c("MSE"),
fweights=c("EW","BICW")
)$forecasts[[1]]$forecast
Now I would like to simulate a situation when a new value of a high-frequency variable becomes available, because, for example, a new month has passed, and the value for this month can be used in the model. I would do the following, but very uncertainly, if this is correct:
select_and_forecast(y~trend+mls(y,1,1,"*")+mls(x,0,4),
from=list(x=c(3)),
to=list(x=rbind(c(14,19))),
insample=1:250,outsample=240:250,
weights=list(x=c("nealmon","almonp")),
wstart=list(nealmon=rep(1,3),almonp=rep(1,3)),
IC="AIC",
seltype="restricted",
ftype="recursive",
measures=c("MSE"),
fweights=c("EW","BICW")
)$forecasts[[1]]$forecast
Theoretically, one involves new observations of the high-frequency variable by reducing the time index, but I do not know if the function is used correctly.
This question is for those who are familiar with the package. Can someone give a comment on this?
The formula I'm thinking of is this:
y_t=\beta_0 + \beta_1B(L^{1/m};\theta)x_{t-h+1/m}^{(m)} + \epsilon_t^{(m)}
With h=1in my case and adding 1/mto enable a new high-frequency surveillance