Regression analysis; How do I detect a delayed relation between two signals

Hi. I have a math question regarding regression analysis. If one has two signals (a) a scalar time series of values, and another scalar time series of values (b), that are the same length in time. Now I want to know if there is any relation between a and b, so that if a behaves in a certain way, b behaves in a certain way but with a delay in reaction. I want to know if there is any mathematical method to figure out IF they have a relation at all, and if so to what degree (in a mix with random noise), and also what the delay is in time (or % of total length of the series) for the relation to appear in b. If someone can tell me or direct me to a method described as formulas or how to set this up in Matlab, I would be very happy.

回答 (4 件)

Jeff Miller
Jeff Miller 2019 年 2 月 7 日

0 投票

It sounds like you are looking for what is sometimes called "lagged regression". The basic idea is to use regular regression to predict the values b(t) from the values a(t-lag). You systematically try different lag values and see which one gives you the best predictions (e.g., lowest MSe). Some lag will always work best (even if it's just by chance).
DanR
DanR 2019 年 2 月 8 日

0 投票

Ok.. so in MatLab, I use the Curve Fitting function and then do a script that goes through it incrementing (a) for each round, and then for example draw out the results on a graph to see a pattern where in the lag relations are most prominent? Do you have info on how to do this in MatLab? Links to scripts, YouTube videos or alike? Thanks

1 件のコメント

Jeff Miller
Jeff Miller 2019 年 2 月 8 日
I've never used the curve fitting function so I can't say how to do it with that. I'd use regress something like this (code not checked):
% a and b hold pre-existing data
MaxLag = 10; % The largest lag you want to check
MSes = zeros(MaxLag,1); % to hold the results
for lag=1:MaxLag
ashort = a(1:end-lag); % data lost at the end of a because we have no b at the lag of interest
bshort = [ones(size(ashort)) b(lag+1:end)]; % matlab's regress requires a column of 1's
[b,bint,r,rint,stats] = regress(bshort,ashort); % fit regression eqn
MSes(lag) = stats(4);
end
plot(1:MaxLag,MSes);

サインインしてコメントする。

DanR
DanR 2019 年 2 月 8 日

0 投票

So how do I differentiate between "real" relation at a point that seems to show such, from luck in the "brute force" approach actually seeing noise that "happened" to hit right?

4 件のコメント

Jeff Miller
Jeff Miller 2019 年 2 月 8 日
There is no way to do this for sure, within the existing data set. Of course if the relation you find is really strong, perhaps it is implausible that it was accidental.
Get a fresh data set and see if you get the same pattern again.
(By the way, it is better to use the "comment on this answer" link for discussing answers, rather than adding a new answer.)
DanR
DanR 2019 年 2 月 8 日
thanks!!!!!
ok, so if we have a set of a and b that each are 30 days in length, b has a value each min), we could test the lagged relation by splitting the 30 days in overlapping segments and do the script on each segment? lets say a segment of 3 days, so we get around 20 overlapping segments?
If the graph shows a strong difference on the same lag spot in each segment, we have a strong true relation?
DanR
DanR 2019 年 2 月 8 日
sorry a and b has a value each minute.
Jeff Miller
Jeff Miller 2019 年 2 月 10 日
Something like that. I don't think I'd trust overlapping segments, though, since they share data and thus produce non-independent outcomes. If you have data minute by minute, you might split into much smaller segments (e.g., day by day) unless the time lag of the response is very slow.

サインインしてコメントする。

DanR
DanR 2019 年 2 月 8 日

0 投票

Intuitively, I would say that if plotting out MSe as you say, and finding a big difference in most of the (a) values (random noise) in comparision with a specific point (aka a spike in the plot curve), then the chance for a real relation with that specific lag is high?

カテゴリ

ヘルプ センター および File ExchangeDescriptive Statistics についてさらに検索

質問済み:

2019 年 2 月 7 日

コメント済み:

2019 年 2 月 10 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by