Current location - Trademark Inquiry Complete Network - Futures platform - 10 to realize the time series analysis and modeling of financial data.
10 to realize the time series analysis and modeling of financial data.
The autoregressive moving average model (ARIMA) contains an explicit statistical model to deal with the irregular part of the time series, which makes the irregular part autocorrelation.

data preparation

It can be seen that the autocorrelation value with the lag order of 1 exceeds the confidence boundary, but all other autocorrelation values with the lag order of 1-20 do not exceed the confidence boundary.

The results show that the partial autocorrelation coefficient exceeds the confidence boundary when the lag order is 1, 2,3, and decreases gradually with the increase of the lag order.

model prediction

Automatic prediction of ARIMA model

It does not require the correlation between continuous values in time series, and exponential smoothing method can be used for short-term prediction of time series data.

Simple exponential smoothing method

It is suitable for forecasting time series with no seasonal change, at a constant level and no obvious trend.

Obtain data (the data source is the annual rainfall in London) and convert it into time series by ts function.

Forecast the precipitation in the next five years

The blue line is used to forecast the rainfall between 19 13- 1920, with a dark gray shadow area of 80% and a light gray shadow area of 95%. Prediction provides a statistical index of prediction error (residual) to evaluate whether the prediction is likely to be improved: if the prediction error is related, it is likely that a simple exponential smooth prediction can be optimized by another prediction technique.

It can be found that the autocorrelation coefficient reaches the confidence limit in the third period. In order to verify whether the non-zero autocorrelation property is significant when the lag is 1-20 order, Ljung-Box test of Box.test () can be used.

The statistic is 17.4, and the p value is 0.626, which is not enough to reject that the prediction error is non-zero autocorrelation in the order of 1-20.

Holt exponential smoothing method

Holt exponential smoothing method can be used to predict time series with unstable level and no seasonal additive model. Holt exponential smoothing method is to estimate the level and slope of the current time. Its smoothing level is controlled by two parameters, α: estimating the current point level and β: estimating the partial slope of the current point trend. Both parameters are between 0- 1. The closer the parameter is to 0, the smaller the weight of the latest observation. The data sources are 1866 to 19 1 1. The ts function is used to convert the data into time series, and the timing chart is drawn.

Among the related predicted values, α is 0.8383, and β is 1.0. These are very high values, which fully shows that the current values are heavily dependent on the latest observed values in time series, both horizontally and in the slope of the trend. This result is also in line with our expectation, because the level and slope of the time series change greatly during the whole time period. Overall, the prediction effect is not bad (red is the predicted value).

Predict the data value in the next five years and get the prediction result.

In order to test the prediction effect, we also test whether the prediction error of delay 1-20 order is non-zero autocorrelation, and continue to use Ljung-Box test.

The correlation diagram shows that the prediction error in the sample exceeds the confidence boundary when it lags behind by 5 orders, and nothing else exceeds it. We think there are some accidental factors.

P =0.4749, that is to say, the confidence is only 53%, which is not enough to reject that the prediction error is non-zero autocorrelation at 1-20, so we accept that the prediction error is non-zero autocorrelation at 1-20.

Holt-Winters exponential smoothing method

Time series forecasting method with increasing and decreasing trend and seasonal fluctuation. In Holt-Winters algorithm, alpha, beta and gamma are provided to correspond to the level, trend and season of the current point respectively. The de-emphasis range of parameters is between 0- 1, and when the parameters are close to 0, the influence weight of recent observations is small. The data source is based on the monthly sales date of seaside commemorative goods in Queensland, Australia, and the data is converted into time series by ts function, and the timing chart is drawn.

Logarithm can be used to reduce the influence of extreme value and eliminate uneven variance.

Forecast the sales data of the next 12 months through the forecast package, and get the forecast result.

The model successfully predicted the seasonal peak, which appeared in about 65438+February every year. We can also test whether the intra-sample prediction error is non-zero autocorrelation when the delay is 1-20 order by drawing correlation diagram and Ljung-Box test, and then determine whether the prediction model can be optimized again.

The correlation diagram shows that the autocorrelation value of the samples does not exceed the significant (confidence) boundary in the lag order of 1-20.

The p value of Ljung-Box test is 0.6 183, so we infer that there is no obvious evidence that the prediction error is non-zero autocorrelation in the lag order of 1-20.