问题
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)
回答1:
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.
来源:https://stackoverflow.com/questions/27113142/matlab-calculating-correlation-of-time-series