# Using a time series model to forecast future values in R

I would like to use a set of weather-related historical data to fit a time series (let's say 1970-2000, Fourier terms plus ARIMA terms), but then use the fit on recent data (i.e., the last week/month of data) to forecast the upcoming day/week/month. All of the functions that I've found forecast from the endpoint of the dataset used to fit.

Can someone point me in the right direction? Or let me know it doesn't exist and I have to write it out the long way (i.e. Tomorrow = fit\$coef[1]*Yesterday + ...)?

• How about simply using a moving average? – Feng Mai Jan 19 '12 at 15:52
• My series needs several fourier terms, and after that is an ARIMA (1,1,5) process. – Nicole Jan 19 '12 at 16:06
• You mention fourier and ARIMA: is this a univariate problem, or multivariate? – Wayne Jan 19 '12 at 19:14
• So basically you just want to know how to make R predict some new data from a ready model? If so, you could make it more clear and add some details about what packages are you using, etc. – user88 Jan 20 '12 at 10:50
• it is going to be a multivariate problem eventually, but for now it is univariate. yes, I want to predict, maybe that's why I'm not finding what I need, I've been searching for tools to "forecast". I am currently testing arima() and auto.arima() using xreg for the fourier terms. To keep it simple, let's say I have: fit = auto.arima(data), but now I have data.latest, and I want to use the fitted terms in "fit" to forecast/predict off of data.latest. I'm going to look around for "predict", thank you – Nicole Jan 20 '12 at 13:54

The difficulty you may have with auto.arima (and arima) is that I believe you'll have to do some futzing around to accomplish your task. The predict method for arima predicts n.ahead steps beyond the end of your training data. But your training data is from 1970-2000, while you're wanting to predict in 2011-2012 (I assume). It wouldn't make sense to tell it (with monthly data) to forecast 130 months beyond the end of your training data. And in fact it sounds like you do have, say, 2011 data and want to use that to predict 2012.
I wish I knew enough about the process to offer an answer beyond, "Now you need to take the ARIMA coefficients and create your own predict.arima function." If your process is ARI (no MA), you could use R's ar, whose predict function actually does allow you to enter new data (say 2011) to predict from. You could do the I part (differencing) yourself with R's diff function. No exogenous variables, though.
• @Nicole: it may be possible to use arima, but it appears to me that all it saves of the original data is the residuals (innovations), though it wants to predict from the end of the original data forwards. R has LOTS of packages, though, so there may be something that works. I'd suggest looking in the CRAN website's (cran.r-project.org) Task Views to get a feel for what's out there. – Wayne Jan 20 '12 at 18:46