By failing to send your email in plain text format on this mailing list, we see 
a damaged version of what you saw when you sent it. 

Also, we would need some some data to test the code with. Google "r 
reproducible example" to find discussions of how to ask questions online. 

From the error message alone I suspect forecast is the function from the 
forecast package, and you are trying to create and modify a data object with 
that same name. At the very least re-using names is unwise, but I think your 
whole concept of how to create forecasts is deviating from the normal way this 
is done. But the scrambling of the code isn't helping. 

-- 
Sent from my phone. Please excuse my brevity.

On February 12, 2017 4:34:20 AM PST, Allan Tanaka <allantanak...@yahoo.com> 
wrote:
>Hi.
>I tried to run this R-code but still completely no idea why it still
>gives error message: Error in forecast[[d + 1]] =
>paste(index(lEJReturnsOffset[windowLength]),  : object of type
>'closure' is not subsettable
>Here is the R-code:
>library(rugarch); library(sos);
>library(forecast);library(lattice)library(quantmod); require(stochvol);
>require(fBasics);data = read.table("EURJPY.m1440.csv",
>header=F)names(data)data=ts(data)lEJ=log(data)lret.EJ =
>100*diff(lEJ)lret.EJ =
>ts(lret.EJ)lret.EJ[as.character(head(index(lret.EJ)))]=0windowLength=500foreLength=length(lret.EJ)-windowLengthforecasts<-vector(mode="character",
>length=foreLength)for (d in 0:foreLength) { 
>lEJReturnsOffset=lret.EJ[(1+d):(windowLength+d)]  final.aic<-Inf 
>final.order<-c(0,0,0)  for (p in 0:5) for (q in 0:5) {    if(p == 0 &&
>q == 0) {      next    }       
>arimaFit=tryCatch(arima(lEJReturnsOffset, order=c(p,0,q)),             
>        error=function(err)FALSE,                     
>warning=function(err)FALSE)    if(!is.logical(arimaFit)) {     
>current.aic<-AIC(arimaFit)      if(current.aic<final.aic) {       
>final.aic<-current.aic        final.order<-c(p,0,q)       
>final.arima<-arima(lEJReturnsOffset, order=final.order)      }    }
>else {      next    }  }
>spec <- ugarchspec(variance.model = list(model = "sGARCH", garchOrder =
>c(1,1)),                     mean.model = list(armaOrder =
>c(final.order[1], final.order[3]), arfima = FALSE, include.mean =
>TRUE),                     distribution.model = "sged")fit <-
>tryCatch(ugarchfit(spec, lEJReturnsOffset, solver='gosolnp'), 
>error=function(e) e, warning=function(w) w)if(is(fit, "warning")) { 
>forecast[d+1]=paste(index(lEJReturnsOffset[windowLength]), 1, sep=",") 
>print(paste(index(lEJReturnsOffset[windowLength]), 1, sep=","))} else
>{  fore = ugarchforecast(fit, n.ahead=1)  ind =
>fore@forecast$seriesFor  forecasts[d+1] = paste(colnames(ind),
>ifelse(ind[1] < 0, -1, 1), sep=",")  print(paste(colnames(ind),
>ifelse(ind[1] < 0, -1, 1), sep=",")) }}write.csv(forecasts,
>file="forecasts.csv", row.names=FALSE)
>  
>       [[alternative HTML version deleted]]
>
>______________________________________________
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to