Time series clustering based on factor model