3y ago

55 Views

5 Downloads

348.52 KB

6 Pages

Transcription

Detecting Seasonality in Univariate Time Series Data Using the SAS System Joseph Earley and Seid ZekavatLoyola Marymount University, Los AngelesAbstractwith v as the difference operator and Bthe backshift operator:The purpose ofthis paper is to illustrate how todetect seasonality in univariate time series usingthe SAS System. A time series of electricityconsumed by the residential and commercialsectors is examined using the SAS procedures:PROC ARIMA, PROC SPECTRA and PROCXl2.V1 - BV Y,s v,are random tloclrlc A ------------------ 8007006005004003002001r TTTTTT rrrr ,,TT TTTTTTrrrr , JAI70JANDOJANDSJANOSdateIntroductionshocks (errors) assumed to be normally andindependently distributed with mean zero andconstant variance.Following are the ACF, IACF and PACF for theelectricity consumption series.The SAS System offers numerous procedureswhich may be used to detect periodicities intime-series data. The SAS/ETS proceduresPROC ARIMA, PROC SPECTRA and PROCX12 are used to illustrate how to detectperiodicity in the above time-series - the amountof monthly electricity consumed by theresidential and commercial sectors of the UnitedStates, from January, 1973 through November,Autocom:lations!I 8 7 IIUr.-93. 212000.l.OOOUIIUs.ll.:a.H11M.6.379o.tzon10051 1100.78371Univariate Non-Seasonal ARIMAModeling10342.'!10011.79U30.10391' 41.8610.663001011lOCIOf.11712:1!36, 36 o.1ZU6131.1'1!1.1172o.tllllllA univariate ARIMA (p,d,q) model may berepresented :U.808Iu:16n18t (B) z,where: (B)ez, 9 (B) - ,B - - e,e - .(BJa[au20 .,e.!N2l.IIJ41oSs1. ' ' '11111.0:3110422.2689CIU,2!11Y,d 0.11'17611O.IIISUD.6UZ 0.1 011o. '60 60.10!1310.6181821. . ,11,8770.! 758 H0.788343 Z 1 II I 2 3 4 5 6 7 8 !I lt ···················lItu u . I t I t t,. uu,,. .,.1············--··-,,. . .jUOOOUUHH.1. .I················Inverse Autocom:lationsis a constantV Y,0.13211 dDI76543Zllllll34!1oli18 l0 u 1.O.IH! 8 1.,.-11.00121.d 0""'"""""558.-o.auno.toesa-o.o 0.051: 10.1111119 II.OH.'ffiO.OllH 0.0 1Zll00.2 83.n.Jt.fil9O.UHOo.o.un0.11129 -0.011!16. t.'. ,,. 1*.,. '.,IIIII

11181!1o.OSU4-o.Ol!:tll0,11'51l/.ll20-o,' )6(13.O,O.U!t1d zo.oo94123 0.0 0612t 0,0011!1has been overdifferenced, the IACF will appear asan ACF for a nonstationary series. Finally, thepartial autocorrelation function measures thecorrelation between time series observations punits apart after controlling for the correlation oreffects of the intervening observations atintermediate lags. Essentially, the PACF allows usto smmnarize the effects of all the infotmation inthe ACF in a small number of parameters. Likethe ACF plot, the PACF plot also shows dotsindicating confidence intervals at each lag p usedto evaluate the null hypothesis that the model is apure AR process of p-1 order.'. '. '.'.Partial Autoeorrelations10.!1 11212l4 O.tlUls t u uu 1 ,. ,. u.o. nuo. u s 0,078 !1'OJuCl.liSIIZ!I0.20MlO,,Jl!)OO0.22114-o.msz . us.nu.u.-o.oo.nll'r O,U60'rtiuu.oJtill41t:.!0O,OUI!i21!11n. '.'., . ,.0.01.,2 0.03236. ,. ,. ,'. . . .o.U281Su.lun!lO,OO!il .uEstimation of the Parameter s 1".o,o111oo22U1. ,.""I. ,,,. .,, . ,. ,'.0.212!.8101112I lh.0,3,11Based on the results from the identification of themodel, the ESTIMATE statement is then used tofit the appropriate model. SAS uses an iterativeprocess to estimate model parameters. There arethree methods available: conditional least squares(CLS), unconditional least squares (ULS),maximum likelihood (MI.), with CLS being thedefault See the SASIETS User's Guide for moredetails on the methods. It is generally thought thatwith a sufficiently long time series and anappropriate model specification, all methods yieldnearly the same results. Observing theautocorrelation check for white noise, sometimesreferred to as Q statistics, we determine whether ornot the null hypothesis of white noise cau berejected. This statistic is a chi-square type statisticusing the Ljung and Box form. Each row gives thevalue of the Q statistic up to the appropriatenumber of lags. Simply observing the p-values forthe Q statistic indicates whether or not to reject thenull hypothesis of white noise for lags up to thatnumber. '.0,06.131 Autocorrelation Check for White Noise'r oChi-Pt ;;L& JS'i'Wr O.ISQ:6UU.6!1.:.0001o.noo,7Uo.tuo.no o.l! .!l12 bl.U7Sfol .n8 .00010,1 8D,1WO.MilU,l.il2 .0001u.8180.61 0,641O.U30.120463 . .uuuto.U!Io.l!iU18uAutocorrelation .ao.1o'o,101o.!t16o.uoo.n O.UO0.1 1o.1nIdentification of the type of time series process isdone by examining the ACF, IACF and PACFfunctions. In order to identify the appropriateArima model for a time series, the first step is torun the PROC ARIMA procedure with theIDENTIFY statement This yields three importantstatistical functions which are integral to theselection of the proper model These functions arethe ACF, autocorrelation function, IACF, inverseautocorrelation function, and the PACF, partialautocorrelation function. A visual examination ofthese plotted functions gives us a preliminary ideaas to the best fitting model The autocorrelationfunction is a plotted diagram varying from -1.0 to1.0 on the horizontal axis and 0 to 24 (the default)on the vertical axis. It measures theautocorrelation (correlation of the series withitself) at successive lags. The dotted lines indicateconfidence limits which are two standard errors forthe sample autocorrelation at each lag p, derivedfrom the null hypothesis that a pure MA process ofp-1 generated the series. Ifthe asterisks appearoutside the dotted lines, the autocorrelation at thatlag is called a spike. If the autocorrelations afterlag p are not significant, it iS said to cut off or dropoff after lag p. Alternatively, a time series mayshow a pattern in which the autocorrelationsdecline in an exponential pattern. It is then said todecay, dampen, tail off or die down. This patternof decay may also be transcendental such as a sinewave pattern. The inverse autocorrelationfunction is the autocorrelation function of aninverted model. The IACF is generally thought tobe useful in determining whether or not a serieshas been overdifferenced. For example, if a seriesUnivariate Seasonal ARIMA ModelingA univariate time series model which also hascomponents of seasonality may be conciselyexpressed as: (p,d,q)(P,D,Q) transformationIwhere:p is the number of regular autoregressiveparametersd is the number of regular differencesq is the number of regular movingaverage parametersP is the number of seasonal autoregressiveparametersDis the number of seasonal differencesQ is the number of seasonal moving averageparametersS is the level of seasonalitytransformation is type of transformation, if any,used on data559

PROC SPECTRA and SeasonalityModeling a seasonal univariate time seriesinvolves the same distinct steps as for a nonseasonal model, recognizing in addition thatseasonal patterns occur only at the seasonal lags.For example, purely seasonal AR processes willtail off exponen1ially in the ACF while showingspikes at the seasonal lags in the PACF. Likewise,purely seasonal MA model processes will exhibitspikes in the ACF at the seasonal lag whileshowing exponential decay in the PACF. Mixedpurely seasonal models will tail off exponentiaiiyin both the ACF and the PACF. Analysis of theACF, IACF andPACF of the electricityconsumption series indicated that both a regularand a seasonal difference transformation wasnecessary to achieve stationarity. The spikes atlags 1, 2 and 12 in the ACF function indicate thatregular moving average components of lags 1 and2 may be appropriate with a seasonal MAcomponent at lag 12. Examination of the spikesof the PACF indicate that an AR component wasalso necessary. The autocorrelation check forwhite noise indicates that the electricity series isnot white noise. After numerous estimations, thefollowing arima model: (i,1,2)(0,1,1)s lognointercept was found to fit the data well asjudged by an R2 of 0.98.The development of spectral analysis may betraced to the work of Jean Baptiste Joseph Fourier(1768-1830), a French physicist andmathematician. In 1822 Fomierpublished TheorieAnalytique de Ia Chaleur, in which he showed thatany periodic fimction could be modeled by atrigonometric function of sine and cosinecomponents. Spectral analysis allows theresearcher to detect the existence of periodicity ina time series. A straightforward way to determinewhether or not a series has a periodic component isto plot the periodogram or spectral density of theseries onto either the period or the frequency. Asignificant ordinate value at the period orfrequency iPdicates the numerical value of thatperiodic element In addition to other output, theSPECI'RA procedure outputs estimates of thespectral and cross-spectral densities of multipletime series. These estimates are produced using afinite Fomier transform, which decomposes theseries into a sum of sine and cosine waves ofvarying amplitudes and wavelengths. The Fomiertransform for the series X. may be written as:mX. stimate0.695510.169050.687860.41S70 .13663cosine coefficientssine coefficientsmt Fomier :frequencies ( 2xk/n)m number of frequencies in Fourierdecompositionbt.In a general sense, PROC SPECI'RA regressesthe time series under analysis onto the sine andcosine variates for frequencies varying from 0 to 1tby small increments. The plotted periodogram orspectral density function is then the sum of squaresof the regression model associated with eachfrequency. Periodicity is then determined by ahigh value for the ordinate of the periodogram orspectral density.The following residual check for the fitted modelshows that the null hypothesis of white noisecannot be rejected.Autocorrelation Check of ResidualsLag612Spectrum of Electricityau-Pr 5qu&n DP 01iSq0.737.3717a. mean termlitStandard ApproxFzror tValue Pr l LagI2.84 0.00480.245080.73 0.466120.231680.04342 15.84 .0001 12I1.71 0.08860.2451620.15307 .89 0.3728Variance Estimate 0.000858Std Error Estimate 0.029293AIC-1354.82SBC-1335.95To E [at cos(mtt) bt. sin(mtt)]AutocorrelationsPROC SPECI'RA was used to estimate theperiodogram of the electricity consumption timeseries. Below are plots of the periodogram versusfrequency and the periodogram versus the period.If the series were white noise, the values of theamplitude periodogram, Jt , will have the sameexpected values. If there is autocorrelation in theseries, each Jk will have a different expected value.In order to test if the series is random, PROCSPECI'RA provides two tests: the Fisher Kappatest and the Bartlett K.olmogorov-Smimov test ofthe null hypothesis of white noise. As shown03918 -0.001 .0.003 . 0.010 -0.043 -0.012 0.01303911 -0,041 '.0.004 .0.031 0.119 0.1) 3 .0.017Model for variable !electricity Periods ofDifferencing: 1,12 No mean term in this model.Autoregressive Factors:Factor 1: 1- 0.4187 B**(1) 0.13663 B**(2)Moving Average Factors:Factor 1: 1- 0.69551 B**(1)- 0.16905 B**(2)Factor 2: 1 - 0.68786 B**(12)560

Periodogr am and Spectral Densitybelow, this series does not in fact appear to berandom, as judged by these tests. Since it iswidely acknowledged that the periodogta m is onlya fair approximation to the true spectrum that it istrying to estimate, the researcher will often use aweighted average of the periodogram ordinates inorder to smooth out the periodogram. Justificationfor this is that adjacent frequencies are highlycorrelated aud the resulting spectral density will beeasier to interpret. Numerous alternatives are usedfor developing the weighting method - selectedaccording to how smooth the spectral density isdesired to be. These weights are often referred toas the spectral window.Empirical Results White Noise Test93.327538Fisher's KappaProb Kappa1.461e-72Bartlett's Kohnogorov-Smirnov0.4969031o.oO.G7- -0641)0.05-0 0.04-41)0.03a.Ul0.02-O.G10.0" .11.050io4o3os'o5o70Period0.08O.G7 .06- 0.05-r-04-0.03a.0.02-The results of applying PROC SPECIRA to theelectricity demand time series are illustratedbelow. The first-difference of the naturallogarithm was calculated in order to achievestationarity. A plot of the difJog attendance isshown. Next, both the periodogram aud thespectral density of dif log attendance are plottedagainst the sonality Detection and PROC X12100 150 200 250jan73 on561The SAS System offers a procedure, PROC X12,which may be used to detect and seasonally adjusteither monthly or quarterly data. The procedurewas originally developed by the U.S. Bureau of theCensus in 1967, and has achieved widespread usefor the seasonal adjustment of government data.The SAS implementation of the X12 procedurenow incoiporates an ARIMA option, which wasdeveloped by researchers at Statistics Canada.The basic idea behind the procedure is that theseries components can be filtered from the originaltime series using a series of symmetrical movingaverage filters. Following the original work ofArthur Burns aud Wesley Clair Mitchell, theseasonal component of the series is treated as noisewhich should be filtered from the series in order toget at the more important trend-cycle componentUsing monthly data, a general outline of the X12procedure would be:1. Use a 12 month centered moving average asan estimate of the trend-cycle component2. Difference the original series aud the centeredmoving average for an estimate of the sum ofthe seasonal aud irregular components.3. Apply a 5 term moving average separately toeach month in order to extract seasonal.5

factors.4. Further smooth the seasonal fuctors andsubtract them to yield an estimate of theirregular components.5. Further smooth the initial estimate of thetrend and re-estimate the seasonals andirregulars.6. Finally, the seasonal adjusted series isobtained by subtracting the final estimate ofthe seasonal from the raw series.Moving Seasonality TestSum ofSquaresBetween Years 227.9792Error1864.345MeanDF SquareF-Va1uc26 8.76843 1.345286 6.518689No evidence of moving seasonality at the fivepercent level.Combined test for the presence of identifiableseasonality:IDENTIFIABLE SEASONAUI'Y PRESENTPROC Xl2 provides numerous parametric andnon-parametric tests for identifiable seasonality.The stable seasonality test is a one-way analysis ofvariance using the seasons - months- as the factor.Large F values indicate that a significant amountof variation in the SI ratios is due to months - i.e.seasonality exists. Technically, the null hypothesisis that there is no effect due to months. Themoving seasonality test is a two-way analysis ofvariance, using both months and years. Using thesame unmodified SI ratios, this test allows fordetermining whether or not there is slowlyevolving seasonality in the time series. The nullhypothesis in this case is that years have nosignificant effect after accounting for variation dueto months. PROC Xl2 also presents a new test forseasonality which combines the previous two Ftests with the Kruskal-Wallis chi-square test forstable seasonality to determine what is calledidentifiable seasonality. The null hypothesis is thatidentifiable seasonality is not present. The resultof this test for the electricity consumption timeseries is that identifiable seasonality was shown tobe present in the series.TableD 10: Final seasonal factors(Expressed as ontbsResidualTOial31173.123047.3013422o.42DECTest for the presence of residual seasonality.No evidence of residual seasonality in the entireseries at the I per cent level. F 0.71. *Residualseasonality present in the last 3 years at the 1 percent level.F 3.59Table F 2: Summary MeasuresF-test for stable seasonality from Table B 1.:248.190.0%F-test for stable seasonality from TableD 8.:300.383.0%Kruskal-Wallis Chi Squared test for stable306.694.0%seasonality from TableD 8.:F-test for moving seasonality from TableD 8.:1.34513%MeanDF SquoJe f.vatueII 2833.92 300.3826 .323 9.434368334** Seasonality present at the 0.1 per cent level.fNonparametric Test for the Presenceof Seasonality Assuming Stability:Kruskal-WallisStatisticDFJUN110.725 102.178 95.151 87.765 86.96198.319113.707 115.481 107.610 92.729 89.318 100.234TableD 8.A: F-tests for seasonalityTest for the Presence of Seasonality AssumingStability:SUm ofMAYNOVIP - level11.00%306.6936Seasonality present at the one percent level.562

ConclusionLadiray, Dominique and Quenneville, Benoit,Seasonal Adjustment with the X-11 Method,NewYork:Springer, 2001.Mcintire, Robert J. "Revision of SeasonallyAdjusted Labor Force Series", Bureau of LaborStatistics, http://stats.bls.gov/cpsrs.htm.Miron, Jeffrey A, The Economics of SeasonalCycles Cambridge, Massachusetts: The MITPress, 1996.Nelson, Charles R., Applied Time Series Analysis.San Francisco: Holden-Day, NC. 1973.Nerlove, Marc, Grether, David M., and Carvalho,Jose L. Analysis of Economic Time Series:A Synthesis, New York: Academic Press, 1979.SAS Institute Inc., SASIETS User's Guide.Version 6. Second Edition, Cary, NC:SASInstitute Inc., 1993.SAS Institute Inc., SASIETS Software:Applications Guides 1 and 2, Version 6, FirstEdition, 1993.SAS Institute Inc., SASISTAT User's Guide, Vols.I and n, 1990 Version 6, Fourth Edition. Cary,N.C.: SAS Institute Inc.SAS Institute Inc., SAS System for ForecastingTime Series, 1986 Edition.Shiller, Robert J. Market Volatility Cambridge,Massachusetts: The MIT Press, 1989.The SAS procedures PROC ARIMA, PROCSPECI'RA and PROC X12 provide the researcherwith a set of powerful statiStical tools fordetermining whether or not a time series exlnbitsperiodicity. Applying each of these procedures tothe electricity consumption time series showedstatistically significant seasonality. This wasdetected in the Arima procedure by analysis of theACF, IACF and PACF visual diagrams. Theperiodogram or the spectral density plotted againstthe frequency or period provides a quick efficientway to determine periodicity from PROCSPECI'RA. Finally, the moving-averageparametric and non-parametric methodology ofPROC X12 complements the other procedureswith tests for identifiable and moving seasonality.The Arima and Spectral Analysis procedures arealso implemented in JMP 4.0 Statistical DiscoverySoftware and the SASJETS Time SeriesForecasting System.Contact InformationThe authors may be contacted atJoseph EarleyDepartment of EconomicsLoyola Marymount UniversityOne LMU Drive, Suite 4231Los Angeles, CA 90045-2659Phone: (310) 338-4572Fax: (310) 338-1950e-mail: jearley@lmu.edu Seid ZekavatDepartment of EconomicsLoyola Marymount UniversityOne LMU Drive, Suite 4223Los Angeles, CA 90045-2659Phone: (310) 338-7372Fax: (310) 338-1950e-mail: szekavat@lmn.edu.ReferencesBernstein, Jake, Seasonality: Systems, Strategies,and Signals New York: John Wiley & Sons,1998.Box, G.E.P. and G.M. Jenkins. Time SeriesAnalysis: Forecasting and Control 2nd.Edition. San Francisco, Holden-Day, 1976.Gujarati, Damodar, Basic Econometrics,Third Edition, New York: McGraw-Hill, Inc.,1995Jaditz, Ted, "Seasonality: economic data andmodel estimation", Monthly Labor Review,December, 1994, pp. 17-22.563

Univariate Seasonal ARIMA Modeling A univariate time series model which also has components of seasonality may be concisely expressed as: (p,d,q)(P ,D,Q) transformation where: I p is the number of regular autoregressive . trigonometric function of sine and cosine components. Spectral analysis allows the

Related Documents: