Time Series Analysis and Its Applications: With R Examples

Second Edition

This is the site for the second edition of the text and is no longer maintained.

Follow this link if you're looking for the site of the 4th edition
.

Code for Chapter 7 Examples

The examples in Chapter 7 were done, for the most part, using Matlab. If you don't own Matlab, you can obtain "free versions" by following this link to Matlab Clones. If we have converted code to R, we will also distribute that here, but if it's not here it hasn't been done. At this time, only the code for the spectral envelope is R code.

Some of the Matlab programs below use FDR.m and fprob.m so you might as well get them... they're small.

§7.3 - Spectral ANOVA [Matlab]


§7.4 - Deterministic Inputs [Matlab]


§7.5 - Random Regression [Matlab]


§7.6 - Designed Experiments [Matlab]


§7.7 - Discrimation & Cluster Analysis [Matlab]


§7.9 - The Spectral Envelope [R]

First, download and source mvspec.R, which is spec.pgram with a few changes in the defaults:

function(x, spans = NULL, kernel = NULL, taper = 0, pad = 0, 
    fast = TRUE, demean = TRUE, detrend = FALSE, plot = FALSE, 
    na.action = na.fail,...)
and written so you can extract the estimate of the multivariate spectral matrix as fxx. For example, if x contains a p-variate time series (i.e., the p columns of x are time series), and you issue the command spec = mvspec(x, spans=3), then spec$fxx is an array with dimensions dim=c(p,p,nfreq), where nfreq is the number of frequencies used. If you print spec$fxx you'll see nfreq p × p spectral matrix estimates.