I am asking this question because the previous one wasn't very helpful and I asked about a different solution for the same problem.

The Problem

I have lateral positions, xcoord, of vehicles over time which were recorded as the distances from the right edge of the road. This can be seen for one vehicle in the following plot:

enter image description here

Each point on the plot represents the position of the front center of the vehicle. When the vehicle changes the lane (lane numbers not shown) there is a drastic change in the position as seen after the 'Start of Lane Change' on the plot.
The data behind this plot are like below:

  Vehicle.ID Frame.ID   xcoord Lane
1          2       13 16.46700    2
2          2       14 16.44669    2
3          2       15 16.42600    2
4          2       16 16.40540    2
5          2       17 16.38486    2
6          2       18 16.36433    2

I want to identify the start and end data points of a lane change by clustering the data as shown in the plot. The data points in the plot circled in red are more similar to each other because the variation between them is smaller compared to the data points in the middle which see large variation in position (xcoord).
My questions are: Is it possible to apply any clustering technique to segment these data so that I could identify the start and end point of a lane change? If yes, which technique would be most suitable?
I use R. I have tried Hierarchical clustering before but don't know how to apply it in this context. Please help.

  • 2
    $\begingroup$ I don't think clustering is the best approach. Instead I suggest treating it as a time series. Prior to lane change, the x position will probably fit a stationary distribution. Lane changes could be detected by tests for non-stationarity. An even simpler approach would be trend change detection via moving averages or similar, as is done in technical stock market analysis. $\endgroup$ Sep 22, 2015 at 6:10
  • 1
    $\begingroup$ Adding to AnonyMousse's answer and MrMeritology's comment, which I agree with, you can consider the following approaches: trend analysis (time series-based) and change point analysis (entropy-based or other). See my relevant answers and links within: on trend analysis and on change point analysis. $\endgroup$ Sep 22, 2015 at 7:16
  • $\begingroup$ Could you please recommend resources for R to implement these techniques? I have never used these before. $\endgroup$ Sep 22, 2015 at 12:09

1 Answer 1


I doubt any of the clustering algorithms will work well.

Instead, you should look into:

  • segmentation (yes, this is something different), specifically time series segmentation
  • change detection (as you said, there is a rather constant distribution first, then a change, then a rather constant distribution again
  • segment-wise regression may also work: try to find the best fit that is constant, linearly changing, and constant again. It's essentially four parameters to optimize in this restricted model: average before and after + beginning and end of transition.
  • $\begingroup$ Are there any tutorials for segmentation in R with similar kind of analysis? My search results in journal articles. $\endgroup$ Sep 22, 2015 at 12:07
  • $\begingroup$ I don't use R much (too slow), so you will have to use Google to find that. $\endgroup$ Sep 22, 2015 at 15:48
  • $\begingroup$ If you know about any Python resources please share those. Maybe I am not using right keywords in Google because all I get are journal articles pdfs. $\endgroup$ Sep 22, 2015 at 16:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.