time series modelling with matlab the sspace toolbox
play

Time series modelling with MATLAB: the SSpace toolbox Pedregal DJ, - PowerPoint PPT Presentation

Introduction State Space Framework System implementation in SSpace Examples Conclusion Time series modelling with MATLAB: the SSpace toolbox Pedregal DJ, Villegas MA, Villegas D, Trapero JR Universidad de Castilla-La Mancha ETSII (Ciudad


  1. Introduction State Space Framework System implementation in SSpace Examples Conclusion Time series modelling with MATLAB: the SSpace toolbox Pedregal DJ, Villegas MA, Villegas D, Trapero JR Universidad de Castilla-La Mancha ETSII (Ciudad Real) PREDILAB Diego.Pedregal@uclm.es ITISE2018, Granada, September Pedregal DJ, Villegas MA, Villegas D, Trapero JR 1/27

  2. Introduction State Space Framework System implementation in SSpace Examples Conclusion Outline 1 Introduction 2 State Space Framework 3 System implementation in SSpace 4 Examples 5 Conclusion Pedregal DJ, Villegas MA, Villegas D, Trapero JR 2/27

  3. Introduction State Space Framework System implementation in SSpace Examples Conclusion Introduction SSpace is a package that implements linear, non-linear and non-Gaussian State Space systems in a very flexible and powerful way. It is mainly based on the work of Peter C Young and colaborators with other elements, like the books of Harvey (1989), Durbin and Koopman (2012), resembling many well-known alternative packages, but there are some unique interesting elements in it... Download at https://bitbucket.org/predilab/sspace-matlab/ To appear soon at the Journal of Statistical Software Pedregal DJ, Villegas MA, Villegas D, Trapero JR 3/27

  4. Introduction State Space Framework System implementation in SSpace Examples Conclusion Introduction Statistical features: 1 The statistical framework is very general in the equations formulation and in the sense that all system matrices are multivariate and potentially time-varying. 2 Exact or diffuse initialisation of Kalman Filtering and state and disturbance smoothing. 3 Use of exact gradient in Maximum Likelihood estimation, when possible. 4 Kalman filtering and smoothing based on univariate treatment of multivariate systems. 5 Other estimation procedures, i.e. Concentrated Likelihood and minimum RMSE of several steps ahead are implemented. 6 ... Pedregal DJ, Villegas MA, Villegas D, Trapero JR 4/27

  5. Introduction State Space Framework System implementation in SSpace Examples Conclusion Introduction Other advantages: 1 It is free. 2 Simple in its usage, since models are standard functions written in MATLAB. 3 A wide range of templates for specific models are available (Unobserved Components, ARIMA, Regression, Exponential Smoothing, Stochastic Volatility, etc.). 4 A full time series analysis may be done with a reduced number of coded functions with names that have been carefully selected following nemotechnic rules so that the user may remember them easily. 5 Minimizer may be chosen (fminunc). 6 We have a fully MATLAB version, we have coded core functions in C++ and finishing a R version. Pedregal DJ, Villegas MA, Villegas D, Trapero JR 5/27

  6. Introduction State Space Framework System implementation in SSpace Examples Conclusion Linear-Gaussian State Space system α t +1 = T t α t + γ t + R t η t State equation: y t = Z t α t + d t + C t ǫ t Observation equation: η t : vector of state noises v × 1, N (0; Q t ) ǫ t : vector of observed noises h × 1, N (0; H t ) S t = E ( ǫ t , η ′ t ) covariance matrix h × v γ t = f (Γ t , u t ) and d t = g ( D t , u t ), with u t of dimensions k × 1 y t : output vector m × 1 α t : state vector n × 1 Every term is potentially multivariate and time-varying Many different ways to write the same system Pedregal DJ, Villegas MA, Villegas D, Trapero JR 6/27

  7. Introduction State Space Framework System implementation in SSpace Examples Conclusion Non-Gaussian State Space system α t +1 = T t α t + γ t + R t η t State equation: y t ∼ p ( y t | θ t ) + d t Observation equation: θ t = Z t α t 1 Exponential family distribution, where p ( y t | θ t ) = exp [ y ′ t θ t − b t ( θ t ) + c t ( y t )] , −∞ < θ t < ∞ . 2 Stochastic Volatility models, i.e. y t = exp ( 1 2 θ t ) ǫ t + d t . 3 Observations generated by the relation y t = θ t + ǫ t , ǫ t ∼ p ( ǫ t ), with p ( • ) being a distribution of the exponential family. Pedregal DJ, Villegas MA, Villegas D, Trapero JR 7/27

  8. Introduction State Space Framework System implementation in SSpace Examples Conclusion Non-Linear State Space system α t +1 = T t ( α t ) + γ t + R t ( α t ) η t State equation: y t = Z t ( α t ) + d t + C t ( α t ) ǫ t Observation equation: η t ∼ N (0 , Q t ( α t )), ǫ t ∼ N (0 , H t ( α t )) The system is actually non-linear and/or state-dependent. At the moment the Extended Kalman Filter and state smoothing with exact initialisation are the implemented algorithms (Koopman and Lee, 2009). Pedregal DJ, Villegas MA, Villegas D, Trapero JR 8/27

  9. Introduction 1. Specify State Space Framework 2. Translate System implementation in SSpace 3. Set up model Examples 4. Estimation, validation, filtering, ... Conclusion 1. Specify the model For a local level model: State equation: L t +1 = L t + η t Observation equation: y t = L t + ǫ t We have to fit that model in the general framework: State equation: α t +1 = T t α t + γ t + R t η t Observation equation: y t = Z t α t + d t + C t ǫ t α t = L t ; T t = 1; R t = 1; Z t = 1; C t = 1; γ t and d t do not exist. S t = 0 and Q t and H t are two unknown scalar values that have to be positive Pedregal DJ, Villegas MA, Villegas D, Trapero JR 9/27

  10. Introduction 1. Specify State Space Framework 2. Translate System implementation in SSpace 3. Set up model Examples 4. Estimation, validation, filtering, ... Conclusion 2. Translate Translate model to a MATLAB function (e.g. using templates). model= SampleSS(p) 1 model.T= []; model.Gam= []; model.R= []; model.Z= []; model.D= []; 2 model.C= []; model.Q= []; model.H= []; model.S= []; 3 ✆ For the local level model: L t +1 = L t + η t y t = L t + ǫ t model= example1(p) 1 model.T= 1; model.Gam= []; model.R= 1; model.Z= 1; model.D= []; 2 model.C= 1; model.Q= 10.ˆp(1); % This makes variance always positive 3 model.H= 10.ˆp(2); model.S= 0; 4 ✆ Pedregal DJ, Villegas MA, Villegas D, Trapero JR 10/27

  11. Introduction 1. Specify State Space Framework 2. Translate System implementation in SSpace 3. Set up model Examples 4. Estimation, validation, filtering, ... Conclusion 3. Set up the model sys= SSmodel('y', y, 'model', @example1); 1 ✆ Using duplets it is possible to select the input and output data, the model filename, additional inputs to the function that implements the model, initial values for parameters, fix values for parameters, diffuse or exact initialisatoin of algorithms, objective cost function and analytical or exact score in Maximum Likelihood estimation. Pedregal DJ, Villegas MA, Villegas D, Trapero JR 11/27

  12. Introduction 1. Specify State Space Framework 2. Translate System implementation in SSpace 3. Set up model Examples 4. Estimation, validation, filtering, ... Conclusion 3. Set up the model Inputs to the system (and to SSmodel): y: [1x100 double] 1 u: [] 2 model: @example1 3 user_inputs: {} 4 p0: [2x1 double] 5 p: [2x1 double] 6 a1: NaN 7 P1: NaN 8 OBJ_FUNCTION_NAME: {@llik} 9 gradient: 1 10 Nsimul: 300 11 ✆ Pedregal DJ, Villegas MA, Villegas D, Trapero JR 12/27

  13. Introduction 1. Specify State Space Framework 2. Translate System implementation in SSpace 3. Set up model Examples 4. Estimation, validation, filtering, ... Conclusion 3. Set up the model Outputs of operations on models: table: [] 1 obj_value: 0 2 llik: 0 3 covp: [] 4 mat: [1x1 struct] 5 a: 740.0149 6 P: 0.7781 7 yfit: [] 8 F: [] 9 yfor: [] 10 Ffor: [] 11 v: [] 12 Fv: [] 13 eta: [] 14 eps: [] 15 Veta: [] 16 Veps: [] 17 ✆ Pedregal DJ, Villegas MA, Villegas D, Trapero JR 13/27

  14. Introduction 1. Specify State Space Framework 2. Translate System implementation in SSpace 3. Set up model Examples 4. Estimation, validation, filtering, ... Conclusion 4. Estimation, validation, filtering, ... sys= SSestim(sys); 1 sys= SSvalidate(sys); 2 ✆ sys= SSfilter(sys); % Just for filtering estimates 1 sys= SSsmooth(sys); % For state smoothing estimates 2 sys= SSdisturb(sys); % If disturbance smoothing is required 3 ✆ Results are stored in sys output structure. It stores parametes with covariance matrix, optimal states and covariances, fitted output values and covariances, forecasted values and covariances, innovations, disturbances estimates with covariances. Further statistical diagnostics are advisable. Pedregal DJ, Villegas MA, Villegas D, Trapero JR 14/27

  15. Introduction Example 1 State Space Framework Example 2 System implementation in SSpace Example 3 Examples Example 4 Conclusion Example 1: VARMA The standard VARMA template is: model= SampleVARMA(p) 1 Sigma = ; % Covariance matrix of perturbance 2 DIFFpoly= ; % Difference operator of output(s) 3 ARpoly = ; % (V)AR polynomial 4 MApoly = ; % (V)MA polynomial 5 D= ; % Inputs 6 ✆ model= SampleVARMA(p) 1 Sigma = 10.ˆp(1); % Covariance matrix of perturbance 2 DIFFpoly= 1; % Difference operator of output(s) 3 ARpoly = [1 p(2) p(3)]'; % (V)AR polynomial 4 MApoly = [1 p(4)]'; % (V)MA polynomial 5 D= p(5); % Inputs 6 ✆ Pedregal DJ, Villegas MA, Villegas D, Trapero JR 15/27

Recommend


More recommend