问题:使用周期图和FFT在R.日常数据检测循环模式
问题是如何在R代码里面的周期图检测数据月度,季度,半年度,annual..etc循环模式。 换句话说,我需要检测为低频率周期性图案的存在(即:11个月=> 2 * PI / 365,6个月=> 4 * PI / 365等)
再现的实施例:
library(weatherData)
w2009=getWeatherForYear("sfo",2009)
w2010=getWeatherForYear("sfo",2010)
w2011=getWeatherForYear("sfo",2011)
w2012=getWeatherForYear("sfo",2012)
w2013=getWeatherForYear("sfo",2013)
w2014=getWeatherForYear("sfo",2014)
w=rbind(w2009,w2010); w=rbind(w,w2011); w=rbind(w,w2012)
w=rbind(w,w2013); w=rbind(w,w2014)
# Next we analyze the periodograms
# This is IMAGE 1
TSA::periodogram(w$Max_TemperatureF)
# Next: I dont really know to use this information
GeneCycle::periodogram(w$Max_TemperatureF)
# Next THIS IS IMAGE 2
stats::spectrum(w$Max_TemperatureF)
# I also tried . This is IMAGE 3
f.data <- GeneCycle::periodogram(tmax)
harmonics <- 1:365
plot(f.data$freq[harmonics]*length(tmax),]
f.data$spec[harmonics]/sum(f.data$spec),
xlab="Harmonics (Hz)", ylab="Amplitute Density", type="h")
阅读的答案后,我做的:
per <- TSA::periodogram(w$Max_TemperatureF,lwd = 1)
x <- which(per$freq < 0.01)
plot(x = per$freq[x], y = per$spec[x], type="s")
我的问题是到底有什么意思呢? 我们有一个季节性周期?