In this guide, we will discuss Auto Regression In Time Series. For a stationary time series, an auto regression models sees the value of a variable at time ‘t’ as a linear function of values ‘p’ time steps preceding it. Mathematically it can be written as −yt=C+ϕ1yt−1+ϕ2Yt−2+…+ϕpyt−p+ϵt
Where,‘p’ is the auto-regressive trend parameter
ϵtϵt is white noise, and
yt−1,yt−2…yt−pyt−1,yt−2…yt−p denote the value of variable at previous time periods.
The value of p can be calibrated using various methods. One way of finding the apt value of ‘p’ is plotting the auto-correlation plot.
Note − We should separate the data into train and test at 8:2 ratio of total data available prior to doing any analysis on the data because test data is only to find out the accuracy of our model and assumption is, it is not available to us until after predictions have been made. In case of time series, sequence of data points is very essential so one should keep in mind not to lose the order during splitting of data.
An auto-correlation plot or a correlogram shows the relation of a variable with itself at prior time steps. It makes use of Pearson’s correlation and shows the correlations within 95% confidence interval. Let’s see how it looks like for ‘temperature’ variable of our data.
Showing ACP
In [141]:
split = len(df) - int(0.2*len(df)) train, test = df['T'][0:split], df['T'][split:]
In [142]:
from statsmodels.graphics.tsaplots import plot_acf plot_acf(train, lags = 100) plt.show()
All the lag values lying outside the shaded blue region are assumed to have a csorrelation.
Next Topic : Click Here
Pingback: Time Series - Naive Methods | Adglob Infosystem Pvt Ltd