Link to original article:tecdat.cn/?p=22458 

Original source:Tuoduan numbers according to the public account of the tribe

 

Introduction to the

This paper provides an economic case. Focus on the oil market as an example. Briefly provides arguments for the use of model averaging and Bayesian approaches in economics, using dynamic model averaging (DMA) and comparing them to ARIMA, TVP, etc. It is hoped to be useful to practitioners and researchers in the field of economics and finance.

motivation

In fact, DMA combines several features of econometric modeling. First, the final forecast is generated from several regression models by model averaging. Second, the method is Bayesian, that is, the probability is explained in terms of the degree of belief. For example, DMA predictions for time T are based only on data that ends at time T-1. In addition, the acquisition of new data directly results in the updating of parameters. In DMA, therefore, both the regression coefficient and the weights assigned to the model vary over time.

Bayesian methods are not the mainstream of modern econometrics. However, these methods have recently been receiving increasing attention. There are various reasons for this. First, we can relate it to the increasing amount of data in research. Due to technological advances, people are often faced with situations with many potential explanatory variables. Although most variables may not be important, researchers often don’t know which ones to exclude.

Of course, you can still use the conventional approach to some extent. However, due to lack of sufficient information, it is usually impossible to estimate the parameters accurately. The simplest example is when the number of explanatory variables is greater than the number of observations in the time series. For example, even in the case of linear regression, the standard ordinary least squares estimate will present a singular matrix, making it impossible to take its reciprocal. In the Bayesian framework, a meaningful formula can still be derived. The Bayesian approach also seems to be better able to deal with over-parameterization and over-fitting.

Various approaches can be found in recent forecasting trends. Taking crude oil price as an example, forecasting methods can usually be divided into time series model, structural model and some other methods, such as machine learning, neural network and so on. In general, time series models focus on modeling volatility rather than spot prices. Structural models, as their name suggests, include causality, but they typically have good predictive power in some periods and poor predictive power in others. In addition, other methods based on wavelet decomposition and neural network usually ignore the influence of other factors and only focus on a single time series. This makes DMA an interesting approach for practitioners.

The next aspect of DMA is that it allows the regression coefficients to vary over time. In fact, this property of econometric models is highly desirable in cases of slow and rapid (structurally interrupted) changes in the economy. Of course, such methods also exist in traditional methodologies, such as recursive or scrolling-window regression.

Theoretical framework

We will briefly describe the theoretical framework for fDMA. In particular, dynamic model averaging (DMA), dynamic model selection (DMS), and median probability model.

Dynamic model averaging (DMA)

DMA is described in great detail in the original paper [1]. However, the following is a brief discussion necessary to understand the role of each function in fDMA.

Assuming YT is the predicted time series (dependent variable), let x (k) t be the column vector of the independent variable in the KTH regression model. For example, there are 10 potential drivers of crude oil prices. If each of them is represented by an appropriate time series, then 2^10 possible linear regression models can be constructed. Each variable may or may not be included in a model. So, there are two choices for each variable, which makes up 2^10 possibilities. This includes a model with only constants. Therefore, in general, there are potentially useful M independent variables, and at most K=2^m models can be constructed. In other words, the state space model is made up of the following parts

Where k = 1… K, θt is the column vector of the regression coefficient. It is assumed that the errors follow normal distributions, i.e., e (k) t ~ N (0, V (k) t) and δ (k) t ~ N (0, W (k) t).

Please note here that there are M potential explanatory variables, and 2m is the upper limit for building the model. However, all of the methods described in this paper (if not specified) apply to any subset of these 2m models, i.e. K≤2m.

Dynamic Model Selection (DMS)

Dynamic Model Selection (DMS) is based on the same idea as DMA. The only difference is that in DMA it is model averaging, whereas in DMS it is model selection. In other words, for each period T, choose the model with the highest posteriori probability. What that means is that you just change the formula to

HT represents the K model.

One example: the oil market

Take the oil market for example. Accordingly, it can be said that there is uncertainty as to which time series can be useful explanatory variables for predicting spot crude oil prices.

The XTS object crudeoil contains selected data from the crudeoil market, i.e.

-WTI stands for the spot price of WTI (West Texas Intermediate) in terms of barrel.

– MSCI stands for THE MSCI World Index.

– TB3MS represents the secondary market rate (%) on 3-month Treasury bills.

– CSP stands for crude steel output in kilotons (which can be used as a measure of global economic activity).

– TWEXM represents the trade-weighted index (March 1973 =100).

– PROD stands for supply of crude oil products in thousands of barrels.

– CONS represents the total consumption of crude oil products in oecd.

– VXO stands for implied volatility (i.e., stock market volatility) of the S&P 100 Index.

The frequency of these data is monthly. They cover the period from January 1990 to December 2016.

Trends in XTS objects include data from Google about the number of Internet sites for selected search terms.

– stock_markets stands for “stock markets” for Google Trends.

Interest_rate represents Google Trends’ interest rate ‘.

– economic_activity Indicates the Google trend for “economic activity”.

– Exchange_rate represents the Google trend for “exchange rate”.

– oil_production: Google trend for “oil production”.

-oil_consumption represents the Google trend for “oil consumption”.

– Market_stress stands for “Market stress” for Google Trends.

These data are also on a monthly basis. They cover the period from January 2004 to December 2016, because Google Trends does not cover an earlier period. From an economic point of view, it makes sense to consider logarithmic differences in these time series

R> drivers <- (lag(crudeoil[ , -1], k = 1))[-1, ]
R> l.wti <- (diff(log(wti)))[-1, ]
R> l.drivers <- (diff(log(driv )))[-1, ]
Copy the code

R> archtest(ld.wti)
Copy the code

R> descstat((ld))
Copy the code

Except for some problems with PROD, all time series can be considered stationary at the significance level of 5%. ARCH effect also exists for WTI difference. Therefore, it seems reasonable to consider the exponential weighted moving average (EWMA) estimate variance in DMA. In addition, you can test for forgetting factors. According to the suggestion, κ=0.97 was adopted for the monthly time series. All of the variances are less than 1. Therefore, there seems to be no need to re-standardize the time series. In DMA estimates, taking initvar=1 also seems sufficient.


 DMA(y = lwti, x = ldrivers,
+  alpha = ra, lambda = rl,
    meth = "ewma" )
Copy the code

According to the minimum RMSE, the best DMA models are α=0.99 and λ=0.97. So, take a look at this model a little bit.

Plot ($x, y type = "l", ylim = c (min ($x y, x $y.h at), Max ($x y, x $y.h at)), xlab = "", ylab =" ", the main = "actual value and predictive value", axes = F)Copy the code

A comparison of Figures 1 and 2 shows that during periods of market volatility, the DMA quickly adapted, giving greater weight to models with more variables. In fact, this is consistent with Figure 3. During this period, the relative variable importance of all explanatory variables increased. We can also see that the role of developed stock markets has increased since 2007. After 2013, however, this effect became less and less; And other variables are starting to add up. This is very obvious, especially with regard to exchange rates.

Figure 3 should be seen with Figure 4. Although the importance of the relative variable may be high, the expected value of the regression coefficient for this variable may be around 0. In fact, high relative variable importance simultaneously observed non-zero expected regression coefficients for MSCI, CSP and TWEXM. So, this analysis now confirms that these three factors played an important role in predicting oil prices between 2007 and 2013. Since 2013, the role of the stock market has diminished, replaced by the exchange rate. Around 2013, the most important role was played by developed stock markets.

Figure 1

for (i in 1:7) { inc[i+1] <- floor(i * nrow( post.incl)/7) } plot( exp.var, Type ="l" ylim=c(0,ncol(x$models)) main=" variables expected value ", AXES = F)Copy the code

Figure 2

For (I in 1: (ncol (post. Incl) - 1)) plot (post) incl [, I + 1), type = "l", col = col, [I + 1] ylim = c (0, 1), xlab = "", ylab =" ", Main =" axes = F ";Copy the code

Figure 3

for (i in 1:(ncol( exp.coef.))) { plot( exp.coef.[,i], type="l", col=col[i] ) } plot(index( exp.coef.[,i]), Rep (0, length (x $exp. Coef. [, I]) xaxt = 'n', xlab = "", ylab =" ", the main = "factor"Copy the code

Figure 4.

Finally, it is possible to suspect that some models are in some sense superior to others. In other words, the choice of the model will have an advantage over the average of the models. This can be checked by analyzing the DMS and the median probability model. However, as can be seen from Figure 5, none of the models has a posteriori probability greater than 0.5. Second, after 2007 and after 2013, none of the models seemed to have an advantage.

It is also possible to question whether the applied method is robust for different parameter Settings. For example, if the other forgetting factors α and λ lead to a different conclusion. Figure 6 shows the relative variable importance of all explanatory variables from all models of object G, i.e., α={1, 0.99, 0.98, 0.97, 0.96, 0.95} and λ={1, 0.99, 0.98, 0.97, 0.96, 0.95} for all combinations. The exact numbers vary, but the graph follows more or less the same path in time. This means that it is robust to set different values for forgotten factors given increasing effects of explanatory variables.

for (i in 1:(ncol(x$post.mod)-1)) { plot(x$post.mod[,i], type="l" } plot(x$post.mod[,i+1], type="l" ylab="", Main =" Posterior model probability ", AXES = F)Copy the code

Figure 5

 

Figure 6.

Finally, the selected model can be compared with some alternative predictions.


R> altm
Copy the code

The RMSE of the selected DMA model is smaller than the two benchmark predictions, but comparable to Auto ARIMA. MAE is a similar story. However, Auto ARIMA has a smaller MAE than the selected DMA model. On the other hand, the selected DMA model has the highest hit rate of all competing predictions. A more accurate comparison can be made with the DieBold-Mariano test.

DieMtest(y = (lwti))
Copy the code

Assuming a significance level of 5%, you can reject the null hypothesis of the simple prediction, that is, the prediction is less accurate than the selected DMA model. In other words, the chosen model in some sense exceeds the simple prediction.

reference

1. Raftery, A.; Karny, m.; Ettler, P. Online Prediction under Model Uncertainty via Dynamic Model Averaging: Application of Cold Rolling Mill. Technometrics 2010, 52, 52 — 66. [CrossRef] [PubMed]

2. Barbieri, M.; Berger, J. Optimal Predictive Model Selection. Ann. Stat. 2004, 32, 870 — 897.


Most popular insight

1. Use LSTM and PyTorch for time series prediction in Python

2. Use LSTM to predict and analyze time series in Python

3. Use R language to analyze time series (ARIMA, exponential smoothing)

4. Multiple Copula-GARCH-model time series prediction in R language

5. R language Copulas and financial time series cases

6. Use R language random wave model SV to deal with random wave in time series

7. Tar threshold autoregression model of r language time series

8. R language K-shape time series clustering method to stock price time series clustering

9. Python3 uses arIMA model for time series prediction