scieee AI-readable full text Open interactive document viewer

Parallel Sequential Monte Carlo for Efficient Density Combination: The DeCo MATLAB Toolbox

Casarin, Roberto,Grassi, Stefano,Ravazzolo, Francesco,van Dijk, Herman K.

Abstract

EconStor is a publication server for scholarly economic literature, provided as a non-commercial public service by the ZBW.

Full text

Casarin, Roberto; Grassi, Stefano; Ravazzolo, Francesco; van Dijk, Herman K. Working Paper Parallel Sequential Monte Carlo for Efficient Density Combination: The DeCo MATLAB Toolbox Working Paper, No. 11/2014 Provided in Cooperation with: Norges Bank, Oslo Suggested Citation: Casarin, Roberto; Grassi, Stefano; Ravazzolo, Francesco; van Dijk, Herman K. (2014) : Parallel Sequential Monte Carlo for Efficient Density Combination: The DeCo MATLAB Toolbox, Working Paper, No. 11/2014, ISBN 978-82-7553-818-3, Norges Bank, Oslo, https://hdl.handle.net/11250/2495973 This Version is available at: https://hdl.handle.net/10419/210060 Standard-Nutzungsbedingungen: Die Dokumente auf EconStor dürfen zu eigenen wissenschaftlichen Zwecken und zum Privatgebrauch gespeichert und kopiert werden. Sie dürfen die Dokumente nicht für öffentliche oder kommerzielle Zwecke vervielfältigen, öffentlich ausstellen, öffentlich zugänglich machen, vertreiben oder anderweitig nutzen. Sofern die Verfasser die Dokumente unter Open-Content-Lizenzen (insbesondere CC-Lizenzen) zur Verfügung gestellt haben sollten, gelten abweichend von diesen Nutzungsbedingungen die in der dort genannten Lizenz gewährten Nutzungsrechte. Terms of use: Documents in EconStor may be saved and copied for your personal and scholarly purposes. You are not to copy documents for public or commercial purposes, to exhibit the documents publicly, to make them publicly available on the internet, or to distribute or otherwise use the documents in public. If the documents have been made available under an Open Content Licence (especially Creative Commons Licences), you may exercise further usage rights as specified in the indicated licence. https://creativecommons.org/licenses/by-nc-nd/4.0/deed.no Parallel sequential Monte Carlo for efficient density combination: The DeCo MATLAB toolbox Norges BaNk research 11 | 2014 AuThors: roBerTo CAsArin sTefAno GrAssi frAnCesCo rAvAzzoLo herMAn K. vAn DijK WorkiNg PaPer Norges BaNk Working PaPer xx | 2014 rapportNavN 2 Working papers fra Norges Bank, fra 1992/1 til 2009/2 kan bestilles over e-post: [email protected] fra 1999 og senere er publikasjonene tilgjengelige på www.norges-bank.no Working papers inneholder forskningsarbeider og utredninger som vanligvis ikke har fått sin endelige form. hensikten er blant annet at forfatteren kan motta kommentarer fra kolleger og andre interesserte. synspunkter og konklusjoner i arbeidene står for forfatternes regning. Working papers from Norges Bank, from 1992/1 to 2009/2 can be ordered by e-mail: [email protected] Working papers from 1999 onwards are available on www.norges-bank.no norges Bank’s working papers present research projects and reports (not usually in their final form) and are intended inter alia to enable the author to benefit from the comments of colleagues and other interested parties. views and conclusions expressed in working papers are the responsibility of the authors alone. ISSN 1502-8143 (online) ISBN 978-82-7553-818-3 (online) JSS cParallel Sequential Monte Carlo for Efficient Density Combination: The DeCo MATLAB Toolbox∗ Roberto Casarin University Ca’ Foscari of Venice and GRETA Stefano Grassi School of Economics University of Kent and CREATES Francesco Ravazzolo Norges Bank and BI Norwegian Business School Herman K. van Dijk Erasmus University Rotterdam VU University Amsterdam and Tinbergen Institute Abstract This paper presents the MATLAB package DeCo (density combination) which is based on the paper by Billio, Casarin, Ravazzolo, and van Dijk (2013) where a constructive Bayesian approach is presented for combining predictive densities originating from different models or other sources of information. The combination weights are time-varying and may depend on past predictive forecasting performances and other learning mechanisms. The core algorithm is the function DeCo which applies banks of parallel Sequential Monte Carlo algorithms to filter the time-varying combination weights. The DeCo procedure has been implemented both for standard CPU computing and for graphical process unit (GPU) parallel computing. For the GPU implementation we use the MATLAB parallel computing toolbox and show how to use general purpose GPU computing almost effortlessly. This GPU implementation provides a speed up of the execution time of up to seventy times on a standard CPU MATLAB implementation on a multicore CPU. We show the use of the package and the computational gain of the GPU version through some simulation experiments and empirical applications. Keywords: Density forecast combination, sequential Monte Carlo, parallel computing, GPU, MATLAB. 1. Introduction Combining forecasts from different statistical models or other sources of information is a crucial issue in many different fields of science. Several papers have been proposed to handle this issues with Bates and Granger (1969) as one of the first attempts in this field. Initially the focus was on defining ∗This working paper should not be reported as representing the views of Norges Bank. The views expressed are those of the authors and do not necessarily reflect those of Norges Bank. For their useful comments, we thank Daniel Armyr and Sylvia Frühwirth-Schnatter and seminar and conference participants at the European Seminar on Bayesian Econometrics 2013, Norges Bank, the 7th Rimini Bayesian Econometrics Workshop and the 2013 Vienna IHS Time-Series Workshop. Roberto Casarin’s research is supported by the Italian Ministry of Education, University and Research (MIUR) PRIN 2010- 11 grant, and by funding from the European Union, Seventh Framework Programme FP7/2007-2013 under grant agreement SYRTO-SSH-2012-320270. 2DeCo:AMATLAB Toolbox for Density Combination and estimating combination weights for point forecasting. For instance, Granger and Ramanathan (1984) propose to combine forecasts with unrestricted least squares regression coefficients as weights. Terui and van Dijk (2002) generalize least squares weights by specifying the weights in the dynamic forecast combination as a state space model with time-varying weights that are assumed to follow a random walk process. Recently, research interest has shifted to the construction of combinations of predictive densities (and not point forecasts) as well as allowing for model set incompleteness (the true model may not be included in the set of models for prediction) and learning. Further, different model evaluation criteria are used. Hall and Mitchell (2007) and Geweke and Amisano (2010) propose using combination schemes based on the Kullback-Leibler score; Gneiting and Raftery (2007) recommend strictly proper scoring rules, such as the Cumulative Rank Probability Score, in particular, if the focus is on some particular area, such as extreme tails, of the distribution. Billio et al. (2013) (hereby BCRVD (2013)) provide a general Bayesian distributional state space representation of predictive densities and specify combination schemes that allow for an incomplete set of models and different learning mechanisms and scoring rules. The design of algorithms for a numerically efficient combination remains a challenging issue (e.g., see Gneiting and Raftery 2007). BCRVD (2013) propose a combination algorithm based on Sequential Monte Carlo filtering. The proposed algorithm makes use of a random grid from the set of predictive densities and runs a particle filter at each point of the grid. The procedure is computationally intensive when the number of models to combine increases. A contribution of this paper is to present a MATLAB (see The MathWorks, Inc. (2011)) package DeCo (Density Combination) for the combination of predictive densities and a simple Graphical User Interface (GUI) for the use of this package. This paper provides, through the DeCo package, an efficient implementation of BCRVD (2013) algorithm based on CPU and GPU parallel computing. We make use of recent increases in computing power and recent advances in parallel programming techniques. The focus of the microprocessor industry, mainly driven by Intel and AMD, has shifted from maximizing the performance of a single core to integrating multiple cores in one chip, see Sutter (2005) and Sutter (2011). Contemporaneously, the needs of the video game industry, requiring increasing computational performance, boosted the development of the Graphics Processing Unit (GPU), which enabled massively parallel computation. In the present paper, we follow the recent trend of using GPUs for general, non-graphics, applications (prominently featuring those in scientific computing), the so-called general-purpose computing on graphics processing unit (GPGPU). The GPGPU has been applied successfully in different fields such as astrophysics, biology, engineering, and finance, where quantitative analysts started using this technology well ahead of academic economists, see Morozov and Mathur (2011) for a literature review. To date, the adoption of GPU computing technology in economics and econometrics has been relatively slow compared with other fields. There are a few papers that deal with this interesting topic, see Suchard, Holmes, and West (2010), Morozov and Mathur (2011), Aldrich, Fernández-Villaverde, Gallant, and Rubio Ramırez (2011), Geweke and Durham (2012), Dziubinski and Grassi (2013)and Creel, Mandal, and Zubair (2012). This is odd given the fact that parallel computing in economics has a long history. An early attempt to use parallel computation for Monte Carlo simulation is Chong and Hendry (1986), while Swann (2002) develops parallel implementation of maximum likelihood estimation. Creel and Goffe (2008) discuss a number of economic and econometric problems where parallel computing can be applied. The low diffusion of this technology in economics and econometrics, according to Creel (2005), is mainly due to two issues, which are the high cost of the hardware, e.g. cluster, and the steep learning curve of dedicated programming languages as CUDA (Compute Unified Device Architecture, see Nvidia Corporation (2010)), OpenCL (Khronos OpenCL Working Group (2009)), Thrust (Hoberock and Bell (2011)) and C++ AMP (C++ Accelerated Massive Par- 3 Advantages Disadvantages CUDA Free Vendor Lock-in OpenCL Free Difficult to program Heterogeneous Thrust Free Vendor Lock-in Easy to program C++ AMP Open Standard Currently only Windows implementations exist Heterogeneous Free (Express Edition) Easy to program Table 1: Comparison of different currently available GPGPU approaches. allelism, see Gregory and Miller (2012)). Table 1compares different currently available GPGPU approaches. The recent increase in attention to parallel computing is motivated by the fact that the hardware costs issue has been solved by the introduction of modern GPUs with relatively low cost. Nevertheless, the second issue remains open. For example, Lee, Christopher, Giles, Doucet, and Holmes (2010) report that a programmer proficient in C (Press, Teukolsky, Vetterling, and Flannery (1992)) or C++ (Stroustrup (2000)), a programming skill that can take some time to be acquired, should be able to code effectively in CUDA within a few weeks. We aim to contribute to this stream of literature by showing that GPU computing can be carried out almost without any extra effort using the parallel toolbox of MATLAB (available in version 2012b and following releases, see The MathWorks, Inc. (2011)) and a suitable approach to MATLAB coding of the algorithms. The MATLAB environment allows easy use of GPU programming without learning CUDA. We emphasize that this paper is not intended to compare CPU and GPU computing. In fact, we propose the combination algorithm for both standard parallel CPU and for parallel GPU computation. Our simulation and empirical experiments show that the DeCo GPU version is faster 3 to 10 times than the parallel multi-core CPU version, similar to recommendations in Brodtkorb, Hagen, and Saetra (2013), and up to 70 times faster than the standard sequential CPU version. The structure of the paper is as follows. Section 2introduces the principles of density forecast combinations with time-varying weights and parallel sequential Monte Carlo algorithms. Section 3presents a parallel sequential Monte Carlo algorithm for density combinations. It also provides background material on GPU computing in MATLAB. Section 4carry out a comparison, using a Monte Carlo, between CPU and GPU calculation. Section 5reports the results for the macroeconomic empirical application. Section 6concludes. Appendix Adescribes the structure of the algorithm and Appendix Bshows the package GUI. 2. Time-varying combinations of predictive densities 2.1. A combination scheme BCRVD (2013) introduces a general density combination scheme, which allows for time-varying weights; model set incompleteness (meaning the true model might not be in the model set); combination weight uncertainty and learning. The authors give a general distributional representation of the combination, provide an effective algorithm for the sequential estimation of the weights and discuss some alternative specifications of the combination and of weight dynamics. In the package, and the 4DeCo:AMATLAB Toolbox for Density Combination paper, we apply for convenience the Gaussian combination scheme with logistic weights applied by BCRVD (2013). Let us denote with v1:t=(v1,...,vt)a collection of vectors vswith s=1,...,t. Let yt∈Y⊂RL be the L-vector of observable variables at time tand ˜ yt=( ˜ y 1,t,...,˜ y K,t)∈Y K, with element ˜ yk,t =(˜y1 k,t,...,˜yL k,t)∈Y⊂RLthe typical one-step-ahead predictor for ytfor the k-th model, k= 1,...,K, in the pool, with predictive density p(˜ yk,t|y1:t−1). The combination scheme is specified as: p(yt|Wt,˜ yt)∝|Σ|−1 2exp −1 2(yt−Wt˜ yt)Σ−1(yt−Wt˜ yt)(1) t=1,...,T, where Wt=(w1 t,...,wL t)is a weight matrix, with wl t=(wl 1,t,...,wl KL,t)as the l-th row vector containing the combination weights for the KL elements of ˜ ytand for the prediction of yl,t. In this paper we assume diagonal covariance matrix, i.e. Σ=diag{σ2 1,...,σ2 L}. The dynamics of the combination weights wl h,t is wl h,t =exp{xl h,t} KL j=1 exp{xl j,t},with h=1,...,KL (2) where p(xt|xt−1)∝|Λ|−1 2exp −1 2(xt−xt−1)Λ−1(xt−xt−1)(3) with xt=vec(Xt)∈X ⊂RKL2where Xt=(x1 t,...,xL t). In this paper we assume the covariance matrix of the state noise is diagonal, i.e. Λ=diag{λ1,...,λ KL2}. A learning mechanism can also be added to the weight dynamics, resulting in: p(xt|xt−1,yt−τ:t−1,˜ yt−τ:t−1)∝|Λ|−1 2exp −1 2(xt−μt)Λ−1(xt−μt)(4) where μt=xt−1−Δet,Δet=(et−et−1)and elements of et el K(l−1)+k,t =(1−λ) τ  i=1 λi−1fyl t−i,˜yl k,t−i, k=1,...,K,l=1,...,L, with λ∈[0,1] a discount factor and τthe number of previous observations used in the learning. We assume the function f() defines a learning strategy. Note that the DeCo package relies on a general algorithm which can account for different scoring rules, such as the Kullback-Leibler score (Hall and Mitchell (2007) and Geweke and Amisano (2010)) and the Cumulative Rank Probability Score (Gneiting and Raftery (2007)).1 The proposed state space representation of the combination scheme composed by the observation equation in (1) and the latent equations (2), (3)or(4) provides a forecast density for the observable variables, conditional on the predictors and on the combination weights. Moreover, the representation is quite general, allowing for nonlinear and non-Gaussian combination models. We use sequential Monte Carlo algorithms, also known as particle filters, to estimate sequentially over time the optimal combination weights and the predictive density. 1The user interested in different scoring rules should change the command lines with the learning in the file PF- CoreGPU.m for the GPU version and PFCore.m for the CPU version. 5 The steps of the density combination algorithm are sketched in the rest of this section. Let θ∈Θ⊂ Rnθbe the parameter vector of the combination model, with θ=(logσ2 1,...,log σ2 L,log λ1,...,log λKL2). Define the augmented state vector zt=(xt,θt)∈Zand the augmented state space Z=X×Θ, where θt=θ,∀t. The distributional state space form of the forecast model is yt∼p(yt|zt,˜ yt)(measurement density) (5) zt∼p(zt|zt−1,y1:t−1,˜ y1:t−1)(transition density) (6) z0∼p(z0)(initial density) (7) The state predictive and filtering densities conditional on the predictive variables ˜ y1:tare p(zt+1|y1:t,˜ y1:t)=Z p(zt+1|zt,y1:t,˜ y1:t)p(zt|y1:t,˜ y1:t)dzt(8) p(zt+1|y1:t+1,˜ y1:t+1)=p(yt+1|zt+1,˜ yt+1)p(zt+1|y1:t,˜ y1:t) p(yt+1|y1:t,˜ y1:t)(9) respectively, which represent the optimal nonlinear filter (see Doucet, Freitas, and Gordon (2001)). The marginal predictive density of the observable variables is then p(yt+1|y1:t)= Y p(yt+1|y1:t,˜ yt+1)p(˜ yt+1|y1:t)d˜ yt+1 (10) where p(˜ yt+1|y1:t)= K  k=1 p(˜ yk,t+1|y1:t)(11) is the joint density of the predictors and p(yt+1|y1:t,˜ yt+1)is defined as Z×YKt p(yt+1|zt+1,˜ yt+1)p(zt+1|y1:t,˜ y1:t)p(˜ y1:t|y1:t−1)dzt+1d˜ y1:t(12) and represents the conditional predictive density of the observable given the past values of the observable and of the predictors. 2.2. A combination algorithm The analytical solution of the optimal filter for non-linear state space models is generally not known. An approximate solution is needed. We apply a numerical approximation method, which converges to the optimal filter in Hilbert metric, in the total variation norm and in a weaker distance suitable for random probability distributions (e.g., see Legland and Oudjane (2004)). More specifically, we consider a sequential Monte Carlo (SMC) approach to filtering. See Doucet et al. (2001) for an introduction to SMC and Creal (2009) for a recent survey on SMC in economics. We propose using banks of SMC filters, where each filter is conditioned on a sequence of realizations of the predictor vector ˜ yt, see BCRVD(2013). The resulting algorithm for the sequential combination of densities is defined through the following steps, see Section Afor a graphical representation. Step 0 (initialization, eq. (7)) Initialize independent particle sets Ξj 0={zi,j 0,ωi,j 0}N i=1,j=1,...,M. Each particle set Ξj 0contains Ni.i.d. random variables zi,j 0with random weights ωi,j 0.2Initialize a random grid over the set of 2The parameter θi,j 0in zi,j 0can be fixed or estimated. When estimated, the parameter must be initialized by drawing from the prior. The prior requires the specification of the mean and the standard deviation of the random noise of the log normal random walk process that θis assumed to follow. DeCo toolbox includes all these options, see Section B. 6DeCo:AMATLAB Toolbox for Density Combination predictors, by generating i.i.d. samples ˜ yj 1,j=1,...,M, from p(˜ y1|y0). We use the sample of observations y0to initialize the individual predictors. Step 1 (predictor generation, eq. (11)) At the iteration t+1of the combination algorithm, we approximate the predictive density p(˜ yt+1|y1:t) with the discrete probability pM(˜ yt+1|y1:t)= M  j=1 δ˜ yj t+1 (˜ yt+1) where ˜ yj t+1,j=1,...,M, are i.i.d. samples from the predictive densities and δx(y)denotes the Dirac mass centered at x. This approximation is also motivated by the forecasting practice (see Jore, Mitchell, and Vahey (2010)). The predictions usually come, from different models or sources, in the form of discrete densities. In some cases, this is the result of a collection of point forecasts from many subjects, such as surveys forecasts. In other cases the discrete predictive is a result of a Monte Carlo approximation of the predictive density (e.g., importance sampling or Markov chain Monte Carlo approximation of the model predictive density). Step 2 (filtering and prediction) We assume an independent sequence of particle sets Ξj t={zi,j 1:t,ωi,j t}N i=1,j=1,...,M, is available at time t+1and that each particle set provides the approximation pN,j(zt|y1:t,˜ yj 1:t)= N  i=1 ωi,j tδzi,j t(zt)(13) of the filtering density, p(zt|y1:t,˜ yj 1:t), conditional on the j-th predictor realization, ˜ yj 1:t. Then M independent SMC algorithms are used to find a new sequence of Mparticle sets, which include the information available from the new observation and the new predictors. Each SMC algorithm iterates, for j=1,...,M, the following steps. Step 2.a (state prediction, eq. (8)) The basic SMC algorithm uses the particle set to approximate the predictive density with an empirical density. We use a regularized version of the SMC procedure (e.g., see Liu and West (2001), Musso, Oudjane, and Legland (2001) and Casarin and Marin (2009)). More specifically, the predictive density of combination weights and parameters, zt+1, conditional on ˜ yj 1:tand y1:tis approximated as follows pN,j(zt+1|y1:t,˜ yj 1:t)= N  i=1 p(xt+1|xt,θt+1,y1:t,˜ yj 1:t)ωi,j tδxi,j t(xt)Kh(θt+1 −θi,j t)(14) where Kh(y)=h−nθK(y/h)is the regularization kernel, Kbeing a positive function defined on Rnθ and ha positive smoothing factor (bandwidth). Step 2.b (state filtering, eq. (9)) We update the state predictive density by using the information coming from ˜ yj t+1 and yt+1, that is pN,j(zt+1|y1:t+1,˜ yj 1:t+1)= N  i=1 γi,j t+1δzi,j t+1 (zt+1)(15) 13 0 0.2 0.4 0.6 0.8 1 1.2 x 10 −4 0 0.5 1 0 1 2 x 10 −4 0 0.5 1 0 0.5 1 1.5 2 2.5 3 x 10 −3 0 0.5 1 GPU CPU GPU CPU GPU CPU 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 x 10 −4 0 0.5 1 0 1 2 x 10 −4 0 0.5 1 0 0.5 1 1.5 2 2.5 3 x 10 −3 0 0.5 1 GPU CPU GPU CPU GPU CPU Figure 2: CDFs of the CPU and GPU mean square errors in the MC estimators of ˆσ2 N(f)when setting the same random generator number (left column) and when not (right column), for different choices of f(different rows), using G= 1000 replications. terms of computing time, for all experiments. Time differences between the CPU and GPU executions are very large (see Table 2, panel (a)), and result in a saving of up to several hours when using 5000 particles (see Table 2, panel (b)). More specifically, the computational gain of the GPU implementation over parallel CPU implementation varies from 3 to 4 times for the Intel Core i7 and from 5 to 7 times for the Intel Xeon X3430. The overperformance of the parallel GPU implementation on sequential CPU implementation varies from 15 to 20 times when considering an Intel Xeon X3430 machine as a benchmark. Figure 3compares the weights for experiments 1 and 2. The weights follow a very similar pattern, but there are some minor discrepancies between them for some observations. Differences are larger for the median value than for the smaller and larger quantiles. The differences are, however, smaller and almost vanish when one focuses on the predictive densities in Figure 4, which is the most important output of the density combination algorithm. We interpret the results as evidence of no economic and statistic significance of the differences between CPU and GPU draws. The results are similar when focusing on the incomplete model set in Figures 5-6. The evidence does not change when we use 5000 particles. Learning mechanism experiments BCRVD (2013) document that a learning mechanism in the weights is crucial to identify the true model (in the case of complete model set) or the best model (in the case of incomplete model set) when the predictions are unbiased, see also left panels in Figures 3-5. We repeat the two unbiased predictor experiments and introduce learning in the combination weights as discussed in Section 2. We set the learning parameters λ=0.95 and τ=9. Tables 3reports the time comparison (in seconds) when using 1000 and 5000 particles filtered model probability weights. The computation time for DeCo increases when learning mechanisms are applied, in particular for the CPU. The GPU 14 DeCo:AMATLAB Toolbox for Density Combination Biased Predictors Unbiased predictors 010 20 30 40 50 60 70 80 90 100 0 0.5 1 GPU CPU 010 20 30 40 50 60 70 80 90 100 0 0.5 1 GPU CPU 010 20 30 40 50 60 70 80 90 100 0 0.02 0.04 0.06 GPU CPU 010 20 30 40 50 60 70 80 90 100 0 0.5 1 GPU CPU 010 20 30 40 50 60 70 80 90 100 0 0.5 1 GPU CPU 010 20 30 40 50 60 70 80 90 100 0 0.5 1 GPU CPU Figure 3: GPU and CPU 1000 particles filtered model probability weights for the complete model set. Median and 95% credibility region for model weights 1,2 and 3 (different rows). Biased Predictors Unbiased predictors 010 20 30 40 50 60 70 80 90 100 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 GPU CPU 010 20 30 40 50 60 70 80 90 100 0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5 GPU CPU Figure 4: GPU and CPU 1000 particles filtered density forecasts for the complete model set. Mean and 95% credibility region of the combined predictive density. 15 Biased Predictors Unbiased predictors 010 20 30 40 50 60 70 80 90 100 0.995 0.996 0.997 0.998 0.999 1 1.001 GPU CPU 010 20 30 40 50 60 70 80 90 100 0 1 2 3 4 5 x 10 −3 GPU CPU 010 20 30 40 50 60 70 80 90 100 0 0.2 0.4 0.6 0.8 1 GPU CPU 010 20 30 40 50 60 70 80 90 100 0 0.2 0.4 0.6 0.8 1 GPU CPU Figure 5: GPU and CPU 1000 particles filtered model probability weights for the incomplete model set. Median and 95% credibility region for model weights 1,2 and 3 (different rows). Biased Predictors Unbiased predictors 010 20 30 40 50 60 70 80 90 100 0.2 0.25 0.3 0.35 0.4 0.45 0.5 0.55 0.6 0.65 GPU CPU 010 20 30 40 50 60 70 80 90 100 0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5 GPU CPU Figure 6: GPU and CPU 1000 particles filtered density forecasts for the incomplete model set. Mean and 95% credibility region of the combined predictive densities. 16 DeCo:AMATLAB Toolbox for Density Combination (a) 1000 Particles p-GPU p-CPU-i7 p-CPU-Xeon CPU-Xeon Complete Model Set Biased Predictors 699 2780 5119 11749 (3.97) (7.32) (16.80) Unbiased Predictors 660 2047 5113 11767 (3.10) (7.75) (17.83) Incomplete Model Set Biased Predictors 671 2801 5112 11635 (4.17) (7.62) (17.34) Unbiased Predictors 687 2035 5098 11636 (2.96) (7.42) (16.94) (b) 5000 particles p-GPU p-CPU-i7 p-CPU-Xeon CPU-Xeon Complete Model Set Biased Predictors 4815 15154 26833 64223 (3.15) (5.57) (13.34) Unbiased Predictors 5302 15154 26680 63602 (2.86) (5.03) (12.00) Incomplete Model Set Biased Predictors 4339 13338 26778 64322 (3.07) (6.17) (14.82) Unbiased Predictors 4581 13203 26762 63602 (2.88) (5.84) (13.88) Table 2: Density combination computing time in seconds. Rows: different simulation experiments. Columns: parallel GPU (p-GPU) and parallel CPU (p-CPU-i7) implementations on GPU NVIDIA Quadro K2000M with CPU Intel Core i7-3820QM, 3.7GHz; parallel CPU (p- CPU-Xeon) and sequential CPU (CPU-Xeon) implementations on Intel Xeon X3430 4core, 2.40GHz. In parentheses: efficiency gain in terms of CPU/GPU times ratio. is 10% to 50% slower than without learning, but CPU is 2.5 to almost 4 times slower than previously. The GPU/CPU ratio, therefore, increases in favor of GPU with GPU computation 5 to 70 times faster depending on the alternative CPU machine considered. The DeCo codes with learning have some if commands related to the minimum numbers of observations necessary to initiate the learning, which increases computational time substantially. The parallelization in GPU is more efficient because it is carried out on blocks of draws and these if commands play a minor role. We expect that the gain might increase to several hundreds of times when using parallelization on GPU clusters. 5. Empirical application As a further check of the performance of the DeCo code, we compare the CPU and GPU versions in the macroeconomic application developed in BCRVD (2013). We consider K=6time series models to predict US GDP growth and PCE inflation: a univariate autoregressive model of order 17 p-GPU p-CPU-i7 p-CPU-Xeon CPU-Xeon (a) 1000 Particles Complete Model Set 755 7036 14779 52647 (9.32) (19.57) (69.73) Incomplete Model Set 719 6992 14741 52575 (9.72) (20.49) (73.08) (b) 5000 particles Complete Model Set 7403 35472 73402 274220 (4.79) (9.92) (37.04) Incomplete Model Set 7260 35292 73256 274301 (4.86) (10.09) (37.78) Table 3: Density combination computing time in seconds. Rows: different simulation experiments with unbiased predictors and a learning mechanism in the weights. Columns: parallel GPU (p-GPU) and parallel CPU (p-CPU-i7) implementations on GPU NVIDIA Quadro K2000M with CPU Intel Core i7-3820QM, 3.7GHz; parallel CPU (p-CPU-Xeon) and sequential CPU (CPU-Xeon) implementations on Intel Xeon X3430 4core, 2.40GHz. In parentheses: efficiency gain in terms of CPU/GPU times ratio. one (AR); a bivariate vector autoregressive model for GDP and PCE of order one (VAR); a two-state Markov-switching autoregressive model of order one (ARMS); a two-state Markov-switching vector autoregressive model of order one for GDP and inflation (VARMS); a time-varying autoregressive model with stochastic volatility (TVPARSV); and a time-varying vector autoregressive model with stochastic volatility (TVPVARSV). Therefore, the model set includes constant parameter univariate and multivariate specification; univariate and multivariate models with discrete breaks (Markov- Switching specifications); and univariate and multivariate models with continuous breaks. These are typical models applied in macroeconomic forecasting; see, for example, Clark and Ravazzolo (2012), Korobilis (2013) and D’Agostino, Gambetti, and Giannone (2013). We evaluate the two combination methods by applying the following evaluation metrics: Root Mean Square Prediction Errors (RMSPE), Kullback Leibler Information Criterion (KLIC) based measure, the expected difference in the Logarithmic Scores (LS) and the Continuous Rank Probability Score (CRPS). Accuracy statistics and related tests (see BCRVD (2013)) are used to compare the forecast accuracy. Table 4reports results for the multivariate combination approach. For the sake of brevity, we just present results using parallel GPU and the best parallel CPU Intel Core i7-3820QM machine. We also do not consider a learning mechanism in the weights. GPU is substantially faster, almost 5.5 times faster than CPU, reducing the computational time by more than 5000 seconds. GPU therefore performs relatively better in this experiment than in the previous simulation experiments (without learning mechanisms). The explanation relies on the larger set of models and the multivariate application. The number of simulations has increased substantially and CPU starts to hit physical limits, slowing down the computation and extending time. GPU has no binding limits and just double the time of simulation experiments with a univariate series and the same number of draws and particles.6 This suggests that GPU might be an efficient methodology to investigate when averaging large sets of 6Unreported results show that GPU is more than 36 times faster than sequential CPU implementation on Intel Xeon X3430 4core. 18 DeCo:AMATLAB Toolbox for Density Combination GDP Inflation GPU CPU GPU CPU Time 1249 6923 - - RMSPE 0.634 0.637 0.255 0.256 CW 0.000 0.000 0.000 0.000 LS -1.126 -1.130 0.251 0.257 p-value 0.006 0.005 0.021 0.022 CRPS 0.312 0.313 0.112 0.112 p-value 0.000 0.000 0.000 0.000 Table 4: Computing time and forecast accuracy for the macro-economic application for the GPU (column GPU) and CPU (column CPU) implementations. Rows: Time: time to run the experiment in seconds; RMSPE: Root Mean Square Prediction Error; CW: p-value of the Clark and West (2007) test; LS: average Logarithmic Score over the evaluation period; CRPS: cumulative rank probability score; LS p-value and CRPS p-value: Harvey et al. (1997) type of test for LS and CRPS differentials respectively. models. Accuracy results for CPU and GPU combinations are very similar and just differ after the third decimal, confirming previous intuitions that the two methods are not necessarily numerically identical, but provide identical economic and statistical conclusions.7The combination approach is statistically superior to the AR benchmark for all the three accuracy measures we implement. 6. Conclusion This paper introduces the MATLAB package DeCo (Density Combination) based on parallel Sequential Monte Carlo simulations to combine density forecasts with time-varying weights and different choices of scoring rule. The package is easy to use for a standard MATLAB user and to facilitate promulgation we have implemented a GUI, which just requires a few input parameters. The package takes full advantage of recent computer hardware progresses and uses banks of parallel SMC algorithms for the density combination using both multi-core CPU and GPU implementation. The DeCo GPU version is up to 70 times faster than the CPU version and even more for larger sets of models. More specifically, our simulation and empirical experiments were conducted using a commercial notebook with CPU Intel Core i7-3820QM and GPU NVIDIA Quadro K2000M, and MATLAB 2013b version, and show that the DeCo GPU version is faster than the parallel CPU version, up to 10 times when the weights include a learning mechanism and up to 5.5 times without it, when using an i7 CPU machine and the Parallel Computing Toolbox. These findings are similar to results in Brodtkorb et al. (2013) when using a raw CUDA environment. In the comparison between GPU and non-parallel CPU implementations, the differences between GPU and CPU time increase up to almost 70 times when using a standard CPU processor, such as quad-core Xeon. Our results can be further improved with the use of more powerful graphics cards, such as GTX cards. All comparisons have been implemented using double precision for both the CPU and GPU versions. However, if 7Numbers for the CPU combination differ marginally (and often just in the third decimal) from those in Table 4in BCRVD (2013) due to the use of a different MATLAB version, different generator numbers and parallel tooling functions. 19 an application allows for a lower degree of precision, then single precision calculation can be used and massive gains (up to 500) can be attained, as documented in Lee et al. (2010) and Geweke and Durham (2012). We also document that the CPU and GPU versions do not necessarily provide the exact same numerical solutions to our problems, but differences are not economically and statistically significant. Therefore, users of DeCo might choose between the CPU and GPU versions depending on the available and preferred clusters. Finally, we expect that our research and the DeCo GPU implementation would benefit enormously from improvement in the MATLAB parallel computing toolbox, such as the possible incorporation of a parallel “for” loop command for GPU; by the inclusion in the package of different particle filters, such as post- and pre-regularized particle filters and of different density combination schemes; and by applications to large sets of predictive densities as in Casarin, Grassi, Ravazzolo, and van Dijk (2014). Acknowledgement For their useful comments, we thank Daniel Armyr and Sylvia Frühwirth-Schnatter and seminar and conference participants at the European Seminar on Bayesian Econometrics 2013, Norges Bank, the 7th Rimini Bayesian Econometrics Workshop and the 2013 Vienna IHS Time-Series Workshop. Roberto Casarin’s research is supported by the Italian Ministry of Education, University and Research (MIUR) PRIN 2010-11 grant, and by funding from the European Union, Seventh Framework Programme FP7/2007-2013 under grant agreement SYRTO-SSH-2012-320270. The views expressed in this paper are our own and do not necessarily reflect those of Norges Bank. References Aldrich EM (2013). “Massively Parallel Computing in Economics.” Technical report, University of California, Santa Cruz. Aldrich EM, Fernández-Villaverde J, Gallant AR, Rubio Ramırez JF (2011). “Tapping the Supercomputer Under Your Desk: Solving Dynamic Equilibrium Models with Graphics Processors.” Journal of Economic Dynamics and Control,35, 386–393. Bates JM, Granger CWJ (1969). “Combination of Forecasts.” Operational Research Quarterly,20, 451–468. Billio M, Casarin R, Ravazzolo F, van Dijk HK (2013). “Time-varying Combinations of Predictive Densities Using Nonlinear Filtering.” Journal of Econometrics,177, 213–232. Brodtkorb AR, Hagen TR, Saetra LS (2013). “Graphics Processing Unit (GPU) Programming Strategies and Trends in GPU Computing.” Journal of Parallel and Distributed Computing,73, 4–13. Casarin R, Grassi S, Ravazzolo F, van Dijk HK (2014). “Dynamic Predictive Density Combinations for Large Datasets.” Unpublished manuscript, Norges Bank. Casarin R, Marin JM (2009). “Online Data Processing: Comparison of Bayesian Regularized Particle Filters.” Electronic Journal of Statistics,3, 239 – 258. 20 DeCo:AMATLAB Toolbox for Density Combination Chan H, Lai T (2013). “A general theory of particle filters in hidden Markov models and some applications.” The Annals of Statistics,41, 2877–2904. Chong Y, Hendry DF (1986). “Econometric Evaluation of Linear Macroeconomic Models.” The Review of Economic Studies,53, 671 – 690. Chopin N (2004). “Central limit theorem for sequential Monte Carlo methods and its application to Bayesian inference.” The Annals of Statistics,32(6), 2385–2411. Clark T, Ravazzolo F (2012). “The Macroeconomic Forecasting Performance of Autoregressive Models with Alternative Specifications of Time-Varying Volatility.” Technical report, FRB of Cleveland Working Paper 12-18. Clark T, West K (2007). “Approximately Normal Tests for Equal Predictive Accuracy in Nested Models.” Journal of Econometrics,138, 291 – 311. Creal D (2009). “A Survey of Sequential Monte Carlo Methods for Economics and Finance.” Econometric Reviews,31(3), 245 – 296. Creel M (2005). “User-Friendly Parallel Computations with Econometric Examples.” Computational Economics,26, 107 – 128. Creel M, Goffe WL (2008). “Multi-core CPUs, Clusters, and Grid Computing: A Tutorial.” Computational Economics,32, 353 – 382. Creel M, Mandal S, Zubair M (2012). “Econometrics in GPU.” Technical Report 669, Barcelona GSE Working Paper. D’Agostino A, Gambetti L, Giannone D (2013). “Macroeconomic Forecasting and Structural Change.” Journal of Applied Econometrics,28, 82 – 101. Del Moral P, Guionnet A (2001). “On the stability of interacting processes with applications to filtering and genetic algorithms.” Ann. Inst. H. Poincaré Probab. Statist.,37, 155–194. Doucet A, Freitas JG, Gordon J (2001). Sequential Monte Carlo Methods in Practice. Springer- Verlag, New York. Dziubinski MP, Grassi S (2013). “Heterogeneous Computing in Economics: A Simplified Approach.” Computational Economics, pp. 1245 – 1266. Geweke J, Amisano G (2010). “Optimal Prediction Pools.” Journal of Econometrics,164(2), 130 – 141. Geweke J, Durham G (2012). “Massively Parallel Sequential Monte Carlo for Bayesian Inference.” Working papers, National Bureau of Economic Research, Inc. Gneiting T, Raftery AE (2007). “Strictly Proper Scoring Rules, Prediction, and Estimation.” Journal of the American Statistical Association,102, 359 – 378. Granger CWJ, Ramanathan R (1984). “Improved Methods of Combining Forecasts.” Journal of Forecasting,3, 197 – 204. 21 Gregory K, Miller A (2012). Accelerated Massive Parallelism with Microsoft Visual C++. Microsoft Press, USA. Hall SG, Mitchell J (2007). “Combining Density Forecasts.” International Journal of Forecasting, 23,1–13. Harvey D, Leybourne S, Newbold P (1997). “Testing the Equality of Prediction Mean Squared Errors.” International Journal of Forecasting,13, 281 – 291. Hoberock J, Bell N (2011). Thrust: A parallel template library, Version 1.4.0. IEEE (2008). IEEE 754 - 2008. IEEE 754 - 2008 Standard for Floating-Point Arithmetic. IEEE. Jore AS, Mitchell J, Vahey SP (2010). “Combining Forecast Densities from VARs with Uncertain Instabilities.” Journal of Applied Econometrics,25(4), 621 – 634. Khronos OpenCL Working Group (2009). The OpenCL Specification Version 1.0. Khronos Group. URL http://www.khronos.org/opencl. Korobilis D (2013). “VAR Forecasting Using Bayesian Variable Selection.” Journal of Applied Econometrics,28, 204 – 230. Le Gland F, Oudjane N (2004). “Stability and uniform approximation of nonlinear filters using the Hilbert metric and application to particle filters.” The Annals of Applied Probability,14(1), 144– 187. Lee A, Christopher Y, Giles MB, Doucet A, Holmes CC (2010). “On the Utility of Graphic Cards to Perform Massively Parallel Simulation with Advanced Monte Carlo Methods.” Journal of Computational and Graphical Statistics,19, 769 – 789. Legland F, Oudjane N (2004). “Stability and Uniform Approximation of Nonlinear Filters using the Hilbert Metric and Application to Particle Filters.” The Annals of Applied Probability,14, 144 – 187. LeSage JP (1998). “ECONOMETRICS: MATLAB Toolbox of Econometrics Functions.” Statistical Software Components, Boston College Department of Economics. Liu J, Chen R (1998). “Sequential Monte Carlo Methods for Dynamical System.” Journal of the American Statistical Association,93, 1032 – 1044. Liu JS, West M (2001). “Combined Parameter and State Estimation in Simulation Based Filtering.” In A Doucet, N de Freitas, N Gordon (eds.), Sequential Monte Carlo Methods in Practice. Springer- Verlag. Morozov S, Mathur S (2011). “Massively Parallel Computation Using Graphics Processors with Application to Optimal Experimentation in Dynamic Control.” Computational Economics,pp.1– 32. Murray LM, Lee A, Jacob PE (2014). “Parallel resampling in the particle filter.” Working paper. Musso C, Oudjane N, Legland F (2001). “Improving Regularised Particle Filters.” In A Doucet, N de Freitas, N Gordon (eds.), Sequential Monte Carlo Methods in Practice. Springer-Verlag. 22 DeCo:AMATLAB Toolbox for Density Combination Nvidia Corporation (2010). Nvidia CUDA Programming Guide, Version 3.2. URL http://www. nvidia.com/CUDA. Press WH, Teukolsky ST, Vetterling WT, Flannery BP (1992). Numerical Recipes in C: the Art of Scientific Computing. 2nd edition. Cambridge University Press, Cambridge, England. Robert CP, Casella G (2004). Monte Carlo Statistical Methods. 2nd edition. Springer-Verlag, Berlin. Stroustrup B (2000). The C++ Programming Language. 3rd edition. Addison-Wesley Longman Publishing Co., Inc., Boston, MA, USA. Suchard M, Holmes C, West M (2010). “Some of the What?, Why?, How?, Who? and Where? of Graphics Processing Unit Computing for Bayesian Analysis.” Bulletin of the International Society for Bayesian Analysis,17,12–16. Sutter H (2005). “The Free Lunch Is Over: A Fundamental Turn Toward Concurrency in Software.” Dr. Dobb’s Journal. URL http://www.gotw.ca/publications/concurrencyddj. htm. Sutter H (2011). “Welcome to the Jungle.” URL http://herbsutter.com/ welcome-to-the-jungle/. Swann CA (2002). “Maximum Likelihood Estimation Using Parallel Computing: An Introduction to MPI.” Computational Economics,19, 145 – 178. Terui N, van Dijk HK (2002). “Combined Forecasts from Linear and Nonlinear Time Series Models.” International Journal of Forecasting,18, 421 – 438. The MathWorks, Inc (2011). MATLAB – The Language of Technical Computing, Version R2011b. The MathWorks, Inc., Natick, Massachusetts. URL http://www.mathworks.com/products/ matlab/.