Reputation: 1
I'm using the midas_r package and I'm wondering if there is a possibility to lower the MIDAS model sensitivity for the starting value of a weighting function to minimize my error metric.
I did a simulation with different starting values and I observe that the forecasting results are quite sensitive to the initial values. There is around 30% difference between the min and max Root Mean Square Forecast Error (RMSFE) for the simulation.
I simulated the starting value distribution below :
df<-setNames(data.frame(matrix(ncol=2,nrow=n_simulation)),c('Starting_value','RMSFE'))
for ( i in 1:n_simulation){
randomvalue_1 <- runif(1,-5.0,5.0)
randomvalue_2 <- runif(1,-5.0,5.0)
randomvalue_3 <- runif(1,-5.0,5.0)
random_vecteur=c(randomvalue_1,randomvalue_2)
mod1 <- midas_r(target_data ~ mls(daily_data, 1:2, 25, nealmon) + mls(target_data, 1:1, 1),
start=list(daily_data=random_vecteur),Ofunction = 'optim',method='Nelder-Mead')
##Calculate average forecasts
avgf <- average_forecast(list(mod1),
data=list(daily_data=daily_data,target_data=target_data),
insample=1:132,outsample=133:180,
type="rolling",
measures=c("MSE","MAPE","MASE"),
fweights=c("EW","BICW","MSFE","DMSFE"))
df$Starting_value[i]=paste('(',paste(toString(random_vecteur),')'))
df$`RMSFE`[i]=sqrt(avgf$accuracy$individual$MSE.out.of.sample[1])}
Is there something that I can do to lower the model sensitivity, Or I'm doing something wrong? I tried to use the update function #update(Ofunction='nls') as suggested in Mixed Frequency Data Sampling Regression (2016) Models: The R Package midasr, but I still observe the sensitivity.
I'm willing to share my data if needed
Thank you!
Upvotes: 0
Views: 148
Reputation: 1
you need to see if the convergence status of the model is 0, otherwise the model didn't find the optimal weight values. For checking the convergence of the model you can run the following code:
mod1[["convergence"]]
The value 0 indicates successful convergence, 1 indicates unsuccessful convergence.
If the convergence status is 1, you can try to optimize the research of the optimal weights by providing a gradient function. For a nealmon weight function you can define the following gradient function:
nealmon_gradient <- function(p, d, m) {
i <- 1:d
pl <- poly(i, degree = length(p) - 1, raw = TRUE)
eplc <- exp(pl %*% p[-1])[, , drop = TRUE]
ds <- colSums(pl * eplc)
s <- sum(eplc)
cbind(eplc / s, p[1] * (pl * eplc / s - eplc %*% t(ds) / s^2))
}
After defined it, try replacing the optimization Nelder-Mead with the gradient function in this way:
mod1 <- midas_r(target_data ~ mls(daily_data, 1:2, 25, nealmon) + mls(target_data, 1:1, 1),
start=list(daily_data=random_vecteur),
weight_gradients = list(nealmon=nealmon_gradient))
All this information is available in Mixed Frequency Data Sampling Regression (2016) Models: The R Package midasr you mentioned.
Upvotes: 0