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(1.0137 + ,0.9834 + ,0.9643 + ,0.9470 + ,0.9060 + ,0.9492 + ,0.9397 + ,0.9041 + ,0.8721 + ,0.8552 + ,0.8564 + ,0.8973 + ,0.9383 + ,0.9217 + ,0.9095 + ,0.8920 + ,0.8742 + ,0.8532 + ,0.8607 + ,0.9005 + ,0.9111 + ,0.9059 + ,0.8883 + ,0.8924 + ,0.8833 + ,0.8700 + ,0.8758 + ,0.8858 + ,0.9170 + ,0.9554 + ,0.9922 + ,0.9778 + ,0.9808 + ,0.9811 + ,1.0014 + ,1.0183 + ,1.0622 + ,1.0773 + ,1.0807 + ,1.0848 + ,1.1582 + ,1.1663 + ,1.1372 + ,1.1139 + ,1.1222 + ,1.1692 + ,1.1702 + ,1.2286 + ,1.2613 + ,1.2646 + ,1.2262 + ,1.1985 + ,1.2007 + ,1.2138 + ,1.2266 + ,1.2176 + ,1.2218 + ,1.2490 + ,1.2991 + ,1.3408 + ,1.3119 + ,1.3014 + ,1.3201 + ,1.2938 + ,1.2694 + ,1.2165 + ,1.2037 + ,1.2292 + ,1.2256 + ,1.2015 + ,1.1786 + ,1.1856 + ,1.2103 + ,1.1938 + ,1.2020 + ,1.2271 + ,1.2770 + ,1.2650 + ,1.2684 + ,1.2811 + ,1.2727 + ,1.2611 + ,1.2881 + ,1.3213 + ,1.2999 + ,1.3074 + ,1.3242 + ,1.3516 + ,1.3511 + ,1.3419 + ,1.3716 + ,1.3622 + ,1.3896 + ,1.4227 + ,1.4684 + ,1.4570 + ,1.4718 + ,1.4748 + ,1.5527 + ,1.5750 + ,1.5557 + ,1.5553 + ,1.5770 + ,1.4975 + ,1.4369 + ,1.3322 + ,1.2732 + ,1.3449 + ,1.3239 + ,1.2785 + ,1.3050 + ,1.3190 + ,1.3650 + ,1.4016 + ,1.4088 + ,1.4268 + ,1.4562 + ,1.4816 + ,1.4914 + ,1.4614 + ,1.4272 + ,1.3686 + ,1.3569 + ,1.3406 + ,1.2565 + ,1.2208 + ,1.2770 + ,1.2894 + ,1.3067 + ,1.3898 + ,1.3661 + ,1.3220 + ,1.3360 + ,1.3649 + ,1.3999 + ,1.4442 + ,1.4349 + ,1.4388 + ,1.4264 + ,1.4343 + ,1.3770 + ,1.3706 + ,1.3556 + ,1.3179 + ,1.2905 + ,1.3224 + ,1.3201 + ,1.3162 + ,1.2789 + ,1.2526 + ,1.2288 + ,1.2400 + ,1.2856 + ,1.2974 + ,1.2828) > par1 = '12' > par1 <- as.numeric(par1) > nx <- length(x) > x <- ts(x,frequency=par1) > m <- StructTS(x,type='BSM') > m$coef level slope seas epsilon 0.0009945977 0.0000000000 0.0000000000 0.0000000000 > m$fitted level slope sea Jan 1 1.0137000 0.0000000000 0.0000000000 Feb 1 0.9849756 -0.0015756000 -0.0015756000 Mar 1 0.9659454 -0.0016454183 -0.0016454183 Apr 1 0.9487075 -0.0017075397 -0.0017075397 May 1 0.9078628 -0.0018628458 -0.0018628458 Jun 1 0.9508854 -0.0016854331 -0.0016854331 Jul 1 0.9414161 -0.0017160784 -0.0017160784 Aug 1 0.9059484 -0.0018484375 -0.0018484375 Sep 1 0.8740658 -0.0019657587 -0.0019657587 Oct 1 0.8572236 -0.0020236434 -0.0020236434 Nov 1 0.8584112 -0.0020111969 -0.0020111969 Dec 1 0.8991462 -0.0018461538 -0.0018461538 Jan 2 0.9114207 -0.0024435695 0.0268792649 Feb 2 0.9237851 -0.0020850909 -0.0020850908 Mar 2 0.9116034 -0.0021034483 -0.0021034483 Apr 2 0.8941313 -0.0021313406 -0.0021313406 May 2 0.8763597 -0.0021596745 -0.0021596745 Jun 2 0.8553937 -0.0021936823 -0.0021936823 Jul 2 0.8628762 -0.0021762162 -0.0021762162 Aug 2 0.9026007 -0.0021007194 -0.0021007194 Sep 2 0.9131779 -0.0020779174 -0.0020779174 Oct 2 0.9079835 -0.0020835126 -0.0020835126 Nov 2 0.8904113 -0.0021112701 -0.0021112701 Dec 2 0.8945002 -0.0021001786 -0.0021001786 Jan 3 0.8659197 -0.0015800294 0.0173803230 Feb 3 0.8714693 -0.0014692941 -0.0014692940 Mar 3 0.8772608 -0.0014607521 -0.0014607521 Apr 3 0.8872473 -0.0014473005 -0.0014473005 May 3 0.9184090 -0.0014090270 -0.0014090270 Jun 3 0.9567624 -0.0013624122 -0.0013624122 Jul 3 0.9935178 -0.0013177778 -0.0013177778 Aug 3 0.9791331 -0.0013330607 -0.0013330607 Sep 3 0.9821280 -0.0013280047 -0.0013280047 Oct 3 0.9824261 -0.0013261072 -0.0013261072 Nov 3 1.0027009 -0.0013009313 -0.0013009313 Dec 3 1.0195798 -0.0012797674 -0.0012797674 Jan 4 1.0444441 -0.0016141692 0.0177558613 Feb 4 1.0785063 -0.0012062609 -0.0012062608 Mar 4 1.0819023 -0.0012022589 -0.0012022589 Apr 4 1.0859977 -0.0011976563 -0.0011976563 May 4 1.1593330 -0.0011329575 -0.0011329575 Jun 4 1.1674250 -0.0011249567 -0.0011249567 Jul 4 1.1383492 -0.0011491775 -0.0011491775 Aug 4 1.1150683 -0.0011683391 -0.0011683391 Sep 4 1.1233602 -0.0011601556 -0.0011601556 Oct 4 1.1703186 -0.0011185665 -0.0011185665 Nov 4 1.1713167 -0.0011167386 -0.0011167386 Dec 4 1.2296654 -0.0010654310 -0.0010654310 Jan 5 1.2475985 -0.0012455894 0.0137014832 Feb 5 1.2656708 -0.0010708276 -0.0010708275 Mar 5 1.2272966 -0.0010965541 -0.0010965541 Apr 5 1.1996149 -0.0011148761 -0.0011148761 May 5 1.2018126 -0.0011125947 -0.0011125947 Jun 5 1.2149028 -0.0011028198 -0.0011028198 Jul 5 1.2276933 -0.0010932646 -0.0010932646 Aug 5 1.2186987 -0.0010986951 -0.0010986951 Sep 5 1.2228951 -0.0010950584 -0.0010950584 Oct 5 1.2500757 -0.0010756516 -0.0010756516 Nov 5 1.3001406 -0.0010405758 -0.0010405758 Dec 5 1.3418113 -0.0010113014 -0.0010113014 Jan 6 1.3038389 -0.0007328273 0.0080611006 Feb 6 1.3021401 -0.0007400572 -0.0007400570 Mar 6 1.3208290 -0.0007289549 -0.0007289549 Apr 6 1.2945436 -0.0007435502 -0.0007435502 May 6 1.2701570 -0.0007570451 -0.0007570451 Jun 6 1.2172868 -0.0007867731 -0.0007867731 Jul 6 1.2044936 -0.0007936182 -0.0007936182 Aug 6 1.2299786 -0.0007786447 -0.0007786447 Sep 6 1.2263803 -0.0007802504 -0.0007802504 Oct 6 1.2022935 -0.0007935154 -0.0007935154 Nov 6 1.1794061 -0.0008060830 -0.0008060830 Dec 6 1.1864016 -0.0008016477 -0.0008016477 Jan 7 1.2004602 -0.0008945242 0.0098397661 Feb 7 1.1947254 -0.0009254146 -0.0009254145 Mar 7 1.2029210 -0.0009209654 -0.0009209654 Apr 7 1.2280083 -0.0009082846 -0.0009082846 May 7 1.2778835 -0.0008835363 -0.0008835363 Jun 7 1.2658889 -0.0008889484 -0.0008889484 Jul 7 1.2692869 -0.0008868613 -0.0008868613 Aug 7 1.2819803 -0.0008802529 -0.0008802529 Sep 7 1.2735839 -0.0008839086 -0.0008839086 Oct 7 1.2619891 -0.0008891157 -0.0008891157 Nov 7 1.2889756 -0.0008755707 -0.0008755707 Dec 7 1.3221590 -0.0008590291 -0.0008590291 Jan 8 1.2921622 -0.0007034388 0.0077378267 Feb 8 1.3080114 -0.0006113617 -0.0006113617 Mar 8 1.3248040 -0.0006039558 -0.0006039558 Apr 8 1.3521920 -0.0005920493 -0.0005920493 May 8 1.3516920 -0.0005920102 -0.0005920102 Jun 8 1.3424957 -0.0005956669 -0.0005956669 Jul 8 1.3721828 -0.0005828025 -0.0005828025 Aug 8 1.3627865 -0.0005865450 -0.0005865450 Sep 8 1.3901747 -0.0005746712 -0.0005746712 Oct 8 1.4232604 -0.0005603902 -0.0005603902 Nov 8 1.4689408 -0.0005407800 -0.0005407800 Dec 8 1.4575454 -0.0005453813 -0.0005453813 Jan 9 1.4653716 -0.0005844014 0.0064284159 Feb 9 1.4753324 -0.0005324151 -0.0005324152 Mar 9 1.5532028 -0.0005028291 -0.0005028291 Apr 9 1.5754942 -0.0004942307 -0.0004942307 May 9 1.5562013 -0.0005013192 -0.0005013192 Jun 9 1.5558013 -0.0005012810 -0.0005012810 Jul 9 1.5774929 -0.0004929190 -0.0004929190 Aug 9 1.4980227 -0.0005226656 -0.0005226656 Sep 9 1.4374453 -0.0005452766 -0.0005452766 Oct 9 1.3327845 -0.0005844620 -0.0005844620 Nov 9 1.2738064 -0.0006064310 -0.0006064310 Dec 9 1.3454792 -0.0005792481 -0.0005792481 Jan 10 1.3187192 -0.0004709816 0.0051807982 Feb 10 1.2791441 -0.0006440678 -0.0006440681 Mar 10 1.3056349 -0.0006348695 -0.0006348695 Apr 10 1.3196299 -0.0006299119 -0.0006299119 May 10 1.3656141 -0.0006141212 -0.0006141212 Jun 10 1.4022015 -0.0006015233 -0.0006015233 Jul 10 1.4093989 -0.0005988832 -0.0005988832 Aug 10 1.4273926 -0.0005925913 -0.0005925913 Sep 10 1.4567824 -0.0005824484 -0.0005824484 Oct 10 1.4821737 -0.0005736646 -0.0005736646 Nov 10 1.4919702 -0.0005701588 -0.0005701588 Dec 10 1.4619801 -0.0005801013 -0.0005801013 Jan 11 1.4224126 -0.0004352158 0.0047873740 Feb 11 1.3692470 -0.0006469845 -0.0006469852 Mar 11 1.3575504 -0.0006503844 -0.0006503844 Apr 11 1.3412552 -0.0006551967 -0.0006551967 May 11 1.2571808 -0.0006808484 -0.0006808484 Jun 11 1.2214916 -0.0006916103 -0.0006916103 Jul 11 1.2776741 -0.0006741320 -0.0006741320 Aug 11 1.2900701 -0.0006701166 -0.0006701166 Sep 11 1.3073646 -0.0006645993 -0.0006645993 Oct 11 1.3904389 -0.0006388888 -0.0006388888 Nov 11 1.3667460 -0.0006459649 -0.0006459649 Dec 11 1.3226593 -0.0006592944 -0.0006592944 Jan 12 1.3285063 -0.0006812481 0.0074937295 Feb 12 1.3654430 -0.0005429858 -0.0005429864 Mar 12 1.4004330 -0.0005329765 -0.0005329765 Apr 12 1.4447204 -0.0005203546 -0.0005203546 May 12 1.4354228 -0.0005228257 -0.0005228257 Jun 12 1.4393216 -0.0005215812 -0.0005215812 Jul 12 1.4269249 -0.0005249226 -0.0005249226 Aug 12 1.4348226 -0.0005225533 -0.0005225533 Sep 12 1.3775385 -0.0005385155 -0.0005385155 Oct 12 1.3711402 -0.0005401629 -0.0005401629 Nov 12 1.3561442 -0.0005442258 -0.0005442258 Dec 12 1.3184547 -0.0005546628 -0.0005546628 Jan 13 1.2854999 -0.0004545503 0.0050000541 Feb 13 1.3227269 -0.0003268830 -0.0003268837 Mar 13 1.3204274 -0.0003273954 -0.0003273954 Apr 13 1.3165283 -0.0003283229 -0.0003283229 May 13 1.2792379 -0.0003379184 -0.0003379184 Jun 13 1.2529447 -0.0003446548 -0.0003446548 Jul 13 1.2291507 -0.0003507392 -0.0003507392 Aug 13 1.2403477 -0.0003477437 -0.0003477437 Sep 13 1.2859358 -0.0003358309 -0.0003358309 Oct 13 1.2977327 -0.0003326853 -0.0003326853 Nov 13 1.2831364 -0.0003363824 -0.0003363824 > m$resid Jan Feb Mar Apr May 1 0.000000000 -0.546879220 -0.554565163 -0.495398105 -1.243441954 2 0.542012623 0.400258023 -0.320437848 -0.487759806 -0.496380940 3 -0.925932023 0.205495273 0.230363259 0.363190419 1.034591346 4 0.885392624 1.056766274 0.145994361 0.168053916 2.364356998 5 0.633055157 0.580948985 -1.183245708 -0.843265970 0.105073713 6 -1.219581099 -0.029332246 0.616239843 -0.810589145 -0.749897567 7 0.487124522 -0.147954585 0.289283055 0.824885824 1.610664250 8 -0.950665342 0.508447677 0.551971478 0.887775840 0.002918129 9 0.272170660 0.325131190 2.486508470 0.722908147 -0.596191145 10 -0.848826329 -1.209223874 0.860552975 0.463971778 1.478316182 11 -1.261247335 -1.634490443 -0.350421127 -0.496150203 -2.645506392 12 0.210098129 1.168350831 1.126857565 1.421388228 -0.278350581 13 -1.044671938 1.172265013 -0.062556560 -0.113267380 -1.172165864 Jun Jul Aug Sep Oct 1 1.426061649 -0.247302193 -1.072309266 -0.954200253 -0.472624417 2 -0.596859854 0.307095503 1.329807161 0.402359633 -0.098907942 3 1.261546973 1.209366625 -0.414575831 0.137314858 0.051591564 4 0.292636753 -0.886663770 -0.702066443 0.300097463 1.526428845 5 0.450505666 0.440686640 -0.250624946 0.167956232 0.896887335 6 -1.652905732 -0.380813378 0.833494889 -0.089435604 -0.739224940 7 -0.352401049 0.135963210 0.430714789 -0.238382256 -0.339709078 8 -0.272888831 0.960427473 -0.279521143 0.887224287 1.067548311 9 0.003212079 0.703837682 -2.504727750 -1.904606211 -3.301973185 10 1.179805805 0.247333074 0.589643720 0.950860540 0.823726302 11 -1.110235631 1.803672930 0.414498008 0.569718731 2.655645724 12 0.140221626 -0.376594371 0.267104452 -1.800077008 -0.185833011 13 -0.823112965 -0.743638345 0.366209614 1.456747114 0.384759637 Nov Dec 1 0.102019514 1.358032363 2 -0.491564932 0.196774397 3 0.685333083 0.576789373 4 0.067147670 1.886375430 5 1.622149139 1.354777170 6 -0.700765134 0.247449189 7 0.884108444 1.080224403 8 1.466538620 -0.344257083 9 -1.851923250 2.292300551 10 0.328878200 -0.933019734 11 -0.731122034 -1.377652783 12 -0.458435943 -1.177989971 13 -0.452337140 > 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/1k9bk1354721500.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/2r1x11354721500.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/30fc11354721500.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/4qijl1354721500.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/5nxai1354721500.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/6sn2x1354721500.tab") > > try(system("convert tmp/1k9bk1354721500.ps tmp/1k9bk1354721500.png",intern=TRUE)) character(0) > try(system("convert tmp/2r1x11354721500.ps tmp/2r1x11354721500.png",intern=TRUE)) character(0) > try(system("convert tmp/30fc11354721500.ps tmp/30fc11354721500.png",intern=TRUE)) character(0) > try(system("convert tmp/4qijl1354721500.ps tmp/4qijl1354721500.png",intern=TRUE)) character(0) > try(system("convert tmp/5nxai1354721500.ps tmp/5nxai1354721500.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 4.307 0.670 4.977