Home » date » 2009 » Dec » 02 »

WS09 - Classical Seasonal Decomposition of a univariate time series by Moving Averages

*The author of this computation has been verified*
R Software Module: /rwasp_decompose.wasp (opens new window with default values)
Title produced by software: Classical Decomposition
Date of computation: Wed, 02 Dec 2009 13:30:12 -0700
 
Cite this page as follows:
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL http://www.freestatistics.org/blog/date/2009/Dec/02/t125978595738ybt57c6k66asf.htm/, Retrieved Wed, 02 Dec 2009 21:32:43 +0100
 
BibTeX entries for LaTeX users:
@Manual{KEY,
    author = {{YOUR NAME}},
    publisher = {Office for Research Development and Education},
    title = {Statistical Computations at FreeStatistics.org, URL http://www.freestatistics.org/blog/date/2009/Dec/02/t125978595738ybt57c6k66asf.htm/},
    year = {2009},
}
@Manual{R,
    title = {R: A Language and Environment for Statistical Computing},
    author = {{R Development Core Team}},
    organization = {R Foundation for Statistical Computing},
    address = {Vienna, Austria},
    year = {2009},
    note = {{ISBN} 3-900051-07-0},
    url = {http://www.R-project.org},
}
 
Original text written by user:
 
IsPrivate?
No (this computation is public)
 
User-defined keywords:
 
Dataseries X:
» Textbox « » Textfile « » CSV «
423.4 404.1 500 472.6 496.1 562 434.8 538.2 577.6 518.1 625.2 561.2 523.3 536.1 607.3 637.3 606.9 652.9 617.2 670.4 729.9 677.2 710 844.3 748.2 653.9 742.6 854.2 808.4 1819 1936.5 1966.1 2083.1 1620.1 1527.6 1795 1685.1 1851.8 2164.4 1981.8 1726.5 2144.6 1758.2 1672.9 1837.3 1596.1 1446 1898.4 1964.1 1755.9 2255.3 1881.2 2117.9 1656.5 1544.1 2098.9 2133.3 1963.5 1801.2 2365.4 1936.5 1667.6 1983.5 2058.6 2448.3 1858.1 1625.4 2130.6 2515.7 2230.2 2086.9 2235 2100.2 2288.6 2490 2573.7 2543.8 2004.7 2390 2338.4 2724.5 2292.5 2386 2477.9 2337 2605.1 2560.8 2839.3 2407.2 2085.2 2735.6 2798.7 3053.2 2405 2471.9 2727.3 2790.7 2385.4 3206.6 2705.6 3518.4 1954.9 2584.3 2535.8 2685.9 2866 2236.6 2934.9 2668.6 2371.2 3165.9 2887.2 3112.2 2671.2 2432.6 2812.3 3095.7 2862.9 2607.3 2862.5
 
Output produced by software:


Summary of computational transaction
Raw Inputview raw input (R code)
Raw Outputview raw output of R engine
Computing time4 seconds
R Server'Gwilym Jenkins' @ 72.249.127.135


Classical Decomposition by Moving Averages
tObservationsFitTrendSeasonalRandom
1423.4NANA0.95821202251639NA
2404.1NANA0.909263062351679NA
3500NANA1.05915880317084NA
4472.6NANA1.01641646265085NA
5496.1NANA1.03706363839455NA
6562NANA0.963751995548248NA
7434.8497.25993099457513.6041666666670.9681773693968020.874391787672005
8538.2542.558337513117523.2666666666671.036867761841860.991967061951175
9577.6593.396277438272533.23751.112817979677480.973379884507423
10518.1525.964145201138544.5708333333330.965832382137870.985048134415834
11625.2515.917524586403556.050.9278257793119381.21182159978226
12561.2589.636015340293564.4541666666671.044612743001500.951773611854625
13523.3551.778408065876575.8416666666670.958212022516390.948387962179056
14536.1535.510480572021588.950.9092630623516791.00110085507075
15607.3636.347022106719600.8041666666671.059158803170840.954353487802057
16637.3623.855249432117613.7791666666671.016416462650851.02155107387510
17606.9647.067214979292623.9416666666671.037063638394550.937924200068493
18652.9616.098541320791639.2708333333330.9637519955482481.05973307224574
19617.2639.420641401660.43750.9681773693968020.965248789353572
20670.4699.591960044066674.7166666666671.036867761841860.958272876603346
21729.9762.572430798742685.26251.112817979677480.957154980328204
22677.2676.022302972625699.93750.965832382137871.00174209788966
23710665.595152493154717.3708333333340.9278257793119381.06671449955805
24844.3808.900230096308774.3541666666671.044612743001501.04376283821736
25748.2841.22631221742877.91250.958212022516390.889415831546913
26653.9897.32519606222986.8708333333330.9092630623516790.728721318502528
27742.61162.153170455841097.241666666671.059158803170840.638986339217854
28854.21212.495903501981192.91251.016416462650850.704497225543499
29808.41313.199116511071266.266666666671.037063638394550.615595906086025
3018191291.375470801561339.945833333330.9637519955482481.40857561656405
311936.51373.452382153931418.595833333330.9681773693968021.40995059250839
321966.11563.125674082351507.545833333331.036867761841861.25780033723406
332083.11799.092827744591616.71.112817979677481.15786132203720
341620.11664.056756994891722.9250.965832382137870.97358458068806
351527.61677.659780685121808.16250.9278257793119380.910554104942636
3617951942.962291770411859.983333333331.044612743001500.923847059514682
371685.11788.139417968311866.120833333330.958212022516390.94237618334851
381851.81678.931513055821846.4750.9092630623516791.10296339403955
392164.41931.923309630331824.016666666671.059158803170841.12033432652881
401981.81842.534353081891812.7751.016416462650851.07558374511996
411726.51875.399957081741808.3751.037063638394550.920603625632241
422144.61743.700423012191809.283333333330.9637519955482481.22991310416458
431758.21767.133470912531825.216666666670.9681773693968020.994944654119465
441672.91900.418757009511832.845833333331.036867761841860.880279671956337
451837.32039.391960231191832.63751.112817979677480.900905777716077
461596.11769.630284965741832.233333333330.965832382137870.901939808309111
4714461711.235476073971844.350.9278257793119380.845003519514163
481898.41922.422593711141840.320833333331.044612743001500.98750399949016
491964.11735.381861028591811.06250.958212022516391.13179700912388
501755.91654.760269981631819.891666666670.9092630623516791.06112047276763
512255.31959.417306895971849.9751.059158803170841.15100545047893
521881.21908.440490547601877.616666666671.016416462650850.98572630863654
532117.91978.432229556241907.7251.037063638394551.07049408534708
541656.51871.590312821441941.983333333330.9637519955482480.885076177543799
551544.11897.910029083811960.291666666670.9681773693968020.813579135121277
562098.92027.556025740691955.46251.036867761841861.03518717774186
572133.32159.376922148341940.458333333331.112817979677480.987923867352258
581963.51870.358553819541936.5250.965832382137871.04979871158407
591801.21816.389064395991957.683333333330.9278257793119380.991637769300795
602365.42068.176539231521979.851.044612743001501.14371280939050
611936.51908.410996994491991.63750.958212022516391.01471852921082
621667.61815.203525929681996.345833333330.9092630623516790.918684861603008
631983.52132.722166064802013.61.059158803170840.930032064917234
642058.62074.146019439852040.645833333331.016416462650850.992504857761146
652448.32140.149340668392063.66251.037063638394551.14398558711579
661858.11995.095131050952070.133333333330.9637519955482480.931334035696442
671625.42005.599591067342071.520833333330.9681773693968020.810430959020587
682130.62181.794425597002104.216666666671.036867761841860.97653563278172
692515.72393.889401140622151.195833333331.112817979677481.05088397099772
702230.22118.806861219732193.76250.965832382137871.05257352183396
712086.92059.03483538982219.204166666670.9278257793119381.01353311956227
7222352328.746482867052229.291666666671.044612743001500.959743800556754
732100.22172.514193150472267.258333333330.958212022516390.966714052603906
742288.62098.374563718652307.7750.9092630623516791.09065370862304
7524902462.685438545952325.133333333331.059158803170841.01109137246135
762573.72374.785068817602336.429166666671.016416462650851.08376123540369
772543.82438.64218238932351.48751.037063638394551.04312146257868
782004.72288.015503197892374.070833333330.9637519955482480.87617413308524
7923902317.873099349162394.058333333330.9681773693968021.03111770902000
802338.42506.226027994982417.11251.036867761841860.933036355811354
812724.52707.764349050242433.251.112817979677481.00618061573771
822292.52363.649394393272447.266666666670.965832382137870.96989849909126
8323862275.624165747932452.641666666670.9278257793119381.04850354285801
842477.92559.618956729672450.304166666671.044612743001500.968073780468448
8523372364.923167271772468.058333333330.958212022516390.988192780358282
862605.12274.64657414382501.63750.9092630623516791.14527682217207
872560.82684.451226121532534.51251.059158803170840.953937987429864
882839.32594.805352432752552.895833333331.016416462650851.09422465825347
892407.22656.088500769682561.16251.037063638394550.906295102479622
902085.22481.789888802812575.133333333330.9637519955482480.840200054568632
912735.62521.549379363642604.429166666670.9681773693968021.0848885301982
922798.72710.558101595282614.179166666671.036867761841861.03251798895321
933053.22928.862734645822631.933333333331.112817979677481.04245240443787
9424052562.614889415262653.270833333330.965832382137870.93849450806429
952471.92499.5626494663626940.9278257793119380.98893300415084
962727.32856.880922963132734.870833333331.044612743001500.954642518726775
972790.72609.343091465232723.13750.958212022516391.06950289869046
982385.42460.355977436942705.879166666670.9092630623516790.969534499021956
993206.62838.143994784972679.620833333331.059158803170841.12982287223342
1002705.62727.578987935112683.5251.016416462650850.99194194264132
1013518.42792.738919522132692.929166666671.037063638394551.25983849596726
1021954.92594.203527816882691.7750.9637519955482480.753564621679903
1032584.32609.564770386552695.33750.9681773693968020.990318396893897
1042535.82788.820016202642689.658333333331.036867761841860.909273450874339
1052685.92990.554581394192687.370833333331.112817979677480.89812773079294
10628662601.220014589632693.241666666670.965832382137871.10179069203115
1072236.62490.176145332322683.883333333330.9278257793119380.898169394238382
1082934.92817.115997879542696.804166666671.044612743001501.04181013568810
1092668.62606.652112701992720.329166666670.958212022516391.02376530684557
1102371.22478.222996612152725.529166666670.9092630623516790.956814622106865
1113165.92917.055738782882754.1251.059158803170841.08530665283789
1122887.22816.562014171602771.070833333331.016416462650851.02507950667267
1133112.22889.661158727092786.38751.037063638394551.07701208863220
1142671.22697.365147673692798.816666666670.9637519955482480.99029973835902
1152432.6NANA0.968177369396802NA
1162812.3NANA1.03686776184186NA
1173095.7NANA1.11281797967748NA
1182862.9NANA0.96583238213787NA
1192607.3NANA0.927825779311938NA
1202862.5NANA1.04461274300150NA
 
Charts produced by software:
http://www.freestatistics.org/blog/date/2009/Dec/02/t125978595738ybt57c6k66asf/16yar1259785808.png (open in new window)
http://www.freestatistics.org/blog/date/2009/Dec/02/t125978595738ybt57c6k66asf/16yar1259785808.ps (open in new window)


http://www.freestatistics.org/blog/date/2009/Dec/02/t125978595738ybt57c6k66asf/2lf001259785808.png (open in new window)
http://www.freestatistics.org/blog/date/2009/Dec/02/t125978595738ybt57c6k66asf/2lf001259785808.ps (open in new window)


http://www.freestatistics.org/blog/date/2009/Dec/02/t125978595738ybt57c6k66asf/34muh1259785808.png (open in new window)
http://www.freestatistics.org/blog/date/2009/Dec/02/t125978595738ybt57c6k66asf/34muh1259785808.ps (open in new window)


http://www.freestatistics.org/blog/date/2009/Dec/02/t125978595738ybt57c6k66asf/4km3h1259785808.png (open in new window)
http://www.freestatistics.org/blog/date/2009/Dec/02/t125978595738ybt57c6k66asf/4km3h1259785808.ps (open in new window)


 
Parameters (Session):
par1 = FALSE ; par2 = 1 ; par3 = 1 ; par4 = 1 ; par5 = 12 ; par6 = 3 ; par7 = 1 ; par8 = 2 ; par9 = 1 ;
 
Parameters (R input):
par1 = multiplicative ; par2 = 12 ; par3 = 1 ; par4 = 1 ; par5 = 12 ; par6 = 3 ; par7 = 1 ; par8 = 2 ; par9 = 1 ;
 
R code (references can be found in the software module):
par2 <- as.numeric(par2)
x <- ts(x,freq=par2)
m <- decompose(x,type=par1)
m$figure
bitmap(file='test1.png')
plot(m)
dev.off()
mylagmax <- length(x)/2
bitmap(file='test2.png')
op <- par(mfrow = c(2,2))
acf(as.numeric(x),lag.max = mylagmax,main='Observed')
acf(as.numeric(m$trend),na.action=na.pass,lag.max = mylagmax,main='Trend')
acf(as.numeric(m$seasonal),na.action=na.pass,lag.max = mylagmax,main='Seasonal')
acf(as.numeric(m$random),na.action=na.pass,lag.max = mylagmax,main='Random')
par(op)
dev.off()
bitmap(file='test3.png')
op <- par(mfrow = c(2,2))
spectrum(as.numeric(x),main='Observed')
spectrum(as.numeric(m$trend[!is.na(m$trend)]),main='Trend')
spectrum(as.numeric(m$seasonal[!is.na(m$seasonal)]),main='Seasonal')
spectrum(as.numeric(m$random[!is.na(m$random)]),main='Random')
par(op)
dev.off()
bitmap(file='test4.png')
op <- par(mfrow = c(2,2))
cpgram(as.numeric(x),main='Observed')
cpgram(as.numeric(m$trend[!is.na(m$trend)]),main='Trend')
cpgram(as.numeric(m$seasonal[!is.na(m$seasonal)]),main='Seasonal')
cpgram(as.numeric(m$random[!is.na(m$random)]),main='Random')
par(op)
dev.off()
load(file='createtable')
a<-table.start()
a<-table.row.start(a)
a<-table.element(a,'Classical Decomposition by Moving Averages',6,TRUE)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,'t',header=TRUE)
a<-table.element(a,'Observations',header=TRUE)
a<-table.element(a,'Fit',header=TRUE)
a<-table.element(a,'Trend',header=TRUE)
a<-table.element(a,'Seasonal',header=TRUE)
a<-table.element(a,'Random',header=TRUE)
a<-table.row.end(a)
for (i in 1:length(m$trend)) {
a<-table.row.start(a)
a<-table.element(a,i,header=TRUE)
a<-table.element(a,x[i])
if (par1 == 'additive') a<-table.element(a,m$trend[i]+m$seasonal[i]) else a<-table.element(a,m$trend[i]*m$seasonal[i])
a<-table.element(a,m$trend[i])
a<-table.element(a,m$seasonal[i])
a<-table.element(a,m$random[i])
a<-table.row.end(a)
}
a<-table.end(a)
table.save(a,file='mytable.tab')
 





Copyright

Creative Commons License

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 License.

Software written by Ed van Stee & Patrick Wessa


Disclaimer

Information provided on this web site is provided "AS IS" without warranty of any kind, either express or implied, including, without limitation, warranties of merchantability, fitness for a particular purpose, and noninfringement. We use reasonable efforts to include accurate and timely information and periodically update the information, and software without notice. However, we make no warranties or representations as to the accuracy or completeness of such information (or software), and we assume no liability or responsibility for errors or omissions in the content of this web site, or any software bugs in online applications. Your use of this web site is AT YOUR OWN RISK. Under no circumstances and under no legal theory shall we be liable to you or any other person for any direct, indirect, special, incidental, exemplary, or consequential damages arising from your access to, or use of, this web site.


Privacy Policy

We may request personal information to be submitted to our servers in order to be able to:

  • personalize online software applications according to your needs
  • enforce strict security rules with respect to the data that you upload (e.g. statistical data)
  • manage user sessions of online applications
  • alert you about important changes or upgrades in resources or applications

We NEVER allow other companies to directly offer registered users information about their products and services. Banner references and hyperlinks of third parties NEVER contain any personal data of the visitor.

We do NOT sell, nor transmit by any means, personal information, nor statistical data series uploaded by you to third parties.

We carefully protect your data from loss, misuse, alteration, and destruction. However, at any time, and under any circumstance you are solely responsible for managing your passwords, and keeping them secret.

We store a unique ANONYMOUS USER ID in the form of a small 'Cookie' on your computer. This allows us to track your progress when using this website which is necessary to create state-dependent features. The cookie is used for NO OTHER PURPOSE. At any time you may opt to disallow cookies from this website - this will not affect other features of this website.

We examine cookies that are used by third-parties (banner and online ads) very closely: abuse from third-parties automatically results in termination of the advertising contract without refund. We have very good reason to believe that the cookies that are produced by third parties (banner ads) do NOT cause any privacy or security risk.

FreeStatistics.org is safe. There is no need to download any software to use the applications and services contained in this website. Hence, your system's security is not compromised by their use, and your personal data - other than data you submit in the account application form, and the user-agent information that is transmitted by your browser - is never transmitted to our servers.

As a general rule, we do not log on-line behavior of individuals (other than normal logging of webserver 'hits'). However, in cases of abuse, hacking, unauthorized access, Denial of Service attacks, illegal copying, hotlinking, non-compliance with international webstandards (such as robots.txt), or any other harmful behavior, our system engineers are empowered to log, track, identify, publish, and ban misbehaving individuals - even if this leads to ban entire blocks of IP addresses, or disclosing user's identity.


FreeStatistics.org is powered by