Seasonality

In the next example, we will show you auto-correlation. First, we upload an R package called astsa, which stands for Applied Statistical Time Series Analysis. Then, we upload the US GDP with quarterly frequency:

library(astsa)path<-"http://canisius.edu/~yany/RData/"dataSet<-"usGDPquarterly"con<-paste(path,dataSet,".RData",sep='')load(url(con))x<-.usGDPquarterly$DATEy<-.usGDPquarterly$GDP_CURRENTplot(x,y)diff4 = diff(y,4)acf2(diff4,24)

In the preceding program, the diff() function takes a difference, such as the current value minus the previous value. The second input value indicates the lag. The function called acf2() is used to plot and print the ACF and PACF of a time series. ACF stands for auto-covariance function, while PACF ...

Get Hands-On Data Science with Anaconda now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.