logo

Time Series Regression Analysis 📂Statistical Analysis

Time Series Regression Analysis

Definition

Time series regression analysis refers precisely to the technique of performing regression analysis using time series data. It’s true that regression analysis is not inherently well-suited to handling time series data, yet, when dealing with multiple series of time-series data, it can be beneficial to borrow the ideas and tools of regression analysis.

Practice

1.png

Suppose we are given two types of data, x and y, as shown above. Of course, the shapes of the two data types are not completely identical, and they differ at each point in time, but when viewed as a whole, we can see that the fluctuations of x occur similarly in y, with a lag of about $k=10$.

2.png

Indeed, when plotting y with a red solid line on the same screen, it appears as shown above. Accordingly, if we give a lag of 10 to x and perform simple regression analysis, we can confirm that the speculation roughly matches.

20190731_143111.png

3.png

If we represent the actual fit with a blue solid line, we can confirm that x can predict y quite accurately, though not perfectly. Of course, it’s not a method that fits the data perfectly, but it should be used when necessary.

Code

Below is an example code written in R.

library(TSA)
set.seed(150421)
data("bluebird")
x<-ts(c(scale(bluebird[-(1:10),1])))
y<-ts(c(scale(-zlag(bluebird[,2],d=10)[-(1:10)])))
example=ts.intersect(x,y)
win.graph(6,5); plot(example,yax.flip = T)
win.graph(6,4); plot(example[,1]); lines(example[,2],col='red')
legend("topright",pch=16,col=1:2,legend=c("x","y"))
out<-lm(y~zlag(x,d=10)); summary(out);
win.graph(6,4); plot(y); lines(c(rep(NA,10),fitted(out)),col='blue\')
legend("topright",pch=16,col=c(1,4),legend=c("x","fitted"))