Contents Previous Next examples

STSA Toolbox Examples

Examples
The EXAMPLES sub-directory of your STSA, The Statistical Time Series Analysis Toolbox , installation contains numerous examples of using the STSA toolbox functions for real-world time series applications. To run a specific example change your working directory to the location of the example file and then include the example script, For example, if you have chosen the default locations for O-Matrix and STSA during installation and at the O-Matrix prompt you enter
     cwd("\omwin\stsa\examples")
     include example01.oms
the first example in the following table will be run. Alternatively, you can select "File | Run Program" from the O-Matrix main menu and then browse to the example file of interest.

The STSA Examples link on the Harmonic Software home page presents several of these examples including output.

Application Examples
The examples in this table provide real-world illustrations of using the STSA toolbox functions for simulated and empirical data.
ar+noise.oms - Estimating and forecasting a state space model with an AR(1) state equation and additive Gaussian noise, using the ltikf STSA function and both methods of numerical optimization BHHH and Newton-Raphson with BFGS update
example01.oms - Simulate a stationary, zero mean Gaussian autoregressive model of order 2 and perform various operations on the resulting realization
example02.oms - Simulate a nonlinear (exponential) trend with Gaussian MA innovations and illustrate how one can use the functions gauss_newton and bhhh_ml with a user-specified function for optimization and estimation of a model's parameters
example03.oms - In this example we use two real economic time series to illustrate the estimation and forecasting of a dynamic transfer function, a vector autoregressive model. Then, we show how to compare the forecasting performance of various models using a training-validation sample approach
example04.oms - Illustrate the simulation and estimation of nonlinear time series models
example05.oms - Briefly illustrate the STSA functions for exponential and simple smoothing of a time series
example06.oms - Illustrate the simulation, fitting and forecasting based on Bayesian first order polynomial DLM (dynamic linear model). This is a class of simple, yet powerful models for short-term forecasting. The example also illustrates how to generate prediction intervals (bands) that are frequently much more useful than point forecasts.
example07.oms - Replicate some results found in the book Bayesian Forecasting and Dynamic Models by Harrison and West (1997, Springer-Verlag)
example08.oms - The workhorse functions of the BAYES directory are reference_tsDLM and fit_tsDLM which allow the user to develop a wide range of DLMs and the use of reference priors that simplify the analysis. In addition, we provide for a number of functions that allow for the automatic specification of the trend and seasonal components of a DLM model.
example09.oms - Illustrate the differences between the two available kernels for nonparametric estimation and forecasting. Then, we illustrate the differences in the fit between a linear and a nonparametric regression when the true model is nonlinear but unknown.
example10.oms - Illustrate the simulation and estimation of time series that exhibit long memory, that is slowly decaying correlations of small magnitude (contrast this to non-stationary where the correlations are slowly decaying but are large in magnitude). Time series like these are frequently encountered in diverse fields and the STSA toolbox provides a number of functions that can handle the modeling of such series.
example11.oms - Illustrate the simulation, estimation and forecasting of ARFIMA-type models. This class of models extends traditional, short-memory ARMA models, to incorporate the effects of long-memory. In the example, we illustrate how to use the arfima_estimate and arfima_forecast STSA functions and we compare the forecasting performance of ARFIMA forecasts vs. forecasts generated by a linear AR model.
example12.oms - Illustrate the functions in the RNG directory; we generate random numbers using the inverse distribution function method and we then test whether the resulting data indeed appear to come from their generating distributions
expdecay.oms - Simulate and estimate the fit of an exponential decay model with y-offset of the form y = A*exp(B*x) + C + error
flu.oms - Analysis of the flu data in Shumway and Stoffer, Time Series Analysis and its Applications, published by Springer-Verlag.
gnp.oms - Analysis of the GNP data in Shumway and Stoffer, Time Series Analysis and its Applications, published by Springer-Verlag
jj.oms - Analysis of the Johnson & Johnson data in Shumway and Stoffer, Time Series Analysis and its Applications, published by Springer-Verlag
nonpar_example01.oms - Nonparametric estimation of the density and empirical distribution for a time series. 2 data series: (1) simulated data and (2) the quarterly growth rate of the US Gross National Product For the second series we specifically have the Real Gross National Product, USA, quarterly 1947-Q1 to 2006-Q2, FRED database series GNPC96 Federal Reserve Bank of Saint Louis online database http://research.stlouisfed.org/fred2/, in billions of chained 2000 dollars
nonpar_example02.oms - Nonparametric smoothing and extrapolation. 1 data series: daily closing price of General Electric from 1/02/2003 to 1/17/2006
nonpar_example03.oms - Various nonparametric autoregression methods, cross-validation and forecasting. 3 data series: (1) simulated data (2) Canadian Lynx data and (3) US interest rate data. The Canadian lynx data are documented in the reference book. The US interest rate data are 3 month treasure bill rates, USA, monthly from 01/1970 to 09/2006, FRED database series TB3MS, Federal Reserve Bank of Saint Louis online database at http://research.stlouisfed.org/fred2/
nonpar_example04.oms - Various nonparametric autoregression methods using simulated data, including a partially linear model.
optimization.oms - Illustrate the use of the quasi-newton optimization algorithm for solving minimization problems. The test functions are adopted from the book Optimization: Foundations and Applications, by Ronald E. Miller, Wiley Interscience.
pod_example01.oms - Constructing the trajectory matrix, applying SVD decomposition and reconstruction of trend and seasonal. Dataset: "unemployment" series of reference book (pp. 29, 30 and 31)
pod_example02.oms - Constructing the trajectory matrix, applying SVD decomposition, reconstruction and forecasting. Dataset: Monthly US Imports from China, Jan-1990 to June-2006, FRED database series IMPCH Federal Reserve Bank of Saint Louis online database http://research.stlouisfed.org/fred2/
pod_example03.oms - Constructing the trajectory matrix, applying SVD decomposition, reconstruction and forecasting. Dataset: Real Gross National Product, USA, quarterly 1947-Q1 to 2006-Q2, FRED database series GNPC96 Federal Reserve Bank of Saint Louis online database http://research.stlouisfed.org/fred2/
soi_recruit.oms - Analysis of the SOI and Recruitment data in Shumway and Stoffer, Time Series Analysis and its Applications, published by Springer-Verlag
stsa04.oms - Illustrate the use of the Holt-Winters method for forecasting
varve.oms - Analysis of the glacial varve data in Shumway and Stoffer, Time Series Analysis and its Applications, published by Springer-Verlag

Function Examples
The examples in this table provide concise usage illustrations for many of the STSA functions.
stsa01.oms - Demonstrates the functions: acfplot, ar_order, arma_to_ma, arma_roots, arma_simulate, ar_yw, descriptives, Gaussianity_Ftest, print_acf_summary, qstat, regress, and seqlags
stsa02.oms - Demonstrates the functions: acfplot, ar_order, arma_details, arma_estimate, arma_noise, arma_residual_diagnostics, arma_simulate ar_yw, boxplot, descriptives, gauss_newton, Gaussianity_ADtest, and Gaussianity_CVMtest
stsa03.oms - Demonstrates the functions: acvf_spectrum, ar_order, ar_spectrum, arma_simulate, plot_spectrum, and spectrum
stsa05.oms - Illustrate the use of the updated qqplot function
logistic.oms - Illustrate the use of the logistic_regression function