R具有时间序列数据的探索性数据分析
示例
data(AirPassengers) class(AirPassengers)
1“ts”
本着探索性数据分析(EDA)的精神,良好的第一步是查看时间序列数据的图表:
plot(AirPassengers) # plot the raw data abline(reg=lm(AirPassengers~time(AirPassengers))) # fit a trend line
对于进一步的EDA,我们检查了多年的周期:
cycle(AirPassengers)
Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec 1949 1 2 3 4 5 6 7 8 9 10 11 12 1950 1 2 3 4 5 6 7 8 9 10 11 12 1951 1 2 3 4 5 6 7 8 9 10 11 12 1952 1 2 3 4 5 6 7 8 9 10 11 12 1953 1 2 3 4 5 6 7 8 9 10 11 12 1954 1 2 3 4 5 6 7 8 9 10 11 12 1955 1 2 3 4 5 6 7 8 9 10 11 12 1956 1 2 3 4 5 6 7 8 9 10 11 12 1957 1 2 3 4 5 6 7 8 9 10 11 12 1958 1 2 3 4 5 6 7 8 9 10 11 12 1959 1 2 3 4 5 6 7 8 9 10 11 12 1960 1 2 3 4 5 6 7 8 9 10 11 12
boxplot(AirPassengers~cycle(AirPassengers)) #Box plot across months to explore seasonal effects