【发布时间】:2016-01-19 22:30:09
【问题描述】:
目标是绘制两个时间序列之间的相干性(即相对于频率的相关系数)。如何让 x 轴上的 1/freq(即周期)均匀分布?
t <- 0:99
ts1 <- ts(2*cos((2*pi)/24*t))
ts2 <- ts(2*cos((2*pi)/48*t))
ts12 <- ts.intersect(ts1, ts2)
Coh <- spec.pgram(ts12, spans=3)
plot(Coh$freq, Coh$coh, type='l')
plot(1/Coh$freq, Coh$coh, type='l') # how to get 1/freq to be evenly-space?
我试图修改函数 spec.pgram() 但没有成功。更具体地说,我替换了以下行:
freq <- seq.int(from = xfreq/N, by = xfreq/N, length.out = Nspec)
与:
freq.tmp <- seq.int(from = xfreq/N, by = xfreq/N, length.out = Nspec)
freq <- rev(1/seq(from=1/max(freq.tmp), to=1/min(freq.tmp), length.out=Nspec))
还有其他人的运气更好吗?谢谢
【问题讨论】: