by
Prepared for use
with Copyright (c)
2006-2007 by Rafał Weron
Part I: The Toolbox 1. Installation Part II: Case Studies 4. Distributions (Case Study 2.6.3)
The MFE Toolbox functions are written in MATLAB 7.0, and should therefore work in that or any later version of MATLAB. Most of the functions have been also tested in MATLAB 6.5. Note, that some of the results may differ from those presented in the book if a later version of MATLAB is used. To install the software, you should copy the MFE Toolbox folder as a folder in your MATLAB 'works' folder, and then activate the path to this new folder so that MATLAB knows it is there. Most of the functions should work if you have the Garch and System Identification Toolboxes in additional to the basic MATLAB package; however, a small number draw on functions in other MATLAB Toolboxes (e.g., the Statistics Toolbox) and will only work if the relevant other MATLAB Toolbox is installed.
MATLAB functions or scripts (i.e. series of MATLAB commands) can be run from the MATLAB command line, which is given by the prompt '>>' in the MATLAB Command Window, i.e.: >> Scripts can be executed by simply typing in the relevant file name in the command line. For example, if you wish to run Case Study 4.4.5 demo script, you can do so by typing in the following command: >> mfe_regime Functions, on the other hand, generally require input parameters. Care must be taken to ensure that the input data is in appropriate form. To check data format requirements type '>> help <function name>' at the command line. For instance, to see the help screen of the 'remst.m' function type in the following command: >> help remst In return MATLAB will display: REMST
Remove seasonal component and trend.
>>
x=sin((1:100)'*pi/2)+rand(100,1)/10; The MFE Toolbox v. 1.0 consists of 58 functions, scripts and data files. Many functions include internally used routines, hence, the total number of functions is much larger. The files are grouped into seven categories: 1. Time
series, The **armaacvf**- Autocovariance function of an ARMA process.**average**- Weighted average.**decompA**- Differencing-smoothing daily data decomposition.**decompB**- Moving average with rolling volatility daily data decomposition.**logret**- Logarithmic returns.**mainfcoeff**- Coefficients of a MA(inf) process corresponding to ARMA(p,q).**periodog**- Periodogram of a time series.**remmed**- Remove mean- or median-based seasonal component.**remsin**- Remove annual sinusoidal component and trend from daily data.**remst**- Remove seasonal component and trend.**rollingvol**- Annual rolling volatility.**volaplot**- Volatility plot.
The **empcdf**- Empirical cumulative distribution function (cdf).**hypcdf**- Hyperbolic cumulative distribution function (cdf).**hypest**- Estimate parameters of the hyperbolic distribution.**hyploglik**- Hyperbolic log-likelihood function.**hyppdf**- Hyperbolic probability density function (pdf).**nigcdf**- NIG cumulative distribution function (cdf).**nigest**- Estimate parameters of the NIG distribution.**nigloglik**- NIG log-likelihood function.**nigpdf**- NIG probability density function (pdf).**stabcdf**- (Alpha-)stable cumulative distribution function (cdf).**stabcull**- Quantile parameter estimates of a stable distribution.**stabreg**- Regression parameter estimates of a stable distribution.
The **edftests**- Empirical distribution function (edf) goodness-of-fit statistics (Kolmogorov and Anderson-Darling).**ferrors**- Compute price forecast errors (including MDE, MeDE and DRMSE).
The **mrs_est**- Estimate 2-state (Markov) regime switching model.**mrs_plot**- Plot calibration results for a 2-state MRS model.**mrs_sim**- Simulate trajectories of a 2-state (Markov) regime switching model.
The **onlyone**- Sets only one active radiobutton.**readf**- Read files and folders from the current directory.
The **mfe_distrib**- GUI illustrating Case Study 2.6.3.
*Auxiliary routine(s)*:**mfe_distrib_aux**
**mfe_loadf**- GUI illustrating Case Studies 3.4.7 and 3.4.10.
*Auxiliary routine(s)*:**mfe_loadf_block**,**mfe_loadf_crit**,**mfe_loadf_errtables**,**mfe_loadf_model_arma**,**mfe_loadf_plotacf**,**mfe_loadf_plotcomp**,**mfe_loadf_plotperiodogram**,**mfe_loadf_predA**,**mfe_loadf_predB**
**mfe_pricef**- GUI illustrating Case Studies 4.3.7, 4.3.8 and 4.3.11.
*Auxiliary routine(s)*:**mfe_pricef_errtables**,**mfe_pricef_plots**,**mfe_pricef_win_arx**,**mfe_pricef_win_arxg**,**mfe_pricef_win_tarx**,**startarx**,**startgarch**,**starttarx**
**mfe_regime**- Script illustrating Case Study 4.4.5.
Finally,
the **CA_daily.dat**- daily electricity prices, loads, forecasted loads and max air temperatures from California (1998.04.01-2002.12.31).**CA_hourly.dat**- hourly electricity prices, loads and forecasted loads from California (1998.04.01-2001.01.31).**EEX_daily_des.dat**- deseasonalized (with respect to the weekly cycle) EEX daily price (Phelix Base index, 2002.01.01-2004.12.31).**NP_daily_des.dat**- logarithm of the deseasonalized with respect to the weekly and annual cycles average daily Nord Pool system price (1997.01.03-2000.04.27).
To open GUI illustrating Case Study 2.6.3 type in the following command: >> mfe_distrib In return MATLAB will display the main window. After selecting the data file (use daily data; note, that the second column is used only) and pressing the 'Open/Load' button all objects will become active. To preprocess the data by removing the 7-day cycle with the moving average technique (remst.m) tick the 'remove 7-day cycle' checkbox. To transform it further by taking first differences ('diff') or log-returns ('diff') select the appropriate radiobutton. Next, choose which of the four distributions (Gaussian, hyperbolic, NIG, alpha-stable) will be fitted to the data and whether EDF test statistics (Kolmogorov and Anderson-Darling) will be computed. Finally, press the 'Run' button. The results will be displayed in the command window and visualized in 3-4 figures:
Finally, the bottom box allows for performing day-ahead forecasts of the 2001-2002 California system-wide load. 'AR', 'MA' and 'X order' edit boxes define orders p, q and r, respectively, of an ARMAX(p,q,r) model. Values of the exogenous variable (max air temperature) for days T-'X shift', T-'X shift'-1, ... are used to forecast load for day T. Afterwards a summary of the forecasting performance is displayed in the command window (MATLAB's format is used, i.e. ARMAX[p r q 'X shift']):
During the estimation/forecasting process, current status (forecast n out of N forecasts) is displayed in the command window. Afterwards a summary of the forecasting performance is displayed in two tables - one with daily errors (MDE, MeDE) and one with weekly errors (MWE, MeWE, WRMSE) for full weeks in the forecasting period: Additionally the results are visualized in two figures - one with point and interval (here: 90% and 95% two-sided non-parametric) forecasts and one with deviations of point and interval forecasts from the actual market price: Finally, the
forecasting results are saved in an ASCII file - date,
- hour,
- actual price,
- price forecast,
- capped price forecast,
- [{lcl_gauss ucl_gauss, lcl_npar ucl_npar} price_capped{lcl_gauss ucl_gauss, lcl_npar ucl_npar}] as many times as there are confidence levels (but no more than 3),
where lcl stands for 'lower confidence level' and ucl for 'upper confidence level'.
To run the script illustrating Case Study 4.4.5 type in the following command: >> mfe_regime It loads Nord Pool
deseasonalized log-prices ( - Gaussian random variable,
- lognormal random variable,
- Pareto random variable,
- mean reverting process (like for the base regime).
The obtained estimates are displayed in the command window: and visualized, here for Pareto (left) and mean-reverting (right) models: In the bottom panels the probability Pr(spike) that an observation comes from the spike regime is plotted. In the top panels the time series is displayed with observations identified as belonging to the spike regime (i.e. having Pr(spike)>0.5) plotted in red. The toolbox also allows for
calibration of a MRS model with Weibull distributed
spikes. To see the results change 'G' to 'W' in [Ksi_tT,
Param, P, Ksi_t1t_10, LogL] = mrs_est(Data, 'G').
However, with the Nord Pool dataset the estimates do not
converge. For simulation of MRS models see Last modified on |