# How to do the Time Series Forecasting, the right way?

#### cybergeek

##### New Member
Hello all,

I don't know much about the topic, but I want to learn.
I have been given a time series in the form of (date, number). and I need to forecast the values for a specific date (continuation of the time-series). What would be the correct procedure to do it and how can I forecast it?

So far I analyzed the input data:
my input is about 100K entries.
time interval is mostly 1 day interval, but is few cases it can be 1day +- few hours, and rarely 2days.

Q1: Should I eliminate the irregular entries? and then should I interpolate the missing data to have 100% regular input data? Or leave it the way it is and algorithm will treat it for me.

Q2: Should I keep the first entry as date? or is it more common to convert it as the time interval from the previous entry?

In the image below you see the crop of the data cycle, it shows 3 cycles(?). As you can see the cycle has some variation from one to the other and is repeated (with slight changes) in whole time series. the period of each cycle is about 150 days.

I also tried the TREND functions such as logarithmic and polynomial least square fitting, but they did not produce good results.

What are the passes that I should proceed from here?

NB. We do not have any information on the nature of the time series or what the numbers represent.

Thank you very much

#### mmercker

##### Member
Hi,

maybe you can model this with Autoregressive (AR) Models, or their generalizations: AR(I)MA models. They are widely used for time series and forecasting and I think they can describe peirodic data as shown in your plot pretty well.

Usually you have time series data with equidistant time intervals between the measurements. Here, usually you do not need to tell the program the time covariate, the data should be only ordered in a chronological way. That would indeed require that you "regularize" your data.

Some programs offer as well to treat the time variable as a continuous covariate, what means in this case you don't have do change your data very much (maybe you have to convert your date variable into a numerical one).

There are several functions in R which can deal with AR-Models, e.g. gls() or lme() from the nlme package.