**Unformatted text preview:**

What is this all about?Motivating example: Lake Huron dataData/Theory goals of the topicGeneral discussion on classical decompositionEstimating/Removing trends and seasonalityStationary time series modelsFitting AR models and choosing their orderModel diagnosticsForecastingSome final notesMore modern take: ProphetReferencesClassical Decomposition Approach to Univariate Time SeriesVladas Pipiras, STOR @ UNC-CHJanuary 18, 2022What is this all about?Suppose given a univariate time series dataxt,t= 1, . . . , T, wheretrefers to time andTto the samplesize. We would like to have a statistical/probability model{Xt}t∈Zfor the series, whereXt’s are randomvariables. This is reverse engineering of what we did in the previous topic: whereas we started with a modeland generated data from it, we now start with data and would like to fit a model to it. Having a statisticalmodel, we can use it for forecasting (prediction), which is one of the basic tasks of time series analysis.This topic is about a classical approach to time series modeling based on the decomposition (possibly after apreliminary transformation):Xt= mt+ St+ Yt, t ∈ Z,where{mt}t∈Zis a (typically deterministic) model for trend,{St}t∈Zis a (typically deterministic periodic)model for seasonal variations, and {Yt}t∈Zis a stationary time series model.Motivating example: Lake Huron dataAnnual measurements of the level, in feet, of Lake Huron 1875–1972.data(LakeHuron)ts <- LakeHuronts## Time Series:## Start = 1875## End = 1972## Frequency = 1## [1] 580.38 581.86 580.97 580.80 579.79 580.39 580.42 580.82 581.40 581.32## [11] 581.44 581.68 581.17 580.53 580.01 579.91 579.14 579.16 579.55 579.67## [21] 578.44 578.24 579.10 579.09 579.35 578.82 579.32 579.01 579.00 579.80## [31] 579.83 579.72 579.89 580.01 579.37 578.69 578.19 578.67 579.55 578.92## [41] 578.09 579.37 580.13 580.14 579.51 579.24 578.66 578.86 578.05 577.79## [51] 576.75 576.75 577.82 578.64 580.58 579.48 577.38 576.90 576.94 576.24## [61] 576.84 576.85 576.90 577.79 578.18 577.51 577.23 578.42 579.61 579.05## [71] 579.26 579.22 579.38 579.10 577.95 578.12 579.75 580.85 580.41 579.96## [81] 579.61 578.76 578.18 577.21 577.13 579.10 578.25 577.91 576.89 575.96## [91] 576.80 577.68 578.38 578.52 579.74 579.31 579.89 579.96par(mfrow = c(1, 2))plot.ts(ts,ylab = 'Depth in Feet',xlab='Year')lts <- length(ts)plot(y=ts[2:lts],x=ts[1:(lts-1)],ylab = 'Depth in feet',xlab='Previous Depth in Feet')1YearDepth in Feet1880 1920 1960576 577 578 579 580 581 582576 578 580 582576 577 578 579 580 581 582Previous Depth in FeetDepth in feetcor(ts[2:lts],ts[1:(lts-1)])## [1] 0.8388905A possibility is also to remove a linear trend.years <- time(LakeHuron)lm.LakeHuron <- lm(LakeHuron ~ years)summary(lm.LakeHuron)#### Call:## lm(formula = LakeHuron ~ years)#### Residuals:## Min 1Q Median 3Q Max## -2.50997 -0.72726 0.00083 0.74402 2.53565#### Coefficients:## Estimate Std. Error t value Pr(>|t|)## (Intercept) 625.554918 7.764293 80.568 < 2e-16 ***## years -0.024201 0.004036 -5.996 3.55e-08 ***## ---## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1#### Residual standard error: 1.13 on 96 degrees of freedom## Multiple R-squared: 0.2725, Adjusted R-squared: 0.2649## F-statistic: 35.95 on 1 and 96 DF, p-value: 3.545e-08ts2 <- resid(lm.LakeHuron)ts2 <- ts(ts2,start=c(1875),end=c(1972),frequency=1)par(mfrow = c(1, 2))plot(ts2,ylab = 'Feet',xlab='Year')2lts2 <- length(ts2)plot(y=ts2[2:lts2],x=ts2[1:(lts2-1)],ylab = 'Depth in feet',xlab='Previous Depth in Feet')YearFeet1880 1920 1960−2 −1 0 1 2−2 −1 0 1 2−2 −1 0 1 2Previous Depth in FeetDepth in feetcor(ts2[2:lts2],ts2[1:(lts2-1)])## [1] 0.7763291lm.LakeHuron2 <- lm(ts2[2:lts2] ~ ts2[1:(lts2-1)])summary(lm.LakeHuron2)#### Call:## lm(formula = ts2[2:lts2] ~ ts2[1:(lts2 - 1)])#### Residuals:## Min 1Q Median 3Q Max## -1.95881 -0.49932 0.00171 0.41780 1.89561#### Coefficients:## Estimate Std. Error t value Pr(>|t|)## (Intercept) 0.01529 0.07272 0.21 0.834## ts2[1:(lts2 - 1)] 0.79112 0.06590 12.00 <2e-16 ***## ---## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1#### Residual standard error: 0.7161 on 95 degrees of freedom## Multiple R-squared: 0.6027, Adjusted R-squared: 0.5985## F-statistic: 144.1 on 1 and 95 DF, p-value: < 2.2e-16ts3 <- resid(lm.LakeHuron2)par(mfrow = c(1, 2))plot(ts3, type="l")3lts3 <- length(ts3)plot(y=ts3[2:lts3],x=ts3[1:(lts3-1)],ylab = 'ts3 current',xlab='ts3 previous')0 20 40 60 80 100−2 −1 0 1 2Indexts3−2 −1 0 1 2−2 −1 0 1 2ts3 previousts3 currentcor(ts3[2:lts3],ts3[1:(lts3-1)])## [1] 0.2183583Possible conclusion:Use the modelXt=a+φXt−1+ZtorXt=a+bt+YtwithYt=φYt−1+Zt,where Zt’s are uncorrelated across time t?Data/Theory goals of the topicIn fact, after fitting a linear trendXt=a+bt+Yt, we will choose the modelYt=φ1Yt−1+φ2Yt−2+Ztforthe residuals and use it in forecasting to arrive at the following forecasting plot:4Timets1880 1900 1920 1940 1960 1980576 577 578 579 580 581 582Forecasts for the time seriesBy the end of the topic, you should understand how the model is fitted and where such a forecasting plotcomes from. On the way, a number of important notions of time series analysis, such as stationarity, somestationary models, ACF, partial ACF, and others, will also be introduced and discussed.Note:The material of this topic is most important. For example, it lays foundation for whatever will bedone later in the course. Even when dealing with multivariate or high-dimensional or . . . time series, theunivariate series modeling based on the introduced models is always the baseline that is to be improved upon.General discussion on classical decompositionEstimating/Removing trends and seasonalitySeveral methods:• Fitting a curve (e.g. a linear trend)• Moving average/Filtering (smoothing)• Differencing (later)Fitting a curve: In absence of seasonality, one could use least squares to fit a linear trendmt= a + btor a quadratic trendmt= a + bt + ct2or . . . In absence of trend, one could use least squares to fit a seasonal (periodic) modelSt= a0+Xj(ajcos(λjt) + bjsin(λjt)), λj=2πjswith periods, where the sumPjcould be overj= 1, . . . , K, or selectivej(like “harmonics”). Use acombination when both trend and seasonality are present.Example: US accidental deaths, 1973-19785library(itsmr)y1 = hr(deaths,12)y2 = hr(deaths,c(12,6,3))par(mfrow = c(1, 2))plotc(deaths,y1)plotc(deaths,y2)0 20 40 607000 8000 9000 100000 20 40 607000 8000 9000 10000Moving

View Full Document