# How to compare and cluster sets of daily time series?

I have multiple dataframes each representing traffic speed for each day of the year (366 dataframes for 366 days of the year). The raws of the dataframe are timestamp from 00:00 to 23:55 at 5 minute intervals and the columns are mileposts at 0.5 mile intervals and the entries are speed of traffic corresponding to the specific time and milepost.

I want to group days of similar traffic conditions to examine daily traffic patterns/variations, which is standard for traffic analysis at a macro level, e.g., examining traffic patterns during weekdays and weekends.

To do this, I will have to measure similarity of the dataframes and apply clustering algorithms. Any idea on how to calculate similarity of dataframes and cluster them? Any R package that can do this?

Thanks

• Your data maybe is stored as multiple data frames but from your description it rather sounds like you have a very long (one year) time series data with 5min intervals. Think of it rather as a single dataset. – Tim Jan 22 '15 at 17:35
• Yes, you are correct that the data can be considered as a single dataset. But the clustering has to be carried out based on the information corresponding to one complete day which contains 288 time series (there are 288 intervals of 5 minutes in one day). My question is how will you compare or meaa set of 288 time series with another set of 288 time series datasets? – Filly Jan 22 '15 at 18:12
• Why you need it to be analyzed using daily data? – Tim Jan 22 '15 at 18:13
• To examine daily traffic patterns/variations, which is standard for traffic analysis applications at a macro level, e.g., examining traffic patterns during weekdays and weekends. – Filly Jan 22 '15 at 18:18
• yes, you can do this using Dynamic time wrapping to determine similarity measures and then use a clustering algorithm. Here is a blog post that shows how to do this in R and here is another post. Also try searching time series clustering in this site, there is plenty of useful posts. – forecaster Jan 22 '15 at 21:33