## Description

We have met the spectral density function, f (ω), of a stochastic process, and the periodogram,

I (ω), which can estimate the spectral density function given a sample from the stochastic process.

In effect, the periodogram is a histogram, created in R using the command spec.pgram. By

default this command plots the periodogram on the log scale, the option log=”no” allowing for

direct comparisons. R uses ω/2π as frequency (per unit time), so the horizontal axis in the plot of

the periodogram ranges from 0 to 0.5 rather than 0 to π.

Moreover, as an estimate of the spectral

density, the periodogram from R should be divided by π to be consistent with definitions we have

provided. In what follows though it is the shape of the periodogram that is of most interest.

We have seen that the periodogram is in general not a consistent estimator of f (ω). We need

to modify the (raw) periodogram to make it consistent. One approach to this is to smooth the

periodogram, applying a moving average filter.

This can be performed within spec.pgram via

the argument spans. For instance, spans=c(m) applies a smoothing filter of length m to the

periodogram values. Filters can be applied in sequence: spans=c(m,n) applies two smoothers in

turn, of length m and n, respectively.

In the following, suppose that {Zt}t∈Z is white noise with mean zero and variance 4.

1. Here we will compare the spectral density of white noise with smoothed periodograms

obtained from simulated white noise samples.

(a) Use the arima.sim command, or otherwise, to simulate a series of length 100 from

{Zt}t∈Z. Use spec.pgram to create and plot the periodogram for your sample. Now

smooth your periodogram by smoothing with spans (i) c(5), (ii) c(15), (iii) c(7,5).

Comment on what you observe, comparing the periodogram with the spectral density

function.

(b) Use the arima.sim command, or otherwise, to simulate a series of length 1000 from

{Zt}t∈Z. Use spec.pgram to create and plot the periodogram for your sample. Now

smooth your periodogram by smoothing with spans (i) c(5), (ii) c(15), (iii) c(7,5).

Comment on what you observe.

(c) In terms of the shape at least, it should make no difference here whether we take

logs of the periodogram of the data from (b). Play around with various choices of (i)

taking logs or not and (ii) the spans argument, looking at no less than four special

cases. Which choice was “best”, and why?

(d) Suppose we know that the relationship between the periodogram I (ω) and the spectrum f (ω) is

2I (ω)

f (ω)

∼ χ

2

2

.

Think about taking logs of the above relationship. In terms of the difference between

the estimator, I (ω), and the expected value, f (ω), what impact does taking logs have

on the error between the two? Is this consistent with your investigations in (c)?

2. Let {Xt}t∈Z be defined by

Xt = Zt − 0.9Zt−1.

Recall that the spectral density function for {Xt}t∈Z is

f (ω) = 7.24

π

1 −

1.8 cos (ω)

1.81

, ω ∈ (0, π).

Remind yourself how this function behaves over (0, π).

(a) Use the arima.sim command to simulate a series of length 100 from {Xt}t∈Z. Use

spec.pgram to create and plot the periodogram for your sample. Now smooth your

periodogram by smoothing with spans (i) c(5), (ii) c(15), (iii) c(7,5). Comment

on what you observe.

(b) Working upwards from the choice of integers in (ii) and (iii) above, find (if you can!)

both single and double smoothers that give periodograms very close to the actual

spectrum.

(c) Use the arima.sim command to simulate a series of length 1000 from {Xt}t∈Z. Use

spec.pgram to create and plot the periodogram for your sample. Now smooth your

periodogram by smoothing with spans (i) c(5), (ii) c(15), (iii) c(7,5). Comment

on what you observe.

(d) Working upwards from the choice of integers in (ii) and (iii) above, find (if you can!)

both single and double smoothers that give periodograms very close to the actual

spectrum. Comment on your results.