Autocorrelation analysis, examine serial dependence
Spectral Analysis
Decomposition of time series
Curve Fitting
Interpolation (smoothing, regression analysis)
Extrapolation
Function Approximation
Known Target Function 知道function长什么样 做近似
Curve Fitting
Prediction, Forecasting and Classification
Spark-TS as a third party package for large scale data
Signal Detection
Fourier Transformation 对声音降噪
Segmentation Analysis
区分对话中不同人的对话声
Definition
Time Series
A time series model for observed data {xt} is a specification of the joint distribution of a sequence of random variables {Xt} of which {xt} is postulated to be a realization.
如果是联合概率,完全没有任何限制,有各种情况组合,而我们观测时只看到这些X的一次实现,那这个问题非常复杂。要试着把问题简化,比如,平稳过程,我们认为X1...X5的分布一样,于是就可以用X2的实现推断X1的distribution。不研究X1...X5的联合分布,而是找到一阶expectation value,二阶expectation... 也就是不需要知道distribution,而是通过找到mean和variation分析问题。有时,知道first and second moments就够用。
Mean Function
Let {Xt} be a time series with E(Xt2)< inf . The mean function of {Xt} is μX(t)=E(Xt) .
Covariance Function
The covariance function of {Xt} is (for all integers r and s)
γX(r,s)=Cov(Xr,Xs)=E[(Xr−μX(t))(Xs−μX(s))]
Stationary Process (weakly stationary)*****
{Xt}is weakly stationary if
(1) μX(t) is independent of t (2) γX(t+h,t) is independent of t for each h
Remark 1: strictly stationary is if the joint distribution is independent of t
Remark 2: γX(h)=γX(t+h,t)
mean function is independent of t, and covariance function is independent of t for each h (和起点终点无关,和距离有关)所以x1和x3的covariance和x2与x4的covariance相同,以及variance function和时间也无关。只在乎first and second moment.
Why do we care about 'stationary'?: make a prediction, assume something does not change with time
Examples
√ i.i.d. noise: with 0 mean and finite variance
√ white noise: uncorrelated random variables, each with zero mean and finite variance
因为uncorrelated意味着只要i≠j,它们的correlation就=0,所以满足了weakly stationary的定义。
要注意 uncorrelated不意味着independent,就像 x,x2 的例子,或者normal & chi square。因为uncorrelated只是线性无关。所以从iid noise可以推出white noise,但是反过来不行。
General Approach to Time Series Modeling(procedure)
Plot the series and examine the main features of the graph. Check if there is: 也就是Exploratory
- Trend
- Seasonal Component
- Sharp Change in Behavior
- Outlying Observation
Remove the trend and seasonal components to get stationary residuals. 获得后先放下,看residual是否还有信息
- Stationary residual: in between iid and seasonal
Choose a model to fit the residuals to make use of various sample statistics including the sample autocorrelation function.
Forecasting is achieved by forecasting the residuals and then inverting the transformation.
De-trend
1.Spline Regression (Parametric)
Run a linear regression with time index
Run a polynomial regression with time index
弱点1: non-local, 所以如果在某一个点附近y值有了变化,整个poly就变了
弱点2: 多项式的fit 可能更高项的fit更好,但是却是overfitting
所以针对这样的弱点,弥补方式就是分段 构造k个阶梯函数,找这些阶梯函数的线性组合。
Fit a spline regression 用光滑的曲线,比较没有棱角。(最后还可以用penalized spline regression)
Independent but conditionally dependent Let’s say you flip two fair coins A-Your first coin flip is heads B- Your second coin flip is heads C- Your first two flips were the same A and B here are independent. However, A and B are conditionally dependent given C, since if you know C then your first coin flip will inform the other one.
ARMA(p,q) Process
φ(B)Xt=θ(B)Zt
比如一个ARMA(1,1) Xt=φ1Xt−1+Zt+θ1Zt−1
这里不能从图直接知道几阶了
ARIMA(p,d,q) process
φ(B)(1−B)dXt=θ(B)Zt
Rule 1: if a series has positive autocorrelations out to a high number of lags, then it probably needs a higher order of differencing (如果一大堆positive 再differencing)
Rule 2:if the lag-1 autocorrelation is zero or negative, or the autocorrelations are all small and patternless, then the series does not need a higher order of differencing. If the lag-1 autocorrelation is -0.5 or more negative, the series may be over-differenced.
以上都是rule of thumb,但是实际操作时 看情况。
Model Estimation
简直太多了...
Preliminary Estimation
Yule-Walker Estimation
Burg's Algorithm
The Innovation Algorithm
The Hannan-Rissanen Algorithm
Maximum Likelihood Estimation
Q: 能用OLS计算AR(1)的系数吗?
Least Square/Regression在这里不满足,因为不满足assumption:如果要regression,需要观测之间互相independent
Model Diagnostics
Check the significance of the coefficients
Check the ACF of residuals. (should be non-significant)
*Check the Box-Pierce (Ljung) tests for possible residual autocorrelation at various lags
Check if the variance is non-constant (use ARCH or GARCH model)
时间序列聚类的,《Robust and Rapid Clustering of KPIs for Large-Scale Anomaly Detection》;另外一篇文章是关于时间序列异常检测的,重点检测时间序列上下平移的,《Robust and Rapid Adaption for Concept Drift in Software System Anomaly Detection》。