title: PCA with panel data in R
body: <p>I want to apply Principal Component Analysis on a panel data set in R but I am having trouble with the time and entity dimension. My data has the form of</p>
  <pre><code>    city year x1_gdp x2_unempl
  1 Berlin 2012   1000      0.20
  2 Berlin 2013   1003      0.21
  3 Berlin 2014   1010      0.30
  4 Berlin 2015   1100      0.27
  5 London 2012   2733      0.11
  6 London 2013   2755      0.12
  7 London 2014   2832      0.14
  8 London 2015   2989      0.14
  </code></pre>
  <p>Applying standard PCA on x1 and x2 does not seem to be a good idea because the observations withing group (e.g. gdp of Berlin 2012 and 2013) are not independent from each other and pca commands like <code>prcomp</code> cannot deal with this form of autocorrelation.</p>
  <p>I started to read into Dynamic PCA models but R commands like <code>dpca {freqdom}</code> which &quot;decomposes multivariate time series into uncorrelated components&quot;. However, they require a <em>time series</em> as input. How can I apply DPCA or any other dimension reduction technique in this panel setting?</p>