Matlab:计算时间序列的相关性 [英] Matlab: Calculating Correlation of time series
问题描述
时间序列模型表示为
y(t) = 0.5 + 0.3y(t-1) + n(t)
其中
n(t) = 0.1*randn(500,1) for t=1,2,...,500
幻灯片包含相关性和协方差矩阵.相关公式为:E[y(t)*y(t)^T]
,可以使用xcorr
进行调用.我想知道如何不使用内置命令就可以为滞后版本E[y(t-1)*y(t-1)^T]
计算单个相关矩阵,以便最终实现以下表达式
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)
更新
例如,让
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)
推荐答案
我不确定我是否了解您问题的所有详细信息,但是如果您只想对信号的延迟版本进行操作,则可以做这样的事情...
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
如果xcorr不是您想要的操作,则可以使用这种索引方法来创建信号的时移版本,从而执行所需的任何操作.
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.
这篇关于Matlab:计算时间序列的相关性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!