I have a time series of data that is 300 days long. I compute PCA factor loadings on a moving window of 30 days. There are 7 stocks in the universe. Thus factors F1 through F7 are calculated on each PCA calculation.

However, the signs on factor loadings change. This causes problems when interpreting factor price time series.

What are the different approaches to deal with this problem?

-
For all components? When you say loadings, you mean the eigen vectors? Could you post some code? –  SpeedBoots Mar 19 '12 at 11:48
There's a related question that might help: link –  michaelv2 Mar 19 '12 at 15:04
@michaelv2 I'm not sure how what that link has to do with the question here. –  chrisaycock Mar 19 '12 at 15:10
My intent was to link to the original question, where some comments address the fact that spectral decompositions can produce eigenvectors with arbitrary signs (and some of the ways of dealing with that). –  michaelv2 Mar 20 '12 at 13:13

1) Eigenvector times minus one is also an eigenvector (with the same eigenvalue). 2) Distinct eigenvectors of a symmetrical matrix (i.e. covariance) are orthogonal. 1 and 2 imply that you can multiply a subset of all the eigenvectors of a symmetrical matrix by minus one an you still get a full set of eigenvectors

Which means, just impose that the first component of every factor is positive. If the PCA returns the first component as negative multiply all the vector by minus one. That will solve your problem.

-
Even there Mepuzza, youc ould still have a problem. The reason is that you have to be sure that the first element is greater than zero in absolute terms, otherwise slight changes in the historical matrix could perturbe this element and make it change signs. –  Anass May 18 '12 at 9:12
Good point. Thanks –  mepuzza May 18 '12 at 13:06

You can compute the PCA on overlapping windows, and try to match the eigenvectors: you may need to change not only their sign (since only the eigenspaces are well-defined, the sign of the eigenvectors is arbitrary) but also their order.

Here is some (untested) R code to do this.

# Sample data
k <- 7
n <- 50
found <- FALSE
while(!found) {
x <- matrix(rnorm(k*(n*1)),nc=k)
e1 <- eigen(var(x[-1,]))
e2 <- eigen(var(x[1:n,]))
found <- e1$vectors[1,1] * e2$vectors[1,1] < 0
}
colnames(e1$vectors) <- LETTERS[1:k] colnames(e2$vectors) <- letters[1:k]

# Compare the eigenvectors,
# by computing the cosine of the angle they form.
d <- cor(e1$vectors, e2$vectors)

# Permutation of the vectors
i <- apply(abs(d), 1, which.max)
e2$values <- e2$values[i]
e2$vectors <- e2$vectors[,i]

# Change the sign, if needed
j <- sign(diag(d[1:k,i]))
e2$vectors <- t( t(e2$vectors) * j )

-

If you're referring to this problem then there is a very complete answer on the cross validated stack exchange.

-