Time Series Analysis

   Daily sales data, hourly stock price, yearly population number can be an example for the time series data type. Time is the main dimension in above-mentioned examples. So, time series data is the series of metrics data spaced in a time dimension.
   Main purposes of time series analysis are:
  • decomposing and explaining data (trend, seasonal variation)
  • forecasting (predicting future events based on historic data) 
  • clustering and classification of data

Common data characteristics

There are some common assumptions of time series data.
Stationarity
  - the mean of series is a constant.
  - the variance of the series does not change over time
  - the covariance does not change over time.

Shortly, stationarity means that mean, variance and covariance of data do not change over time.


Time Series Data Decomposition

   Time series decomposition is a method to split data series into components. In this technique, time series data is decomposed into trend, seasonal, cyclic, and irregular (noise) components.
  • Trend component reflects the overall direction in data.
  • Seasonal component is a variation that occurs at specific regular intervals in data series (e.g., weekly, monthly).
  • Cyclic component describes repeated but non-periodic fluctuations in data.
  • Irregular (noise) component is residuals, a remaining of after removing above components from data series.
   Below sample is a decomposition of time series sample data. ts() command is used to create time series object

# 1000 random element between 100 and 500 
> value=sample(100:500,1000, replace = T) 
 
# ts class usage, 24 observations per day  
> value_ts=ts(value,frequency = 24)  
 
# decompose value_ts
> decomp_value=decompose(value_ts)    
> plot(decomp_value)
 

The chart shows observed (original data), trend, seasonal, random (residuals) parts of time series data. The forecast::stl() function is also can be used to decompose. Please refer below my post for practical example.

Forecasting time series data in R

Forecasting time series data in Python

Time series data prediction with LSTM model in python

No comments:

Post a Comment