R version 2.9.0 (2009-04-17) Copyright (C) 2009 The R Foundation for Statistical Computing ISBN 3-900051-07-0 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(98.8,100.5,110.4,96.4,101.9,106.2,81,94.7,101,109.4,102.3,90.7,96.2,96.1,106,103.1,102,104.7,86,92.1,106.9,112.6,101.7,92,97.4,97,105.4,102.7,98.1,104.5,87.4,89.9,109.8,111.7,98.6,96.9,95.1,97,112.7,102.9,97.4,111.4,87.4,96.8,114.1,110.3,103.9,101.6,94.6,95.9,104.7,102.8,98.1,113.9,80.9,95.7,113.2,105.9,108.8,102.3,99,100.7,115.5,100.7,109.9,114.6,85.4,100.5,114.8,116.5,112.9,102,106,105.3,118.8,106.1,109.3,117.2,92.5,104.2,112.5,122.4,113.3,100,110.7,112.8,109.8,117.3,109.1,115.9,96,99.8,116.8,115.7,99.4,94.3) > 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 1.50694 0.00000 11.06126 0.00000 > m$fitted level slope sea Jan 1 98.80000 0.0000000000 0.0000000 Feb 1 99.00984 -0.0391919649 1.4901638 Mar 1 103.55794 0.2891175124 6.8420613 Apr 1 102.91662 0.2048668633 -6.5166161 May 1 102.46703 0.1486460198 -0.5670318 Jun 1 103.31415 0.1990167386 2.8858459 Jul 1 98.14216 -0.1070519737 -17.1421630 Aug 1 95.24156 -0.2321453921 -0.5415616 Sep 1 95.41445 -0.2173514460 5.5855506 Oct 1 98.82932 -0.1024655497 10.5706812 Nov 1 101.08218 -0.0340545802 1.2178153 Dec 1 99.52110 -0.0765164809 -8.8211030 Jan 2 98.42783 -0.0786365050 -2.2278336 Feb 2 97.63446 -0.0779097750 -1.5344559 Mar 2 97.21482 -0.0817089764 8.7851848 Apr 2 99.66182 -0.0188244896 3.4381830 May 2 100.69862 0.0166870899 1.3013835 Jun 2 100.13893 -0.0045826867 4.5610691 Jul 2 100.42614 0.0059263958 -14.4261424 Aug 2 99.20414 -0.0341627033 -7.1041441 Sep 2 99.99941 -0.0107872689 6.9005892 Oct 2 100.92467 0.0111798729 11.6753253 Nov 2 100.74202 0.0075134574 0.9579835 Dec 2 100.47736 0.0034786501 -8.4773575 Jan 3 100.19930 0.0001521773 -2.7993034 Feb 3 99.98936 -0.0022130199 -2.9893587 Mar 3 99.65133 -0.0066804689 5.7486732 Apr 3 99.54632 -0.0083311438 3.1536773 May 3 98.72661 -0.0247165307 -0.6266147 Jun 3 98.70241 -0.0247049417 5.7975860 Jul 3 99.37068 -0.0086298393 -11.9706841 Aug 3 99.28312 -0.0104047850 -9.3831202 Sep 3 100.21233 0.0090617977 9.5876660 Oct 3 100.41086 0.0125454075 11.2891407 Nov 3 99.71590 0.0012323856 -1.1158992 Dec 3 100.67189 0.0145715390 -3.7718935 Jan 4 100.27713 0.0093784898 -5.1771284 Feb 4 99.94658 0.0051846292 -2.9465804 Mar 4 101.39727 0.0237964810 11.3027342 Apr 4 101.46916 0.0244698132 1.4308384 May 4 100.78399 0.0136337197 -3.3839888 Jun 4 101.85681 0.0308758079 9.5431940 Jul 4 101.76976 0.0288996685 -14.3697560 Aug 4 102.95063 0.0480456142 -6.1506346 Sep 4 103.76250 0.0602233630 10.3374975 Oct 4 102.91260 0.0466477584 7.3873959 Nov 4 103.24696 0.0506124271 0.6530397 Dec 4 103.87295 0.0579596860 -2.2729532 Jan 5 103.26984 0.0499844650 -8.6698440 Feb 5 102.28736 0.0378471829 -6.3873566 Mar 5 99.87837 0.0089006847 4.8216266 Apr 5 99.40902 0.0030750048 3.3909849 May 5 100.03810 0.0109906155 -1.9381014 Jun 5 101.45417 0.0293281301 12.4458261 Jul 5 100.77307 0.0199016027 -19.8730683 Aug 5 100.81717 0.0202218476 -5.1171714 Sep 5 101.17395 0.0245797155 12.0260490 Oct 5 100.68332 0.0181488837 5.2166791 Nov 5 102.12193 0.0351014119 6.6780677 Dec 5 102.82929 0.0427747121 -0.5292892 Jan 6 103.75618 0.0525091832 -4.7561832 Feb 6 104.46605 0.0595915574 -3.7660510 Mar 6 106.24649 0.0780223817 9.2535065 Apr 6 105.04988 0.0642789463 -4.3498827 May 6 106.38871 0.0782030914 3.5112881 Jun 6 105.82803 0.0711344405 8.7719666 Jul 6 105.58936 0.0676839168 -20.1893560 Aug 6 105.68377 0.0679807939 -5.1837690 Sep 6 105.24408 0.0624140869 9.5559237 Oct 6 106.96690 0.0802359727 9.5330989 Nov 6 107.77467 0.0878406201 5.1253297 Dec 6 107.18300 0.0809293000 -5.1829981 Jan 7 108.08300 0.0890638669 -2.0830000 Feb 7 108.89278 0.0960995290 -3.5927837 Mar 7 109.23625 0.0984917683 9.5637470 Apr 7 109.80759 0.1030528774 -3.7075917 May 7 108.97275 0.0939907637 0.3272535 Jun 7 108.55379 0.0890219911 8.6462058 Jul 7 109.49496 0.0972794161 -16.9949635 Aug 7 110.01080 0.1013192184 -5.8108019 Sep 7 108.96212 0.0903205405 3.5378752 Oct 7 109.66000 0.0960517884 12.7399981 Nov 7 109.65051 0.0950728527 3.6494884 Dec 7 108.88822 0.0872611126 -8.8882173 Jan 8 109.71002 0.0938437929 0.9899819 Feb 8 111.64826 0.1101502535 1.1517375 Mar 8 109.69869 0.0921156500 0.1013142 Apr 8 111.47084 0.1067372864 5.8291560 May 8 111.54534 0.1064576928 -2.4453439 Jun 8 110.73849 0.0985564180 5.1615055 Jul 8 110.97703 0.0997636311 -14.9770324 Aug 8 109.71055 0.0880402167 -9.9105455 Sep 8 110.20328 0.0914866336 6.5967178 Oct 8 108.72342 0.0782384955 6.9765768 Nov 8 105.21005 0.0483135625 -5.8100533 Dec 8 103.76641 0.0360382604 -9.4664068 > m$resid Jan Feb Mar Apr May 1 0.0000000000 0.3887171783 2.3789491070 -0.4534724558 -0.3899355001 2 -0.8371142938 -0.5973271582 -0.2719689434 1.8847732694 0.7649091786 3 -0.2254353158 -0.1677323279 -0.2650596503 -0.0764024286 -0.6233580183 4 -0.3257243500 -0.2700019488 1.1433886116 0.0378481793 -0.5560520232 5 -0.5256695009 -0.8205319125 -1.9416448935 -0.3787874628 0.4949961852 6 0.7039460533 0.5233736886 1.3694608308 -1.0136701576 1.0129776797 7 0.6533638316 0.5749833310 0.1973341940 0.3771320336 -0.7479024122 8 0.5870257824 1.4742388898 -1.6464529224 1.3429487976 -0.0257687263 Jun Jul Aug Sep Oct 1 0.4852652886 -4.0375549792 -2.1750000156 0.3200749838 2.8873639932 2 -0.4222439232 0.2195633175 -0.9470801045 0.6505237095 0.7412311907 3 0.0003954714 0.5343096731 -0.0614178310 0.7374385213 0.1496619018 4 0.8286065230 -0.0923682580 0.9051576581 0.6024289817 -0.7202721689 5 1.1101492434 -0.5614709870 0.0191492475 0.2667362348 -0.4090169633 6 -0.5076033844 -0.2461755810 0.0212493259 -0.4039009646 1.3221339232 7 -0.4089967364 0.6795152497 0.3338497643 -0.9176123231 0.4850056890 8 -0.7300576165 0.1119044739 -1.0923886879 0.3236494424 -1.2569924963 Nov Dec 1 1.8755561216 -1.2157369345 2 -0.1543069102 -0.2174278827 3 -0.5612785370 0.7593069430 4 0.2282866033 0.4572845465 5 1.1293072395 0.5349994218 6 0.5797694342 -0.5418346576 7 -0.0842908546 -0.6849956642 8 -2.8738782337 -1.1941114614 > 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/www/html/rcomp/tmp/1ldtc1259936634.ps",horizontal=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/www/html/rcomp/tmp/2gn7a1259936634.ps",horizontal=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/www/html/rcomp/tmp/323jp1259936634.ps",horizontal=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/www/html/rcomp/tmp/4e9g01259936634.ps",horizontal=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/www/html/rcomp/tmp/5wofk1259936634.ps",horizontal=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/www/html/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/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/www/html/rcomp/tmp/625ku1259936634.tab") > system("convert tmp/1ldtc1259936634.ps tmp/1ldtc1259936634.png") > system("convert tmp/2gn7a1259936634.ps tmp/2gn7a1259936634.png") > system("convert tmp/323jp1259936634.ps tmp/323jp1259936634.png") > system("convert tmp/4e9g01259936634.ps tmp/4e9g01259936634.png") > system("convert tmp/5wofk1259936634.ps tmp/5wofk1259936634.png") > > > proc.time() user system elapsed 1.735 0.812 3.959