# Can PCA be applied for time series data?

I understand that Principal Component Analysis (PCA) can be applied basically for cross sectional data. Can PCA be used for time series data effectively by specifying year as time series variable and running PCA normally? I have found that dynamic PCA works for panel data and the coding in Stata is designed for panel data and not time series. Is there any specific type of PCA which works on time series data?

Update. Let me explain in detail.

I am presently constructing an index for Infrastructure in India with variables like road length, rail route length, electricity generation capacity, number of telephone subscribers etc. I have 12 variables through 22 years for 1 country. Though I have reviewed papers that apply PCA on time series and even panel data, PCA is designed for cross sectional data which assumes i.i.d assumption. Panel and cross sectional data violates it and PCA does not take into account the time series dimension in it. I have seen dynamic PCA being applied only on panel data. I want to know if there is a specific PCA that is applied on time series or running static PCA with year defined as time series variable will do the job?

• Singular Spectrum Analysis (SSA) is often called PCA for time series. en.wikipedia.org/wiki/Singular_spectrum_analysis – Vladislavs Dovgalecs Jun 23 '15 at 15:30
• Please review some of the posts in the sidebar to the right (-->) that refer to both PCA and time series. If any answer your question, please link to it in comments here, but if none do, you might explain the specific ways in which your issue differs from any of those. – Glen_b Jun 24 '15 at 5:27
• None of them answers the question of pca on time series. Specific queries on the topic either relates to science or are left unanswered. – Nisha Simon Jun 24 '15 at 7:13
• PCA, as a data transformation, dimensionality reduction, exploration, and visualization tool, does not make any assumptions. You can run it on any data whatsoever, including time series data. In fact, PCA is very often applied for time series data (sometimes it is called "functional PCA", sometimes not). I don't even know what "dynamic PCA" and "static PCA" should mean; don't worry and use standard PCA. – amoeba Jun 28 '15 at 13:11
• You may wanna consider using Functional PCA which is particularly designed for time series. The FDA package in R implemented fPCA. You will be able to find the multivariate fPCA. – Anne Jul 7 '18 at 23:47

One approach could be to take the first time differences of your 12 variables to ensure stationarity. Then calculate the $12\times12$ covariance matrix and perform PCA on it. This will be some sort of average PCA over the whole time span, and will not say anything about how the different timelags affect each other. But it could be a good starting point.

If you are interested in decomposing the time domain as well I would check out SSA as suggested in the comments.

When you series are (assumed) stationary a single covariance matrix is meaningful. If your data is integrated of an order of 1 or higher, as I suspect they might be, the estimation of a single covariance matrix will not yield consistent results. A random walk is for example integrated of order 1, and the estimated covariance of two random walks does not say anything about their co-movement, here co-integration analysis is required.

As suggested in the comments PCA in itself doesn't care about stationarity so you can feed PCA any positive semi-definite matrix and the PC decomposition will be fine in a PCA-sense.

But if your estimated covariance matrix does not represent anything meaningful about the data, then PCA will, of course, not either.

• +1. What do you mean by "the first time differences"? – amoeba Jun 28 '15 at 14:14
• I mean the first difference, so for each of the twelve x's I would do x_t - x_t-1. – Duffau Jun 28 '15 at 14:22
• So you suggest to do PCA on time derivatives of each time series, as opposed to time series themselves. That's interesting; why would this be your first suggestion? – amoeba Jun 28 '15 at 14:45
• For two reasons: 1) For covariance estimation to be consistent, the normal cross sectional assumptions is for the two random variables to be independent and identically distributed (iid). This ensures the convergence of the sample mean to expected value, the so called Law of large numbers (LLN). In time series analysis the assumption of two stochastic processes being iid is to restrictive. So it is replaced with the notion of stationarity (of many different kinds). For the LLN to hold and covariance estimation to be consistent the two series need to have a jointly stationary distribution. – Duffau Jun 28 '15 at 21:54
• If each stochastic process is staionary then (I'm allmost positive that) they have are jointly stationary, hence covariance estimation makes sense. First differences is a standard technique in econometrics to make time series "more stationary". And from here estimation and PCA is straight forward. So in short, because it is easy :-) .... ok there was no second reason.. – Duffau Jun 28 '15 at 22:00