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(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) > 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 338.2008820 0.1944153 1602.7474768 663.8387161 > m$fitted level slope sea Jan 1 617.0000 0.000000000 0.000000 Feb 1 616.3969 0.008900969 -1.891027 Mar 1 627.1902 0.988799372 16.498896 Apr 1 614.2874 -0.285014674 -30.104776 May 1 611.0525 -0.517188084 4.018369 Jun 1 617.0958 -0.096893808 16.182353 Jul 1 556.6884 -3.258901444 -141.807181 Aug 1 484.1686 -6.349233203 -96.186076 Sep 1 501.7309 -5.396186717 126.039450 Oct 1 572.8778 -2.557130087 143.893378 Nov 1 604.9282 -1.329306216 -10.365301 Dec 1 623.8694 -0.630563447 5.488504 Jan 2 630.2280 -0.735261175 -3.830880 Feb 2 622.3331 -0.772652073 -32.860090 Mar 2 631.2711 -0.493456771 59.602696 Apr 2 617.4699 -1.028935064 -60.178977 May 2 605.9598 -1.480806147 17.225877 Jun 2 600.5141 -1.645153476 82.121536 Jul 2 578.8095 -2.407933864 -149.261998 Aug 2 538.2752 -3.718967960 -214.643279 Sep 2 564.9290 -2.774122462 175.620983 Oct 2 574.6951 -2.421812745 109.700225 Nov 2 600.8222 -1.712879588 30.338024 Dec 2 617.8970 -1.326323887 16.596460 Jan 3 619.5476 -1.283116650 -12.914054 Feb 3 635.4593 -0.991225742 7.752093 Mar 3 634.3955 -0.992904593 56.636231 Apr 3 643.5013 -0.706503155 -20.793360 May 3 634.8633 -0.953749781 2.476741 Jun 3 629.6227 -1.090075784 103.194432 Jul 3 622.7561 -1.268922595 -145.275710 Aug 3 610.6602 -1.586376589 -268.952012 Sep 3 616.6498 -1.379377459 183.023519 Oct 3 624.0759 -1.157505203 94.031832 Nov 3 614.1898 -1.358835318 -20.314819 Dec 3 636.3498 -0.861929287 77.176556 Jan 4 646.4557 -0.643500528 -24.347352 Feb 4 659.8775 -0.353259535 29.883595 Mar 4 691.5716 0.373423026 119.381050 Apr 4 699.8105 0.568995158 -26.217887 May 4 689.0149 0.268732305 -28.121023 Jun 4 682.8042 0.093188054 104.987924 Jul 4 648.7119 -0.828645465 -221.907733 Aug 4 634.7036 -1.174739938 -276.961156 Sep 4 638.0396 -1.061017594 198.984465 Oct 4 639.3805 -1.003304265 88.563265 Nov 4 665.2958 -0.386876005 18.836737 Dec 4 651.8193 -0.675218594 -5.040386 Jan 5 670.3195 -0.260201923 16.215574 Feb 5 665.3894 -0.362581890 -25.333131 Mar 5 657.2944 -0.538188223 108.094394 Apr 5 651.1308 -0.671219417 -13.677632 May 5 668.7858 -0.223798474 44.246779 Jun 5 686.3202 0.217124722 159.961780 Jul 5 678.0737 0.006729731 -256.388381 Aug 5 669.5521 -0.202755297 -298.828182 Sep 5 658.8363 -0.455622555 169.766770 Oct 5 645.2447 -0.763683850 47.519016 Nov 5 624.5420 -1.220006698 -14.781140 Dec 5 635.3902 -0.948801097 35.303529 Jan 6 658.5489 -0.411112944 70.852988 Feb 6 678.1489 0.037413859 4.063995 Mar 6 658.8495 -0.402309408 32.624375 Apr 6 645.0115 -0.713389930 -45.136411 May 6 652.5570 -0.519155927 72.836987 Jun 6 630.5786 -1.028617775 109.787937 Jul 6 623.6905 -1.167983178 -235.131199 Aug 6 619.2348 -1.245781022 -286.796935 Sep 6 593.6285 -1.816375918 123.039564 Oct 6 603.1425 -1.554310918 106.890241 Nov 6 627.0686 -0.972049697 18.752231 Dec 6 635.8500 -0.751147810 12.869357 Jan 7 622.7898 -1.028873256 24.612191 Feb 7 617.5748 -1.123491171 27.261360 Mar 7 629.4898 -0.826971113 82.796185 Apr 7 648.6071 -0.369709693 -3.339023 May 7 626.0837 -0.881438387 15.608612 Jun 7 616.3557 -1.086788840 118.513957 Jul 7 614.1786 -1.112131319 -221.701527 Aug 7 615.1099 -1.064734755 -272.004549 Sep 7 633.1405 -0.623962171 150.494653 Oct 7 670.8407 0.255276391 164.361833 Nov 7 671.7502 0.270196313 -23.037011 Dec 7 656.2965 -0.086826918 -20.400677 Jan 8 653.9567 -0.137879074 32.031372 Feb 8 640.4182 -0.441701783 -17.542712 Mar 8 635.8912 -0.534567910 80.899293 Apr 8 650.4004 -0.191340425 58.009268 May 8 644.1907 -0.329137635 -12.555032 Jun 8 682.4204 0.555871018 216.695528 Jul 8 714.3844 1.277338973 -197.138624 Aug 8 709.0722 1.126105119 -349.185749 Sep 8 728.7623 1.551216233 180.103600 Oct 8 716.7042 1.240474532 117.260626 Nov 8 713.9262 1.148985450 -4.164546 Dec 8 753.4147 2.019938869 87.776360 Jan 9 760.6696 2.138728447 12.035336 Feb 9 775.7845 2.433218006 3.526959 Mar 9 823.1809 3.454770340 163.111748 Apr 9 818.7047 3.274281880 -26.229285 May 9 811.4085 3.033325770 -72.777161 Jun 9 786.4999 2.395620342 131.741770 Jul 9 767.0435 1.896677995 -225.469613 Aug 9 758.2650 1.653020332 -366.587439 Sep 9 769.3523 1.868135732 217.513186 Oct 9 765.9004 1.746997984 77.431397 Nov 9 807.5887 2.655180460 66.903272 Dec 9 795.7040 2.324939282 -7.330196 Jan 10 800.1160 2.372312976 9.969157 Feb 10 805.7189 2.445645689 -15.135104 Mar 10 806.1540 2.399986024 172.727300 Apr 10 799.7827 2.200646492 -22.938419 May 10 808.7759 2.355137267 -15.752757 Jun 10 809.2780 2.312966217 137.534098 Jul 10 812.5466 2.334720243 -218.965455 Aug 10 815.4844 2.348445955 -377.748741 Sep 10 817.1487 2.332882109 206.151138 Oct 10 818.3325 2.306759337 50.171121 Nov 10 793.7590 1.696083075 9.023648 Dec 10 781.8847 1.387954662 -15.936041 Jan 11 776.3409 1.230612617 5.697718 Feb 11 797.1983 1.676096031 46.198279 Mar 11 810.2770 1.934954836 185.724950 Apr 11 802.4611 1.713519365 -64.187164 May 11 852.9373 2.821287376 121.690079 Jun 11 837.2711 2.401181071 39.831727 Jul 11 828.5328 2.148016684 -224.650404 Aug 11 819.1817 1.886695055 -388.141579 Sep 11 842.3329 2.369835335 286.346574 > m$resid Jan Feb Mar Apr May 1 0.000000000 -0.047815737 0.382687229 -0.509321994 -0.125858379 2 0.406114330 -0.391537437 0.475572216 -0.623305304 -0.496596256 3 0.157776554 0.900349345 -0.003691726 0.502901601 -0.393398704 4 0.570315951 0.727765939 1.641868712 0.399418529 -0.575120312 5 0.990801528 -0.240739837 -0.397055699 -0.287771542 0.935702231 6 1.242532674 1.030309958 -0.993915817 -0.689446748 0.423393795 7 -0.633773365 -0.215432446 0.670507476 1.024869738 -1.137866087 8 -0.115954315 -0.689537009 -0.210140918 0.773562187 -0.309398760 9 0.269378334 0.667669646 2.313150589 -0.407949027 -0.543658038 10 0.107386582 0.166226550 -0.103443856 -0.451243980 0.349431191 11 -0.356667091 1.009861949 0.586676627 -0.501678056 2.508767430 Jun Jul Aug Sep Oct 1 0.309684842 -3.000476291 -3.533640652 1.234221137 3.971257123 2 -0.193503833 -1.005409328 -1.946072810 1.567348744 0.651027555 3 -0.214324543 -0.292197917 -0.553355123 0.390011587 0.455304881 4 -0.328536258 -1.741767541 -0.674976306 0.231950299 0.123839012 5 0.907050019 -0.433153105 -0.437525966 -0.540485167 -0.676339656 6 -1.100131918 -0.300629631 -0.168872965 -1.252579584 0.583048353 7 -0.454363881 -0.056016195 0.105042465 0.982058119 1.971786154 8 1.982190086 1.614801347 -0.338870857 0.954900475 -0.700185468 9 -1.437060673 -1.123911750 -0.549113735 0.485341330 -0.273717250 10 -0.095326676 0.049163722 0.031025763 -0.035199091 -0.059120891 11 -0.951144011 -0.573112339 -0.591624723 1.094078616 Nov Dec 1 1.799357776 1.054777022 2 1.487236067 0.982912835 3 -0.452515251 1.221736708 4 1.390133049 -0.676545744 5 -1.027540877 0.622172317 6 1.311850846 0.502250182 7 0.033667524 -0.809300248 8 -0.206775383 1.972924283 9 2.055118688 -0.748151025 10 -1.383070964 -0.698252925 11 > 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/1arb71323182405.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/2hdxq1323182405.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/3ft3w1323182405.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/4j3fc1323182405.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/59i6i1323182405.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/6s4dh1323182405.tab") > > try(system("convert tmp/1arb71323182405.ps tmp/1arb71323182405.png",intern=TRUE)) character(0) > try(system("convert tmp/2hdxq1323182405.ps tmp/2hdxq1323182405.png",intern=TRUE)) character(0) > try(system("convert tmp/3ft3w1323182405.ps tmp/3ft3w1323182405.png",intern=TRUE)) character(0) > try(system("convert tmp/4j3fc1323182405.ps tmp/4j3fc1323182405.png",intern=TRUE)) character(0) > try(system("convert tmp/59i6i1323182405.ps tmp/59i6i1323182405.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.855 0.273 4.143