R version 2.15.2 (2012-10-26) -- "Trick or Treat" Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i686-pc-linux-gnu (32-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > x <- c(617,614,647,580,614,636,388,356,639,753,611,639,630,586,695,552,619,681,421,307,754,690,644,643,608,651,691,627,634,731,475,337,803,722,590,724,627,696,825,677,656,785,412,352,839,729,696,641,695,638,762,635,721,854,418,367,824,687,601,676,740,691,683,594,729,731,386,331,706,715,657,653,642,643,718,654,632,731,392,344,792,852,649,629,685,617,715,715,629,916,531,357,917,828,708,858,775,785,1006,789,734,906,532,387,991,841,892,782,811,792,978,773,796,946,594,438,1023,868,791,760,779,852,1001,734,996,869,599,426,1138,1091,830,909) > par1 = '12' > par1 <- '12' > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: Write here your technical program description (don't use hard returns!) > par1 <- as.numeric(par1) > nx <- length(x) > x <- ts(x,frequency=par1) > m <- StructTS(x,type='BSM') > m$coef level slope seas epsilon 548.3289173 0.2745117 1542.8388816 702.0883139 > m$fitted level slope sea Jan 1 617.0000 0.00000000 0.0000000 Feb 1 616.0623 -0.01826182 -1.5996303 Mar 1 628.6482 0.99946634 15.3056019 Apr 1 613.3855 -0.24910185 -28.9611012 May 1 610.2365 -0.42784612 4.7109327 Jun 1 617.7325 -0.05132838 15.4154200 Jul 1 546.5854 -2.75846109 -131.9022920 Aug 1 466.5700 -5.29342155 -81.0841276 Sep 1 498.5985 -4.16562500 126.0689471 Oct 1 587.5174 -1.46242717 129.6703407 Nov 1 619.3764 -0.51279311 -21.1986328 Dec 1 634.4044 -0.07466588 -1.3829530 Jan 2 637.4416 -0.14590234 -8.7190870 Feb 2 625.1343 -0.18940017 -34.4647736 Mar 2 635.8010 0.11771994 55.5634416 Apr 2 618.4517 -0.54893558 -60.8714438 May 2 606.0215 -1.01167569 16.8665133 Jun 2 600.3571 -1.17779087 82.2254016 Jul 2 572.2909 -2.02748377 -141.8792898 Aug 2 523.4473 -3.34309402 -199.7824927 Sep 2 561.7164 -2.28411159 177.3391973 Oct 2 577.5337 -1.86451583 105.9354317 Nov 2 610.4775 -1.15266811 20.9259839 Dec 2 628.7558 -0.83711366 7.1796969 Jan 3 627.4037 -0.84209145 -19.2138463 Feb 3 644.2211 -0.59837908 0.3763349 Mar 3 640.2484 -0.67108371 51.9264331 Apr 3 649.2235 -0.40885013 -25.4901616 May 3 636.1782 -0.78205722 2.0914692 Jun 3 628.0613 -0.99767162 105.4490703 Jul 3 617.2453 -1.27163273 -138.8331992 Aug 3 601.2072 -1.65411499 -259.0139726 Sep 3 611.3014 -1.37440666 187.5356753 Oct 3 623.3790 -1.08231480 93.8343102 Nov 3 614.1723 -1.24154180 -21.2743006 Dec 3 643.4929 -0.70305039 69.5825026 Jan 4 654.4413 -0.51090335 -31.6112364 Feb 4 668.7924 -0.24456905 21.9276652 Mar 4 703.9735 0.49400735 108.6307429 Apr 4 708.3920 0.58660012 -32.7472289 May 4 690.4347 0.11845994 -28.0575757 Jun 4 680.2619 -0.14587924 108.2912555 Jul 4 637.5996 -1.21715400 -210.8105062 Aug 4 622.9468 -1.54152591 -266.2403044 Sep 4 630.6976 -1.32945785 205.0310432 Oct 4 635.2882 -1.20251181 91.6215123 Nov 4 668.6540 -0.50475262 15.1207529 Dec 4 652.4782 -0.80680761 -5.9315865 Jan 5 676.5236 -0.33400913 9.6854734 Feb 5 670.1982 -0.45197240 -30.0869168 Mar 5 661.1100 -0.63308531 103.9130777 Apr 5 653.8665 -0.78055734 -16.5671495 May 5 673.9152 -0.29601018 39.8596224 Jun 5 690.6933 0.10785024 157.3772162 Jul 5 674.9555 -0.26473443 -251.4332752 Aug 5 662.4792 -0.54539797 -291.2071016 Sep 5 650.5881 -0.79767046 177.3929520 Oct 5 637.3939 -1.06336607 53.9638612 Nov 5 617.2995 -1.45792917 -9.6028385 Dec 5 635.3436 -1.06240087 33.7916530 Jan 6 665.4704 -0.43232858 63.5573014 Feb 6 687.5415 0.02962974 -4.4423065 Mar 6 661.2023 -0.52771911 31.0264252 Apr 6 644.5016 -0.88034488 -44.8586023 May 6 654.7121 -0.63276536 70.4244182 Jun 6 627.3257 -1.23681209 112.9966727 Jul 6 619.2737 -1.39049374 -230.8950313 Aug 6 614.0367 -1.47623121 -281.6914703 Sep 6 583.9091 -2.10333838 132.1279350 Oct 6 598.6634 -1.74181186 110.4245604 Nov 6 628.8959 -1.06828530 16.8838683 Dec 6 639.4392 -0.82643573 9.4854003 Jan 7 624.4417 -1.12104862 22.5302633 Feb 7 620.2468 -1.18544573 23.8305097 Mar 7 635.0461 -0.84577527 77.3602193 Apr 7 656.2569 -0.36962609 -9.9634434 May 7 626.0109 -1.02288119 16.4186812 Jun 7 613.7227 -1.27090267 121.2100672 Jul 7 610.9652 -1.30363790 -218.4457769 Aug 7 611.5488 -1.26231857 -268.2088681 Sep 7 632.3099 -0.78478225 151.9806339 Oct 7 676.3653 0.17687949 159.9279199 Nov 7 674.5207 0.13394081 -24.8123124 Dec 7 655.3422 -0.27381036 -19.5743947 Jan 8 654.1431 -0.29332620 31.1811550 Feb 8 639.3828 -0.59956145 -17.3166664 Mar 8 636.3565 -0.65129287 79.4926134 Apr 8 655.0252 -0.23609484 53.2198674 May 8 644.9677 -0.44861022 -12.5354106 Jun 8 688.8708 0.51487898 211.6300225 Jul 8 721.5534 1.21398749 -201.7988336 Aug 8 708.9785 0.91514871 -347.1555420 Sep 8 730.9965 1.37021197 178.6185436 Oct 8 715.2921 1.00414918 118.6853516 Nov 8 712.8313 0.93024716 -3.6181029 Dec 8 760.6828 1.92775917 80.8869165 Jan 9 765.5209 1.98958497 8.4601364 Feb 9 780.5472 2.26702261 -0.1105161 Mar 9 834.1445 3.36325438 153.8952118 Apr 9 822.1937 3.03483499 -27.8374728 May 9 809.9315 2.70558671 -70.5825883 Jun 9 779.7510 1.99619074 137.7477130 Jul 9 758.9501 1.50423597 -218.9776821 Aug 9 751.1065 1.30278232 -360.8364932 Sep 9 766.9698 1.61576347 218.9354912 Oct 9 762.7110 1.48987505 80.3449055 Nov 9 813.2798 2.53873218 61.5419836 Dec 9 796.1606 2.11937544 -7.2798536 Jan 10 801.2943 2.18364869 8.6506670 Feb 10 808.0753 2.28175795 -17.6841882 Mar 10 808.9272 2.25118919 169.5731502 Apr 10 800.4008 2.02028773 -23.6305846 May 10 810.2702 2.18877399 -17.0156106 Jun 10 808.3632 2.10074793 139.0693593 Jul 10 810.3847 2.09904561 -216.3570513 Aug 10 812.6214 2.10200245 -374.6695729 Sep 10 814.3552 2.09410271 208.7735828 Oct 10 815.9675 2.08378168 52.2010598 Nov 10 787.9207 1.43928086 13.6233897 Dec 10 776.8555 1.17206759 -12.4795084 Jan 11 773.4405 1.07407282 7.1647821 Feb 11 800.9061 1.63809248 41.8589730 Mar 11 815.5064 1.91535876 180.9582578 Apr 11 803.5645 1.61861784 -64.7164951 May 11 863.1396 2.86096055 112.5859467 Jun 11 838.0084 2.26052620 40.7836509 Jul 11 825.6967 1.94789208 -221.5989143 Aug 11 814.6644 1.66949860 -384.1232577 Sep 11 843.7670 2.25747828 284.6347989 Oct 11 902.9157 3.47582884 168.1780719 Nov 11 890.7130 3.14032670 -55.2268778 Dec 11 900.7565 3.28796767 5.8279786 > m$resid Jan Feb Mar Apr May 1 0.000000000 -0.044463020 0.360524437 -0.526273131 -0.107821019 2 0.143794742 -0.523327346 0.418181553 -0.655595327 -0.457764248 3 -0.021754220 0.734642304 -0.135794637 0.381002418 -0.500310721 4 0.482508123 0.611421992 1.439405344 0.157979752 -0.745518642 5 1.021845541 -0.245519771 -0.351980343 -0.268195473 0.844006197 6 1.278268161 0.920668314 -1.076033106 -0.658497598 0.451198495 7 -0.579874284 -0.125663826 0.652662698 0.899561807 -1.217893488 8 -0.037835257 -0.591229892 -0.099110516 0.788601386 -0.400778528 9 0.118943843 0.532683392 2.096686632 -0.625348307 -0.624557681 10 0.123168731 0.187831088 -0.058410939 -0.440192812 0.320559453 11 -0.187415551 1.078210073 0.529521172 -0.566040387 2.367281437 Jun Jul Aug Sep Oct 1 0.315667117 -2.913563334 -3.200065240 1.551470611 3.872663791 2 -0.185132367 -1.093670313 -1.927284261 1.722972576 0.751238066 3 -0.294117415 -0.398795255 -0.605209716 0.483912792 0.555294193 4 -0.415743929 -1.729093836 -0.549434602 0.381285137 0.243308311 5 0.693133463 -0.645399470 -0.498919999 -0.464505234 -0.508073264 6 -1.089176603 -0.277903497 -0.157109274 -1.171658652 0.689833204 7 -0.459352573 -0.060666276 0.077083007 0.900111016 1.833387543 8 1.810041592 1.313298486 -0.563206040 0.862264954 -0.697835705 9 -1.342740547 -0.930979105 -0.381835227 0.594873903 -0.240036879 10 -0.167274301 -0.003234274 0.005622030 -0.015041660 -0.019684871 11 -1.143363031 -0.595242112 -0.530242234 1.120707916 2.324244215 Nov Dec 1 1.386067907 0.646192004 2 1.445768850 0.809200691 3 -0.335696117 1.264409015 4 1.421774626 -0.644783629 5 -0.780374127 0.799762461 6 1.308829228 0.475320399 7 -0.082669023 -0.789783983 8 -0.141624436 1.917883660 9 2.005531045 -0.803293655 10 -1.231073318 -0.510909865 11 -0.640547210 0.282030228 > mylevel <- as.numeric(m$fitted[,'level']) > myslope <- as.numeric(m$fitted[,'slope']) > myseas <- as.numeric(m$fitted[,'sea']) > myresid <- as.numeric(m$resid) > myfit <- mylevel+myseas > mylagmax <- nx/2 > postscript(file="/var/wessaorg/rcomp/tmp/1wm1m1352579069.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > op <- par(mfrow = c(2,2)) > acf(as.numeric(x),lag.max = mylagmax,main='Observed') > acf(mylevel,na.action=na.pass,lag.max = mylagmax,main='Level') > acf(myseas,na.action=na.pass,lag.max = mylagmax,main='Seasonal') > acf(myresid,na.action=na.pass,lag.max = mylagmax,main='Standardized Residals') > par(op) > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/27u8h1352579069.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > op <- par(mfrow = c(2,2)) > spectrum(as.numeric(x),main='Observed') > spectrum(mylevel,main='Level') > spectrum(myseas,main='Seasonal') > spectrum(myresid,main='Standardized Residals') > par(op) > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/3hi0v1352579069.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > op <- par(mfrow = c(2,2)) > cpgram(as.numeric(x),main='Observed') > cpgram(mylevel,main='Level') > cpgram(myseas,main='Seasonal') > cpgram(myresid,main='Standardized Residals') > par(op) > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/4a4qa1352579069.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(as.numeric(m$resid),main='Standardized Residuals',ylab='Residuals',xlab='time',type='b') > grid() > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/5p3mh1352579069.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > op <- par(mfrow = c(2,2)) > hist(m$resid,main='Residual Histogram') > plot(density(m$resid),main='Residual Kernel Density') > qqnorm(m$resid,main='Residual Normal QQ Plot') > qqline(m$resid) > plot(m$resid^2, myfit^2,main='Sq.Resid vs. Sq.Fit',xlab='Squared residuals',ylab='Squared Fit') > par(op) > dev.off() null device 1 > > #Note: the /var/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/wessaorg/rcomp/createtable") > > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Structural Time Series Model',6,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'t',header=TRUE) > a<-table.element(a,'Observed',header=TRUE) > a<-table.element(a,'Level',header=TRUE) > a<-table.element(a,'Slope',header=TRUE) > a<-table.element(a,'Seasonal',header=TRUE) > a<-table.element(a,'Stand. Residuals',header=TRUE) > a<-table.row.end(a) > for (i in 1:nx) { + a<-table.row.start(a) + a<-table.element(a,i,header=TRUE) + a<-table.element(a,x[i]) + a<-table.element(a,mylevel[i]) + a<-table.element(a,myslope[i]) + a<-table.element(a,myseas[i]) + a<-table.element(a,myresid[i]) + a<-table.row.end(a) + } > a<-table.end(a) > table.save(a,file="/var/wessaorg/rcomp/tmp/6nd871352579069.tab") > > try(system("convert tmp/1wm1m1352579069.ps tmp/1wm1m1352579069.png",intern=TRUE)) character(0) > try(system("convert tmp/27u8h1352579069.ps tmp/27u8h1352579069.png",intern=TRUE)) character(0) > try(system("convert tmp/3hi0v1352579069.ps tmp/3hi0v1352579069.png",intern=TRUE)) character(0) > try(system("convert tmp/4a4qa1352579069.ps tmp/4a4qa1352579069.png",intern=TRUE)) character(0) > try(system("convert tmp/5p3mh1352579069.ps tmp/5p3mh1352579069.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.941 0.444 4.615