24.7 Spectral analysis

numbers <- read.table("c:\\temp\\lynx.txt",header=T)
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:


Y <- rnorm(250,0,2)
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="")



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值