Mathematical Modeling--(8) Time Series Model

Table of contents

sequentially

1. Time series data

2. Time series elements

3. Time series decomposition

4. Spss practical operation

5. Steps of Time Series Analysis

6. Establish time series analysis model

exponential smoothing model

Simple model

Linear trend model (linear trend)​

Damped trend model (Damped)​

Simple seasonal model (Simple seasonal)​

Winters' additive​

Winters' multiplicative model​

7. Models for univariate time series analysis

Stationarity of time series

difference equation

Lag operator

AR§ model

MA(q) model

ARMA(p,q) model

ACF autocorrelation coefficient

Model selection: AIC and BIC criteria (principle of small selection)​

Check if the model is fully recognized

8. The idea of ​​Spss time series modeling

Example 1: Sales data forecast

Example 2: Prediction of Population Data

Example 3: Shanghai Composite Index Forecast


sequentially

        Time series , also known as dynamic series, refers to a numerical sequence in which the index values ​​of a certain phenomenon are arranged in chronological order . Time series analysis can be roughly divided into three parts, which are describing the past , analyzing laws and predicting the future .

        This lecture will mainly introduce three models commonly used in time series analysis:

  1. season breakdown,
  2. exponential smoothing method
  3. ARIMA model,

The time series data will be modeled with Spss software.

1. Time series data

Time series data: Data obtained from continuous observations of the same object at different times

For example:
(1) From birth to now, your weight data (weigh once a year on your birthday).
(2) China's GDP data over the years.
(3) Temperature data measured every hour in a certain place.


2. Time series elements

A time series consists of two components:

  1. The first element is the time element; year, quarter, month, week, day, hour, minute, second
  2. The second element is a numerical element.
  • Time series can be divided into period time series and time point time series according to different time and numerical properties .
  • In the period sequence, the numerical elements reflect the result of the development of the phenomenon in a certain period of time;
  • In the time point sequence, the numerical elements reflect the instantaneous level of the phenomenon at a certain time point
     

Distinguish between period and point-in-time time series:

For example:
(1) From birth to now, your weight data (weigh once a year on your birthday).
(2) China's GDP data over the years.
(3) Temperature data measured every hour in a certain place.
(1) and (3) are point-in-time time series; (2) are period time series

The time series can be added, but the time point series cannot be added.

  • The observations in the time series reflect the total amount of the phenomenon's development process in a period of time, and the observations in different periods can be added together, and the result of the addition shows the total amount of activity of the phenomenon in a longer period of time;
  • The observations in the time point sequence reflect the level reached by the phenomenon at a certain moment, and the observations in different periods cannot be added, and the result of the addition has no practical significance. (There is an accumulation process in the gray forecasting model)

3. Time series decomposition

Because time series is the numerical representation of long-term changes in the value of a certain index, there must be regularities in numerical transformation behind the changes in time series values, and these regularities are the entry point for time series analysis .
In general, there are four types of numerical change laws of time series:

A time series is often the superposition of the above four types of changes.

Long-term trend: T

The long-term trend (Secular trend, T) refers to the statistical indicators that are affected by the long-term trend factors for a long period of time, showing a continuous upward or downward trend , usually represented by the letter T.

For example, with the development of the national economy, the per capita income will gradually increase; with the improvement of the medical level, the neonatal mortality rate will continue to decline


Seasonal trend: S

Seasonal Variation (S) refers to the periodic change of the index value due to the change of season . The season here is in a broad sense, generally taking months, seasons, and weeks as time units, not years. For example, the sales of ice cream and cotton-padded clothes will change periodically with the change of seasonal temperature; the annual long holidays (May 1st, 11th, and Spring Festival) will cause a large increase in the number of people traveling


Cycle changes: C 

Cyclical Variation (C) is different from the cycle of seasonal variation. Cyclical variation usually takes several years as a cycle, and it is shown as a wave-like periodic change on the graph. This periodic change is characterized by alternating increases and decreases , but does not have strict regular periodic continuous changes.

The most typical cycle cases are the business cycle of the market economy and the economic cycle of the entire country


Irregular changes: I

Irregular Variation (Irregular Variation, I) is a numerical change caused by some random factors . The effects of these factors are unpredictable and irregular, and can be regarded as the influence of many accidental factors on the time series (in regression Also known as disturbance term)


        The above four changes are the decomposition results of the time series numerical changes. Sometimes these changes will appear in a time series at the same time, and sometimes only one or several types may appear, which is determined by the influencing factors that cause various changes. It is precisely because of the uncertainty of the combination of changes that the numerical changes of the time series are so ever-changing.
        The relationship between the four changes and the final change of the index value may be a superposition relationship or a product relationship.

  1.  If the four changes are independent of each other, then the superposition model can be expressed as:

  2. If there are interactions among the four movements, then the product model should be used:

 (1) Time series decomposition can only be used when the data has periodicity within a year. For example, the data is monthly data (period is 12), quarterly data (period is 4), and yearly data is not acceptable .
(2) On the specific time series diagram, if the seasonal fluctuation of the series becomes larger and larger as time goes by , it reflects that the relationship between various changes has changed, and it is recommended to use the product model; conversely, if the time If the volatility of the sequence diagram is kept constant , the superposition model can be used directly; of course, if there are no seasonal fluctuations, both decompositions are fine.

As time changes, the seasonal fluctuations of the search data are more and more large, so it is more accurate to use the product model.

 The seasonal fluctuations in the sales data are increasing over time, so the product model is more accurate.


4. Spss practical operation

Handle missing values ​​in a time series: 

If the missing value occurs at the beginning or end of the time series, the method of direct deletion can be used;
if the missing value occurs in the middle of the sequence, it cannot be deleted (the original time series will be misplaced after deletion), and the method of replacing the missing value can be used.

Five ways to replace missing values 

 


Spss defines time variables:

 SPSS Time Series Plot

SPSS Seasonal Decomposition 

result: 

Draw the decomposed timing diagram 


5. Steps of Time Series Analysis

 Specific steps:

  1. make a time series plot
  2. Determine the variable components contained in the time series
  3. Time series decomposition (periodic and contains long-term trends, seasonal changes or cyclical changes)
  4. Build time series analysis models
  5. Forecasting future indicator values

6. Establish time series analysis model

Exponential smoothing model:

 Simple model:

Simple exponential smoothing forecast: 

Linear trend model (linear trend)

Damped Trend Model (Damped)

 Simple seasonal model (Simple seasonal)

 Winters' additive model (Winters' additive)

 Winters' multiplicative model

7. Models for univariate time series analysis

The following concepts only introduce a general idea, and you need to work hard after class to fully understand them. If it is really difficult to learn this small part, you can choose to give up the theoretical part, instead of studying every detail and concept, our focus can be on the application .

Stationarity of time series

 


difference equation

 Lag operator


AR§ model

 Conditions for the AR§ model to be stationary:

 


MA(q) model

 The relationship between MA model and AR model


ARMA(p,q) model

The autoregressive moving average model (Autoregressive Moving Average, ARMA) is a model that tries to combine the autoregressive process AR and the moving average process MA to jointly simulate the random process that generates the existing time series sample data.


 ACF autocorrelation coefficient

 Model selection: AIC and BIC criteria (selection of small principles)

Check if the model is fully recognized

After estimating the time series model, we need to perform a white noise test on the residuals ,

  • If the residual is white noise, it means that the model we selected can fully identify the regularity of the time series data, that is, the model is acceptable;
  • If the residual is not white noise, it means that there is still some information that has not been recognized by the model, and we need to modify the model to recognize this part of the information.

8. The idea of ​​Spss time series modeling

The following steps are the process of thinking about modeling, not written in the paper:

  1. (1) Deal with the missing value problem of data, generate time variables and draw time series diagrams;
  2. (2) Whether the data is quarterly data or monthly data (at least two complete cycles, that is, two years), and if so, observe whether there are seasonal fluctuations in the graph.
  3. (3) According to the time series diagram, roughly judge whether the data is a stationary sequence (the data fluctuates around the mean, without trend and seasonality)
  4. (4) Open Spss, analyze-time series forecasting-create a traditional model (this function may only be available in higher versions of Spss), and see the optimal model type obtained by the Spss expert modeler.
  5. (5) If the final result is an ARIMA(p,0,q) model, then we can draw the sample ACF and PACF graphs of the time series for analysis; if the ARIMA(p,1,q) model is obtained, we You can perform a first-order difference on the data before using ACF and PACF graphical analysis; if the results obtained are related to seasonality, then we can consider using time series decomposition

Example 1: Sales data forecast


Preparation:

 Spss time series modeler:

 Steps:

 Commonly used evaluation indicators:

Table of parameter estimates:

 White noise for residual testing

 Predicted results and renderings:


Example 2: Prediction of Population Data


forecast result: 

White noise test of residuals

Prediction result graph: 


Example 3: Shanghai Composite Index Forecast

 

Remodeling after removing outliers

Prediction result display chart:

 

Guess you like

Origin blog.csdn.net/qq_58602552/article/details/130413058