**Useful Stand-Alone R Programs** for

Applied Time Series Analysis

Wayne A. Woodward, *Southern Methodist University, Dallas, Texas, USA*; Henry L. Gray, *Southern Methodist University, Dallas, Texas, USA*; Alan Elliott, *University of Texas Southwestern Medical Center at Dallas, USA*

In the following we discuss some useful stand-alone R programs that are provided on this website. Most of the figures and examples in Chapters 1-11 involve capabilities of the GW-WINKS program. The figures in these chapters were created by R, but in most cases the realizations, spectral estimates, autocorrelations, etc. were obtained using GW-WINKS. Although GW-WINKS can create plots, for purposes of consistency we created all files using either R (or S+). In the following we give examples of the R code that is used to create some of these plots. In the R code, we assume that the data are read from and plots are written to the subdirectory c:\ATSA.

**1. Plotting figures such as Figure 1.18
**Several figures throughout the book include a realization centered above a row containing plots of the autocorrelations and spectral quantities (either sample or true values). See for example Figure 1.18. R code used to create these plots can be found in

__Figure1.18.R__. Two R programs are provided, one for the case in which the data are read from .txt files and one in which the data are in a .csv file (which can be created either from GW-WINKS or Excel).

**2. Plotting the periodogram.**

Figure 1.16 shown below contains plots of the periodogram. The R code for creating Figure 1.16 is given in in

__Figure1.16.R__.

**3. Long memory model calculations**

R programs for long memory models discussed in Chapter 11 are available at the following links:

- Calculate true autocorrelations at
__trueacv.R__ - Generate realizations (both Fractional/FARMA and Gegenbauer/GARMA) at
__simulations.R__ - Estimate parameters at
__GARMA parm est.R__ - Calculate and plot forecasts at
__forecast and plot.R__

**4. Wavelet analysis**

We have used R and S+ to perform the wavelet analyses given in Chapter 12. CRAN contains several wavelet packages. We have used the functions available in Waveslim for several of the examples. Also, we used the Wavelet module in S+. The R and S+ code required to produce the wavelet-related results and figures in Chapter 12 are available at __Chapter12.R__.

**5. Wigner-Ville plots and plots of the Gabor spectrum**

Wigner-Ville plots, such as Figure 12.3(c) and (d), of the time-varying frequency behavior were discussed in Chapter 12, and an R function for plotting a Wigner-Ville plot can be found at __wvR.R__. Plots of the Gabor spectrum, such as Figure 12.3(a) and (b), were obtained in R using the function cgt in the package Rwave available in CRAN. Code for obtaining Figure 12.3, and most of the figures in Chapter 12, are available at __Chapter12.R__.

More information from publisher