mpiktas / midasr

R package for mixed frequency time series data analysis.
http://mpiktas.github.io/midasr/
Other
73 stars 34 forks source link

how to use polystep in a midas_r formula? #91

Open Theo24K opened 11 months ago

Theo24K commented 11 months ago

Hi, i dont know how to use the step function specification. how to set starting value for polystep, i cant find any examples.

Theo24K commented 11 months ago

step <- midas_r(y~mls(y,1,1)+mls(xx,0:3,3,polystep),start = list(xx=list(c(1,2,3,4),3,3,a=c(2,2,2)))), for example, i tried this,and error:Error in polystep(c(xx1 = 1, xx2 = 2, xx3 = 3, xx4 = 4), 4L, 3) : argument "a" is missing, with no default came out, how to set the starting value properly?

vzemlys commented 11 months ago

You should supply a into mls, not in start. The following should work:

step <- midas_r(y~mls(y,1,1)+mls(xx,0:3,3,polystep,a=c(2,2,2)),start = list(xx=list(c(1,2,3,4))))

Starting values are only needed for the parameters of weight function which are optimized. In step function parameter a is fixed.

Theo24K commented 11 months ago

Thanks!
I encountered a new error when using average_forecast(), like this, avgf09.fixed <- average_forecast(list(nealmon09,almonp09,beta0.09,betan.09,step.09),data = list(y=y,xx=xx), insample = 1:47,outsample = 48:50, type = 'fixed', measures = c("MSE","MAPE","MASE"), fweights=c("EW","BICW","MSFE","DMSFE")) Error in midas_r.fit(prepmd) : The optimisation algorithm of MIDAS regression failed with the following message: Error in if (sum(nb) < eps) { : missing value where TRUE/FALSE needed

Please try other starting values or a different optimisation function how to solve this ?