-1

The time series model is expressed as

y(t) = 0.5 + 0.3y(t-1) + n(t)

where

n(t) = 0.1*randn(500,1) for t=1,2,...,500

Slides contain the Correlation and covariance matrix. The formula for correlation is: E[y(t)*y(t)^T] which can be invoked by using xcorr. I would like to know how one can calculate the individual Correlation matrix for its lagged version E[y(t-1)*y(t-1)^T] without using the inbuilt commands so that I can finally implement the following expression

 trace([E[y(t-1)*y(t-1)']]^-1) 

UPDATE

For example, Let

y = randn(10,1);

for t = 1:10
disp(y(t));
end

Expectation_y =  sum(y(1:end))/10

Likewise, how do I perform expectation for lagged variables and then implement the formula =

 trace([E[y(t-1)*y(t-1)']]^-1)
SKM
  • 959
  • 2
  • 19
  • 45
  • Your expression for covariance contains a typo, it should be cov = E[(y(t)-mean)^2] (http://nl.mathworks.com/help/matlab/ref/cov.html), your expression resembles autocorrelation coefficient c1 (http://nl.mathworks.com/help/econ/autocorr.html). – Kostya Nov 24 '14 at 20:55
  • 1
    Are you looking for explicit expressions for mean and cov, or their symbolic expression for AR(1) process? – Kostya Nov 24 '14 at 20:59
  • actually I think the wording is wrong - I suppose it should be `E[(y(t) - E[y(t)])*(y(t-1)-E[y(t-1])]` - but I'm puzzled how one could consider to use the builtin `mean` function for that. – bdecaf Nov 24 '14 at 21:03
  • to the question - what you write is (with minor flukes) valid matlab code - so what's the problem with it? – bdecaf Nov 24 '14 at 21:19
  • @bdecaf:The thing is how can I obtain the answer to this multiplication = 'y(t-1)*y(t-1)' for t = 1 to 1000 (say)? This will yield a matrix. Then I need to take the Expectation and later trace of the Expectation. This is very similar to computing the individual elements that constitute the Correlation Matrix, 'E[y(t)*y(t)^T]'. In the current problem, I don't know how I can implement the analytical expression 'E[y(t-1)*y(t-1)^T]'. If 'E[y*y^T]' is feasible, then surely it is possible to implement the lagged version also. Is there a way to do? Please help. – SKM Nov 25 '14 at 00:51
  • What are the dimensions of y and y(t)? – bdecaf Nov 25 '14 at 06:17
  • @bdecaf: They both are same and is one dimensional time series signal/vector of one column containing t = 10000 data points. – SKM Nov 25 '14 at 06:57
  • I thought y(t) would be a single entry in y. I don't understand how this makes sense in case they are the same. – bdecaf Nov 25 '14 at 07:16
  • @bdecaf: What I mean is for example let y be an array, y = [0.1, 0.9, -0.7]. So, in this case t=3 and y(1) = 0.1, y(2)=0.9 and y(3) = -0.7. – SKM Nov 25 '14 at 07:51
  • Look the question is very confusing right now. Can you create two vectors: y - as in your statement and Ey containing E[y(t)] for t=1:10? I'm sure it's easier if we see some numbers as example. – bdecaf Nov 25 '14 at 07:59
  • @bdecaf: I have provided an example to better explain. Also, this Question may seem a repeat of my previous Question asked here http://stackoverflow.com/questions/27052558/matlab-confusion-related-to-correlation-operation-for-lags. Actually, the previous Question went through several revisions as it was basically on Statistics and meaning of the expressions. I was advised to re-write the Question to keep I on topic. I did no realize that by doing revisions, I boiled down to the same Question asked here! Thank you for your effort to help me out. – SKM Nov 25 '14 at 08:20

1 Answers1

0

I'm not sure that I understand all of the details of your question, but if you just want to operate on a delayed version of a signal, you can do something like this...

%xcorr with a 1-sample shifted version of itself
[c,lags]=xcorr(t(1:end-1),t(2:end));  

%xcorr with a 2-sample shifted version of itself
[c,lags]=xcorr(t(1:end-2),t(3:end));

%etc

If xcorr is not the operation that you want, you can do whatever operations you'd like with this indexing method of creating a time-shifted version of your signal.

chipaudette
  • 1,655
  • 10
  • 13
  • Thank you so much! This partly answers my Question, however there is one thing which I don't understand. Could you please clarify?Assuming, t is the variable, In the first statement xcorr(t(1:end-1),t(2:end)), does this correspond to t(I-1)*t(I-2)? The other half of the Question was how do I calculate the Expectation of the result of this operation. – SKM Nov 25 '14 at 06:39
  • I am interested to know if there is a rule for indexing. I have come across for t=2, y(t) is written as y(2:end-1) ; y(t-1) = y(1:end-1) etc. I get confused when to put end-1 and which is the index to begin with. – SKM Nov 25 '14 at 21:04
  • 1
    Regarding the indexing...if we assume that `t` has a length of 100, then our time-shifted vector `t(2:end)` will have a length of 99. To do our comparison with the non-shifted vector `t`, we need shorted the non-shifted vector by one...hence `t(1:end-1)`. The same argument goes for the other example...`t(3:end)` would be 98 elements long, so we shorten `t` via `t(1:end-2)` to make it have a length of 98, – chipaudette Nov 25 '14 at 21:52
  • So, both the style of writing means the same right in the context of containing the same number of elements. But, t(3:end) not equal to t(1:end-2) because in the former notation we are not considering the first 2 samples and in the latter case, the last two samples are discarded. Why are we doing this for calculating the correlation? Can you please shed some insights into this? I just noticed this right now. – SKM Nov 25 '14 at 23:19