MDFA-Tutorial (MSE-Criterion)

I here provide a tutorial on univariate as well as on multivariate real-time filtering, using the MDFA-package on Github.  I will emphasize the Mean-Square Error (MSE) norm 'only' in this tutorial. The material is designed as an entry-point to the MDFA-methodology (see Advances in Signal Extraction and Forecasting) and to the R-package.


Objectives


  • Handling of the MDFA-package in a simple application (various case-studies)
  • Replication of the results in the MSE-chapter of  MDFA (chapter 4) 
    • The code below is obtained directly from the book (using the stangle-command of the sweave package). I slightly simplified the initialization steps because I'll emphasize MSE-performances 'only'. 
    • Some of the (MSE-) slides in Advances in Signal Extraction and Forecasting will be addressed too in this tutorial.
  • Introduction to (univariate and bivariate) filtering
    • Show that the multivariate filter (MDFA) replicates and generalizes univariate filters (DFA)  
    • Analyze effects of so-called leading-indicators (a time series which anticipates turning-points of an interesting target series). In particular, the example illustrates the effects of the lead-time as well as of the noisiness of an indicator on MSE-performances (two-parametric simulation summarized in the table at the end of  chapter 4 in MDFA).  The user can  analyze arbitrary designs by supplying different noise/lead combinations (specify different grid points).

Limitations

  • The examples illustrate mean-square error --MSE-- performances, only (other features like customization or regularization or constraints are ignored: see chapters 5 and ff in MDFA). 
  • The criterion in these examples relies on the (non-parametric) Discrete Fourier Transform -- DFT --. Replication and extension of classic model-based approaches (chapter 9 in MDFA) are ignored, here. 

R-Code

  • Download the following two R-files: 
    • MDFA_Legacy_MSE.r: this is the main R-code. It requires some R-libraries to be installed (the MDFA-package, among others, see below) and needs a path to the second file (which is then sourced).
    • control_default.r: this second file configures parameters of MDFA for ordinary MSE estimation (all other features of MDFA are ignored). Instead of setting (MSE-) parameters the user could rely on dedicated (MSE-)functions which are illustrated in the above code, too: dedicated functions are integral part of the MDFA-package (they preset certain parameters which condition the generic MDFA in view of particular application fields).
  • Installation
    • Download both files
    • Install the libraries (external R-packages) as required by MDFA_Legacy_MSE.r (see also below for a corresponding list)
    • Set the path (variable path.pgm in MDFA_Legacy_MSE.r) in order to be able to source control_default.r (this file is sourced via the command source(file=paste(path.pgm,"control_default.r",sep="") in the larger file)
    • Run the (multiple) examples in  MDFA_Legacy_MSE.r (sweave automatically annotates the code chunks which are displayed in the book, too).
In short: the libraries hereunder (the lines are copy-pasted from MDFA_Legacy_MSE.r) are required and the variable path.pgm must be set in order to be able to source the second file...



###################################################
### code chunk number 2: init
###################################################
# Load packages: time series and xts
#library(tseries)
library(xts)
# Library for tables
library(Hmisc)
require(xtable)
#install.packages("devtools")
library(devtools)
# Load MDFA package from github
devtools::install_github("wiaidp/MDFA")
# MDFA package
library(MDFA)

path.pgm <- paste(getwd(),"/",sep="")


Guidance

  • Navigate through the various code-chunks in  MDFA_Legacy_MSE.r sequentially, from top to bottom (later code might need variables that are initialized/defined earlier on). 
  • For reference, the chunks are displayed in the MSE-chapter in MDFA (chapter 4). All results (performance numbers, figures, tables) should be readily replicable.   
Background is provided in understanding-mdfa-package-step-by-step.

Comments

Popular posts from this blog

What is a 'Direct Filter Approach'?