attach(numbers)
names(numbers)
plot.ts(Lynx)
The fundamental tool of spectral analysis is the periodogram. This is based on the squared correlation
between the time series and sine/cosine waves of frequency ω, and conveys exactly the same information as
the autocovariance function. It may (or may not) make the information easier to interpret. Using the function
is straightforward; we employ the spectrum function like this:
spectrum(Lynx,main="",col="red")
twoseries <- read.table("c:\\temp\\twoseries.txt",header=T)
attach(twoseries)
names(twoseries)
plot.ts(cbind(x,y),main="")
par(mfrow=c(2,2))
acf(cbind(x,y),type="p",col="red")
24.9 Simulated time series
We begin with the special case of α = 0 so that Yt = Zt and the process is pure white noise:
windows(7,4)
par(mfrow=c(1,2))
plot.ts(Y)
acf(Y,main="")
To generate the time series for non-zero values of α we need to use recursion: this year’s population is last
year’s population times α plus the white noise. We begin with a negative value of α = –0.5. First we generate
all the noise values (by definition, these do not depend on population size):
Z <- rnorm(250,0,2)
Y <- numeric(250)
Y[1] <- Z[1]
for (i in 2:250) Y[i] <- -0.5*Y[i-1]+Z[i]
plot.ts(Y)
acf(Y,main="")
Z <- rnorm(250,0,2)
Y[1] <- Z[1]
for (i in 2:250) Y[i] <- 0.5*Y[i-1]+Z[i]
plot.ts(Y)
acf(Y, main="")
Z <- rnorm(250,0,2)
Y[1] <- Z[1]
for (i in 2:250) Y[i] <- Y[i-1]+Z[i]
plot.ts(Y)
acf(Y, main="")