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

12 visualizaciones (últimos 30 días)
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.

Respuestas (4)

Jeff Miller
Jeff Miller el 7 de Feb. de 2019
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 el 8 de Feb. de 2019
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 comentario
Jeff Miller
Jeff Miller el 8 de Feb. de 2019
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);

Iniciar sesión para comentar.


DanR
DanR el 8 de Feb. de 2019
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 comentarios
DanR
DanR el 8 de Feb. de 2019
sorry a and b has a value each minute.
Jeff Miller
Jeff Miller el 10 de Feb. de 2019
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.

Iniciar sesión para comentar.


DanR
DanR el 8 de Feb. de 2019
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?

Community Treasure Hunt

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

Start Hunting!

Translated by