R version 2.13.0 (2011-04-13) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-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(112,118,132,129,121,135,148,148,136,119,104,118,115,126,141,135,125,149,170,170,158,133,114,140,145,150,178,163,172,178,199,199,184,162,146,166,171,180,193,181,183,218,230,242,209,191,172,194,196,196,236,235,229,243,264,272,237,211,180,201,204,188,235,227,234,264,302,293,259,229,203,229,242,233,267,269,270,315,364,347,312,274,237,278,284,277,317,313,318,374,413,405,355,306,271,306,315,301,356,348,355,422,465,467,404,347,305,336,340,318,362,348,363,435,491,505,404,359,310,337,360,342,406,396,420,472,548,559,463,407,362,405,417,391,419,461,472,535,622,606,508,461,390,432) > 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 0.00000 160.97553 29.84652 0.00000 > m$fitted level slope sea Jan 1 112.0000 0.00000000 0.0000000 Feb 1 116.6627 4.77318473 1.3373392 Mar 1 130.3654 11.08629383 1.6346055 Apr 1 132.2554 4.19626406 -3.2554035 May 1 123.4946 -5.30231649 -2.4946259 Jun 1 130.6818 3.82135945 4.3182047 Jul 1 145.9541 12.21060836 2.0458534 Aug 1 150.7955 6.80932764 -2.7954621 Sep 1 139.9905 -6.09921746 -3.9905199 Oct 1 120.9578 -15.57585341 -1.9578022 Nov 1 103.4520 -16.98990776 0.5480121 Dec 1 111.3207 1.22406086 6.6792744 Jan 2 116.0844 3.81134596 -1.0844087 Feb 2 126.6033 8.73193668 -0.6032929 Mar 2 136.8854 9.82660265 4.1145706 Apr 2 136.6235 2.70264194 -1.6235103 May 2 132.2658 -2.30644459 -7.2657818 Jun 2 144.7753 8.12593014 4.2246822 Jul 2 165.1234 16.73441075 4.8765648 Aug 2 172.0741 9.83368013 -2.0740605 Sep 2 162.3749 -3.94679630 -4.3749101 Oct 2 137.8905 -18.43542697 -4.8905428 Nov 2 118.5544 -19.07065027 -4.5544017 Dec 2 126.4104 -0.09916577 13.5895791 Jan 3 144.5567 12.75657260 0.4432855 Feb 3 153.0599 9.75587649 -3.0598766 Mar 3 168.0546 13.41224616 9.9454189 Apr 3 166.1793 2.76495712 -3.1793486 May 3 180.7019 10.99183138 -8.7019068 Jun 3 182.6633 4.69351440 -4.6632705 Jul 3 191.5728 7.62913390 7.4272182 Aug 3 196.3072 5.61137262 2.6928129 Sep 3 184.8344 -6.30429133 -0.8343703 Oct 3 167.3629 -14.09293312 -5.3629432 Nov 3 156.8838 -11.57367947 -10.8838091 Dec 3 155.2560 -4.64475390 10.7440430 Jan 4 165.8134 5.95357172 5.1866097 Feb 4 181.9197 13.02911932 -1.9196715 Mar 4 182.2668 4.23629381 10.7331800 Apr 4 187.0905 4.64303187 -6.0904725 May 4 190.4105 3.72421741 -7.4104732 Jun 4 218.8996 20.90628961 -0.8996351 Jul 4 227.0411 12.06476096 2.9588640 Aug 4 234.3416 8.76358187 7.6583878 Sep 4 213.3321 -11.87937057 -4.3320562 Oct 4 196.5211 -15.29886386 -5.5210871 Nov 4 184.6596 -12.91638712 -12.6595528 Dec 4 184.9232 -3.78282916 9.0768478 Jan 5 191.2187 3.20563283 4.7812582 Feb 5 193.5794 2.62011525 2.4206337 Mar 5 218.3071 17.89263912 17.6928670 Apr 5 241.2295 21.36484012 -6.2294951 May 5 249.1423 12.06154921 -20.1423293 Jun 5 245.7061 1.34448613 -2.7060591 Jul 5 257.0653 8.26126065 6.9347383 Aug 5 257.4232 2.80342294 14.5767563 Sep 5 242.9183 -9.15456155 -5.9183193 Oct 5 219.7176 -18.85977643 -8.7176207 Nov 5 196.5544 -21.83268265 -16.5544010 Dec 5 189.5524 -11.58651477 11.4476001 Jan 6 194.8948 0.11397077 9.1052237 Feb 6 193.9680 -0.60479977 -5.9680106 Mar 6 213.7698 13.46101747 21.2301760 Apr 6 229.3182 14.89918533 -2.3182452 May 6 249.2278 18.35542494 -15.2277659 Jun 6 270.8827 20.63197617 -6.8827104 Jul 6 293.3736 21.91345463 8.6263877 Aug 6 281.8732 -1.11232882 11.1267969 Sep 6 262.8385 -13.46502398 -3.8385442 Oct 6 237.9917 -21.31061647 -8.9917202 Nov 6 221.8125 -17.77352113 -18.8125436 Dec 6 217.8790 -8.23165709 11.1209844 Jan 7 227.4850 4.06916041 14.5150220 Feb 7 242.2508 11.44033229 -9.2507606 Mar 7 248.0626 7.56707640 18.9373602 Apr 7 270.0310 17.47456773 -1.0310427 May 7 289.2444 18.67181543 -19.2443589 Jun 7 320.6910 27.47087492 -5.6910076 Jul 7 346.4582 26.29814762 17.5417681 Aug 7 338.3996 2.65973800 8.6004468 Sep 7 316.2412 -14.41525189 -4.2412464 Oct 7 286.8088 -24.74809447 -12.8088379 Nov 7 259.8360 -26.27907422 -22.8359529 Dec 7 264.0103 -5.31729681 13.9897036 Jan 8 269.6684 2.23809422 14.3316281 Feb 8 281.2219 8.64661796 -4.2219026 Mar 8 299.7337 15.42629437 17.2662833 Apr 8 316.1650 16.11678350 -3.1649523 May 8 341.7878 22.65279755 -23.7878071 Jun 8 378.0812 32.03467512 -4.0812192 Jul 8 390.9817 18.88014360 22.0182905 Aug 8 391.7170 6.41231248 13.2830397 Sep 8 361.6475 -18.65081643 -6.6475174 Oct 8 321.6317 -33.32960048 -15.6317108 Nov 8 299.2090 -25.83460259 -28.2089805 Dec 8 290.6476 -13.96149959 15.3523599 Jan 9 297.7003 0.48326739 17.2997348 Feb 9 305.7670 5.69289597 -4.7669962 Mar 9 333.3221 20.69935392 22.6778572 Apr 9 356.3835 22.32042287 -8.3835011 May 9 384.0880 26.01760145 -29.0880094 Jun 9 420.3627 33.06331494 1.6372739 Jul 9 441.5824 24.93046845 23.4175871 Aug 9 445.9233 10.79939262 21.0766956 Sep 9 413.0913 -19.13766809 -9.0913350 Oct 9 369.4977 -35.91846172 -22.4976897 Nov 9 336.3594 -34.01033365 -31.3594251 Dec 9 321.2343 -21.04532956 14.7656720 Jan 10 319.8876 -7.52237983 20.1124252 Feb 10 325.7851 1.68521518 -7.7850992 Mar 10 337.5925 8.62555397 24.4074597 Apr 10 357.2402 16.18211251 -9.2402328 May 10 393.3108 29.82348199 -30.3108115 Jun 10 431.3385 35.45243428 3.6614913 Jul 10 463.2158 33.00011277 27.7842262 Aug 10 474.7164 18.26050754 30.2835796 Sep 10 421.5512 -30.69180259 -17.5511728 Oct 10 381.0457 -37.41781571 -22.0457107 Nov 10 346.0975 -35.72475173 -36.0975285 Dec 10 323.9909 -26.38631867 13.0090656 Jan 11 333.6135 -1.69536859 26.3865153 Feb 11 348.3405 9.55953752 -6.3404607 Mar 11 379.5356 24.37883063 26.4644261 Apr 11 411.7351 29.73516644 -15.7350823 May 11 453.4403 37.93659847 -33.4402919 Jun 11 475.7819 27.24838152 -3.7818539 Jul 11 510.9559 32.67921777 37.0441024 Aug 11 513.6633 12.15185108 45.3367076 Sep 11 484.8765 -15.87689413 -21.8765116 Oct 11 434.8407 -39.26400026 -27.8406855 Nov 11 399.1402 -36.82355201 -37.1402179 Dec 11 394.1817 -14.99557895 10.8182583 Jan 12 392.7148 -5.72902709 24.2851881 Feb 12 400.3772 3.43918812 -9.3771845 Mar 12 397.7033 -0.74393633 21.2966645 Apr 12 463.8640 45.03559070 -2.8639619 May 12 506.9738 43.71740723 -34.9737548 Jun 12 544.9161 39.76339486 -9.9160926 Jul 12 578.0951 35.25600399 43.9049188 Aug 12 560.0433 -1.21956357 45.9567427 Sep 12 524.0762 -24.98704833 -16.0761888 Oct 12 490.5008 -30.86151459 -29.5007552 Nov 12 441.0112 -43.60646150 -51.0112282 Dec 12 417.8508 -29.61435094 14.1492403 > m$resid Jan Feb Mar Apr May Jun 1 0.00000000 0.42422808 0.52904817 -0.55572228 -0.74310512 0.72013021 2 0.20450767 0.39384248 0.08591047 -0.57008290 -0.39434193 0.82076557 3 1.01622748 -0.23684215 0.28757659 -0.84393700 0.64940047 -0.49550887 4 0.83683715 0.55759280 -0.69229486 0.03214197 -0.07253046 1.35283026 5 0.55134685 -0.04613044 1.20301533 0.27407012 -0.73415967 -0.84427584 6 0.92265739 -0.05662765 1.10820945 0.11345853 0.27267330 0.17940003 7 0.96973956 0.58074578 -0.30520038 0.78139772 0.09443706 0.69351425 8 0.59554282 0.50491915 0.53425433 0.05444992 0.51548478 0.73951740 9 1.13849103 0.41047245 1.18259469 0.12782031 0.29156376 0.55539748 10 1.06578525 0.72549651 0.54695365 0.59579172 1.07570037 0.44372706 11 1.94591942 0.88683235 1.16789990 0.42229728 0.64669525 -0.84255214 12 0.73029745 0.72242699 -0.32967410 3.60916432 -0.10393616 -0.31169450 Jul Aug Sep Oct Nov Dec 1 0.66141391 -0.42569268 -1.01743383 -0.74692087 -0.11145153 1.43557126 2 0.67899938 -0.54395063 -1.08607979 -1.14202126 -0.05006671 1.49570948 3 0.23138010 -0.15907692 -0.93911993 -0.61390472 0.19856138 0.54645417 4 -0.69655478 -0.26022765 -1.62704141 -0.26951533 0.18779443 0.72034237 5 0.54486521 -0.43015897 -0.94252767 -0.76495796 -0.23435466 0.80801818 6 0.10095306 -1.81455032 -0.97363007 -0.61842045 0.27885050 0.75240001 7 -0.09239375 -1.86269976 -1.34581033 -0.81452210 -0.12070272 1.65275197 8 -1.03646644 -0.98242998 -1.97537641 -1.15715373 0.59092605 0.93608887 9 -0.64083992 -1.11347791 -2.35948279 -1.32289016 0.15044430 1.02212992 10 -0.19324346 -1.16143089 -3.85812344 -0.53024088 0.13348809 0.73619555 11 0.42796607 -1.61750241 -2.20904077 -1.84370689 0.19241358 1.72076562 12 -0.35520522 -2.87421693 -1.87319020 -0.46310651 -1.00484344 1.10301869 > 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/19i1y1323889413.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/2h8ib1323889413.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/36d7r1323889413.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/4q5mj1323889413.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/5k1eo1323889413.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/6azjo1323889413.tab") > > try(system("convert tmp/19i1y1323889413.ps tmp/19i1y1323889413.png",intern=TRUE)) character(0) > try(system("convert tmp/2h8ib1323889413.ps tmp/2h8ib1323889413.png",intern=TRUE)) character(0) > try(system("convert tmp/36d7r1323889413.ps tmp/36d7r1323889413.png",intern=TRUE)) character(0) > try(system("convert tmp/4q5mj1323889413.ps tmp/4q5mj1323889413.png",intern=TRUE)) character(0) > try(system("convert tmp/5k1eo1323889413.ps tmp/5k1eo1323889413.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.283 0.360 2.645