How do I apply
e.divisive method from
ecp package effectively on multivariate time-series, so that the resulting segments and changepoints are consistent with domain knowledge and the process is efficient?
I have data of cars moving in a lane. In the car-following literature, the movement of a subject car relative to its lead car in the same lane can be divided into at-least 3 distinct states:
Distance between the two cars is large, so the subject car (for which the data is collected) either accelerates or maintains speed. So, the position of the gas pedal is expected to be fully or partially pressed and maintained for some time.
Speed difference between subject car and lead car is quite large because subject car was moving at higher speed. But due to decrease in distance, the subject car reduces speed. So, it is expected that driver in subject car completely steps off the gas pedal and in some cases follow by pressing brake pedal.
Subject car reduces speed until the speed difference becomes zero and the distance reduces to the distance that subject car wants to keep while closely following lead car. So, it is expected that we see slight up and down movements in the position of gas pedal in subject car because driver tries to maintain the current speed equal to lead car's speed.
Here is one example that illustrates 2 states:
I am showing plots for 5 variables for a subject car called "Cars_02". The x-axis contains the time frames (60 frames in 1 second), and y axis contains the given variable. On each plot I also manually put vertical lines where I think the
Following states start. For keeping this question medium sized, I'm skipping what happened before these 2 states.
You can see that
Approaching starts when the driver steps off the gas pedal (see gas pedal position, plot # 2) which causes a decrease in speed (see plot # 1). Afterward,
Following starts when speed difference becomes zero (plot # 4) and distance between the car gets shorter and remains consistent for some time (plot # 5). Also, the gas pedal position has up and down movements which shows that driver tried to maintain the speed.
What I want to do?
I want to divide these time-series into segments where each segment represents a
car-following state (basically automating my manual effort to identify pattern in multiple variables and detecting where the state changed). This is my first time using
ecp so I have several questions:
- Is using
ecpgoing to be useful in this case?
- Should I normalize all variables first?
- Should I smooth all variables as they have tiny undulations?
- How can I make
e.divisiverun faster? The above time series database is about 6000 data points. And I have 30 other time series.
What I have tried?
I tried using
e.divisive on a sliced gas pedal position variable only (first 2000 data points). I kept the
R very small because otherwise it takes very, very long on my 12 GB RAM laptop.
library(ecp) Xnorm <- as.matrix(df$acc_pedal_pos) output1 <- e.divisive(Xnorm, R = 20, alpha = 2) ts.plot(Xnorm,ylab='Value',main='Change points') abline(v=output1$estimates[c(-1,-21)],col='red',lty=2)
You can see that the small steps in the gas pedal positions cause detection of multiple changepoints, however, they should actually be part of the same behavior: `accelerating to reach a desired speed in Free-driving'.
So, what is the most effective way to use
ecp for my problem?