ya it looks like you can't use predict to take in data. In general you could do the following:
fit a model to n-(prediction sample set length). Then use the predict function to do a 1 step forward forecast. Test to see how close it is to the actual 1 value ahead. Then train your model on n-(prediction sample set length-1). predict 1 step ahead and compare to the next value. rinse and repeat. -Rob On Thu, Mar 18, 2010 at 2:59 AM, RAGHAVENDRA PRASAD < raghav.npra...@gmail.com> wrote: > Hi, > > Thanks a lot.It was very useful to me.If i m correct we cant do real time > Stock forecasting using R with ARIMA+GARCH model using garchFit or any other > available packages which are avaibale in R as Predict function wont take any > test data. > > Eg: predict(garch11sp500t, 10) > > We just need to give how for how many periods we need the forecast > results.Is there any work around any packages avaiable where we can use test > data for prediction like we have in Neural Nets package. > > > Regards, > Raghav > > > On Wed, Mar 17, 2010 at 8:40 PM, Rob Forler <rfor...@uchicago.edu> wrote: > >> Hi, >> >> I can help, but what you are saying doesn't make sense. firstly what is >> fitted.ga? >> >> You can use predict from the garchFit that will give the predictions for >> fitted.gar for example. >> >> For example, >> >> library(fGarch) >> library(tseries) >> library(moments) >> >> data = get.hist.quote(instrument="^GSPC", "1990-01-01", "2010-02-01", >> quote = c("AdjClose"),provider=c("yahoo")) >> >> ret = diff(log(data)) >> >> garch11sp500t = garchFit(~arma(1,1) +garch(1,1), data=ret, >> cond.dist="std") >> >> > predtsp500 = predict(garch11sp500t, 10) >> > predtsp500 >> meanForecast meanError standardDeviation >> 1 0.0013071158 0.01049783 0.01049783 >> 2 0.0011799772 0.01051555 0.01050872 >> 3 0.0010749574 0.01053107 0.01051959 >> 4 0.0009882084 0.01054509 0.01053042 >> 5 0.0009165514 0.01055807 0.01054123 >> 6 0.0008573608 0.01057034 0.01055201 >> 7 0.0008084679 0.01058211 0.01056276 >> 8 0.0007680811 0.01059354 0.01057349 >> 9 0.0007347205 0.01060472 0.01058418 >> 10 0.0007071638 0.01061572 0.01059485 >> >> you will see that both the mean and the standard deviation is forecasted. >> This gives you both the "stock forecast" and the stocks' volatility >> forecast. >> >> now comparing the models you have a lot of different options. And it cares >> what you are looking to use the predictions for. >> >> In the above example imagine you were using the model to trade. You would >> want to pick the model that gives you the best pnl. >> >> Secondly you want to look at the acf and the pacf of the standarized >> residuals to makes sure that there are not any significant lags. Also you >> may want to look at the distribution of the residuals! are they really >> t-distributed? you can use a qq type test to determine this. if not you may >> have a model misspecification. you may need to use a skewed distribution or >> you may need to use something like aparch (in garchFit) which fits an >> asymmetric model/ >> >> you also want to look at summary(garch11sp500t) >> look at : >> Error Analysis: >> Estimate Std. Error t value Pr(>|t|) >> mu 1.003e-04 3.718e-05 2.697 0.00701 ** >> ar1 8.260e-01 5.913e-02 13.971 < 2e-16 *** >> ma1 -8.621e-01 5.267e-02 -16.368 < 2e-16 *** >> omega 4.090e-07 1.365e-07 2.998 0.00272 ** >> alpha1 5.743e-02 6.607e-03 8.693 < 2e-16 *** >> beta1 9.409e-01 6.484e-03 145.123 < 2e-16 *** >> shape 6.990e+00 6.820e-01 10.249 < 2e-16 *** >> --- >> you can see here that all the coefficients are very significant. >> >> also, >> AIC BIC SIC HQIC >> -6.539617 -6.530588 -6.539621 -6.536455 >> >> are computed from the summary. Google these. Picking a model with a lower >> aic or bic can be another way to choose the model. >> >> If you need more help let me nkow, >> Rob >> >> On Wed, Mar 17, 2010 at 1:11 AM, RAGHAVENDRA PRASAD < >> raghav.npra...@gmail.com> wrote: >> >>> Hi, >>> >>> Although my doubt is pretty,as i m not from stats background i am not >>> sure >>> how to proceed on this. >>> >>> Currently i am doing a forecasting.I used ARIMA to forecast and time >>> series >>> was volatile i used garchFit for residuals. >>> How to use the output of Garch to correct the forecasted values from >>> ARIMA. >>> >>> Here is my code: >>> >>> ###delta is the data >>> >>> fit<-arima(delta,order=c(2,,0,1)) >>> >>> fit.res <- resid(fit) >>> ##Check for Residuals >>> acf((fit.res-mean(fit.res))/sd(fit.res)) >>> acf(((fit.res-mean(fit.res))/sd(fit.res))^2) >>> fit.fore = predict(fit, n.ahead=test) >>> >>> ##Use ARIMA GARCH To fit residuals from ARIMA Model >>> 1. >>> fitted.gar<-garchFit(formula >>> =~arma(2,1)+garch(1,1),data=*fit.res*,cond.dist >>> = "std",trace=FALSE) >>> sresi=fitted....@residuals/fitted....@sigma.t ###Standardised >>> Residuals >>> acf(sresi) >>> acf(sresi^2) >>> fore.res<-predict(fitted.ga, n.ahead=test) >>> >>> OR >>> 2. >>> fitted.gar<-garchFit(formula >>> =~arma(2,1)+garch(1,1),data=*delta*,cond.dist = >>> "std",trace=FALSE) >>> sresi=fitted....@residuals/fitted....@sigma.t ###Standardised >>> Residuals >>> acf(sresi) >>> acf(sresi^2) >>> fore.res<-predict(fitted.ga, n.ahead=test) >>> >>> My Question is >>> 1. How to use fore.res(Result from Garch Model) to change fit.fore >>> (Forecasted values from ARIMA) >>> 2.Out of 1 and 2 for GARCH which one is correct.Pretty confused.Shud we >>> need >>> to use the residuals got from ARIMA Model or the series directly ? >>> >>> Regards, >>> Raghav >>> >>> [[alternative HTML version deleted]] >>> >>> ______________________________________________ >>> R-help@r-project.org mailing list >>> 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. >>> >> >> > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list 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.