# reconstruction of time series in SSA

i am trying to reconstruct time series from SSA ,because according to this link

http://en.wikipedia.org/wiki/Singular_spectrum_analysis

there is procedure

4th step: Diagonal averaging.


i have with started following code

clear all;
n=length(B);
l =input('Give the size of the interval: ' );% Number of columns in the Data matrix
m=n-l+1;%number of rows in the Data matrix
X = zeros(m,l);
for i=1:m
X(i,:)=B(i:i+l-1);
end;
[U E V]=svd(X);


now which procedure should i make?i should some eigenvalues right?from example let us consider following code

>> E=E(:);
>> stem(E);


in this case i should choose first four eigenvalue right?what i would like would be if i will indicate starting index of eigenvalue and ending point of eigenvalue and i will reconstruct time series in these range,how can i do it?please help me

I'm interested in SSA and the related techniques and I made an implementation which may be useful to you. Take a look at this Scilab code: https://gist.github.com/werediver/9785544 Scilab language is pretty similar to Matlab and the code should be easy to port.

You're applying SVD directly to the trajectory matrix (the time delay embedding of the time series). That's possible and will work, but usualy SVD is applied to the covariance matrix $C=XX'$.

Right after SVD you have the eigenvalues (they are shown on your plot), but SSA is not done yet. Next, you need to compute the principal components of the trajectory matrix: $V_i=\frac{X'U_i}{\sqrt{\lambda_i}} (i=1,...,L)$ You need $\sqrt{\lambda_i}$ when applying SVD to the covariance matrix and just $\lambda_i$ when SVD is applied directly to the trajectory matrix.

So now the SSA decomposition is done and you want a partial reconstruction. The time domain representation of $V_i$ is $X_i=\sqrt{\lambda_i}U_iV_i'$. These components are additive so sum all the components you're interested in and then apply diagonal averaging to get from $X_I$ to univariate time series. Diagonal averaging produces a vector from averaged antidiagonals of the $X_I$ matrix, take a look at my implementation for example.

I can point you to a good description of Basic SSA: Singular Spectrum Analysis for Time Series book by N. Golyandina & A. Zhigljavsky has freely available sample, Chapter 2: Basic SSA. This chapter completely covers Basic (univariate) SSA decomposition & reconstruction algorithms and gives many advices on interpretation of the decomposition.

There are also pretty good book (teaching aid) in Russian language if it's appropriate for you: Метод «Гусеница»-SSA: анализ временных рядов by N. Golyandina.

• thanks very much,but it seems a bit confusing for me,i have left and right singular vectors,so next what i should do? – dato datuashvili Apr 16 '14 at 10:15
• The left singular vector presents orthonormal basis of the column space of the trajectory matrix. SSA operates on the column space of the trajectory matrix only so you can discard the right singular vector. – werediver Apr 16 '14 at 10:59
• but what about my code?how can i fix this error? – dato datuashvili Apr 16 '14 at 11:13
• from theory point of view i dont need it,i need code just – dato datuashvili Apr 16 '14 at 11:45
• You did not mentioned any errors in your originl question. If you need just a working code you can take mine implementation and adapt it to Matlab (should be very easy). Or at least read it and take the parts you need. I see from your profile you're mature in math, but I don't see from your question that you don't need a detailed description of SSA algorithm so I provided you with a couple of links, hope this will help. – werediver Apr 16 '14 at 11:49