Closed kazimsanlav closed 6 years ago
Which function is that? It is not exported from midasr. Which midasr version are you using?
I am using midas version 0.6 and trying to run the sample code given in oos_prec. In the issue, there was a typo ( oob_prec ) but sample code is still not working.
Change the function rep1
code to this one and it will work:
rep1 <- function(n) {
dt <- gendata(round(1.25*n))
ni <- n
ind <- 1:ni
mind <- 1:(ni*12)
indt<-list(y=dt$y[ind],z=dt$z[mind],trend=dt$trend[ind])
outdt <- list(y=dt$y[-ind],z=dt$z[-mind],trend=dt$trend[-ind])
um <- midas_r(y~trend+mls(z,0:16,12),data=indt,start=NULL)
nm <- midas_r(y~trend+mls(z,0:16,12,nealmon),data=indt,start=list(z=c(1,-1,0)))
am <- midas_r(y~trend+mls(z,0:16,12,almonp),data=indt,start=list(z=c(1,0,0,0)))
modl <- list(um,nm,am)
names(modl) <- c("um","nm","am")
list(norms=sapply(modl,bnorm),
mse=sapply(modl,function(mod)mean((forecast(mod,newdata=outdt)$mean-outdt$y)^2)))
}
The code was written for older version of midasr. Forecast method now returns a forecast object for compatibility with forecast package.
Thanks.
Hi, I am trying to run the sample code supplied for the function 'oob_prec', but I get the following error message: 'Error in forecast(mod, newdata = outdt) - outdt$y : non-numeric argument to binary operator Called from: mean((forecast(mod, newdata = outdt) - outdt$y)^2)'
R version 3.4.3