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(95.1,97.0,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.0,100.7,115.5,100.7,109.9,114.6,85.4,100.5,114.8,116.5,112.9,102.0,106.0,105.3,118.8,106.1,109.3,117.2,92.5,104.2,112.5,122.4,113.3,100.0,110.7,112.8,109.8,117.3,109.1,115.9,96.0,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 3.504207405 0.002462643 13.501892203 0.000000000 > m$fitted level slope sea Jan 1 95.10000 0.00000000 0.00000000 Feb 1 95.61725 -0.01791372 1.38275423 Mar 1 103.51006 0.53409232 9.18993837 Apr 1 105.42511 0.64181674 -2.52510762 May 1 103.35520 0.46029462 -5.95519627 Jun 1 105.24573 0.53328051 6.15426902 Jul 1 100.46667 0.32984416 -13.06667265 Aug 1 97.67278 0.23410225 -0.87278452 Sep 1 101.69335 0.33663224 12.40664576 Oct 1 105.77550 0.43388245 4.52449780 Nov 1 106.67954 0.44610753 -2.77954456 Dec 1 105.46051 0.40216468 -3.86051039 Jan 2 103.14813 0.40537961 -8.54813384 Feb 2 101.75442 0.40270977 -5.85442189 Mar 2 99.36325 0.35046264 5.33674574 Apr 2 99.74685 0.35153464 3.05314885 May 2 100.87737 0.38138633 -2.77737491 Jun 2 102.18673 0.41703309 11.71327436 Jul 2 100.20172 0.33203696 -19.30172269 Aug 2 99.86950 0.31112947 -4.16950203 Sep 2 100.94661 0.33244736 12.25338712 Oct 2 101.35088 0.33421713 4.54912059 Nov 2 103.91350 0.38248017 4.88649561 Dec 2 104.65351 0.38919806 -2.35351469 Jan 3 105.23324 0.39238911 -6.23324203 Feb 3 105.44390 0.38916940 -4.74389968 Mar 3 107.19784 0.41845843 8.30215640 Apr 3 105.09955 0.35325497 -4.39955092 May 3 106.78466 0.39217238 3.11533998 Jun 3 105.72363 0.34759395 8.87636599 Jul 3 105.22380 0.32181550 -19.82380292 Aug 3 105.34736 0.31606602 -4.84736141 Sep 3 104.99207 0.29792960 9.80793070 Oct 3 107.62078 0.35605010 8.87921648 Nov 3 108.79608 0.37498557 4.10391974 Dec 3 108.00238 0.34945076 -6.00237959 Jan 4 109.15463 0.36665423 -3.15463142 Feb 4 109.94260 0.37592663 -4.64259999 Mar 4 110.00935 0.36869223 8.79065190 Apr 4 110.36100 0.36826444 -4.26099984 May 4 108.91806 0.32013461 0.38193724 Jun 4 108.24898 0.29299317 8.95102151 Jul 4 109.44591 0.31792474 -16.94591281 Aug 4 109.99833 0.32428020 -5.79832902 Sep 4 108.64018 0.28015472 3.85982039 Oct 4 109.90006 0.30485973 12.49994423 Nov 4 110.07558 0.30171485 3.22442377 Dec 4 109.20603 0.27393813 -9.20602621 Jan 5 110.44832 0.29672501 0.25168241 Feb 5 112.86250 0.34707043 -0.06249808 Mar 5 109.87998 0.26599938 -0.07997504 Apr 5 112.13565 0.31586732 5.16434926 May 5 111.81263 0.29943804 -2.71262774 Jun 5 110.49394 0.25713232 5.40606337 Jul 5 110.84144 0.25950674 -14.84143515 Aug 5 109.23290 0.21071437 -9.43290274 Sep 5 110.12269 0.22820568 6.67730684 Oct 5 108.34448 0.17742944 7.35552330 Nov 5 104.16092 0.06888971 -4.76092227 Dec 5 103.07492 0.04047802 -8.77491956 > m$resid Jan Feb Mar Apr May Jun 1 0.000000000 0.355983430 2.677724124 0.524277644 -1.240984263 0.718438978 2 -1.473012995 -0.984415504 -1.423677694 0.015936983 0.374405976 0.458675405 3 0.099311900 -0.094297612 0.696945242 -1.262921218 0.663873068 -0.728312784 4 0.413329358 0.216233565 -0.157728262 -0.008637796 -0.915032124 -0.500264488 5 0.495801752 1.082494846 -1.697920943 1.011990857 -0.324450755 -0.821824416 Jul Aug Sep Oct Nov Dec 1 -2.759265648 -1.638632156 1.989899805 1.966269624 0.246334626 -0.870790832 2 -1.219035546 -0.342395783 0.397518724 0.037339821 1.158444173 0.185972814 3 -0.429238488 -0.101341346 -0.344952271 1.199940155 0.421988022 -0.602100114 4 0.458898933 0.119539580 -0.860136311 0.501577874 -0.066250650 -0.599998337 5 0.045959251 -0.951746156 0.346469067 -1.024517953 -2.227588425 -0.589954652 > 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/168xv1259938463.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/2a8w11259938463.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/371uy1259938463.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/4lqqw1259938463.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/5wono1259938463.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/6lay61259938463.tab") > system("convert tmp/168xv1259938463.ps tmp/168xv1259938463.png") > system("convert tmp/2a8w11259938463.ps tmp/2a8w11259938463.png") > system("convert tmp/371uy1259938463.ps tmp/371uy1259938463.png") > system("convert tmp/4lqqw1259938463.ps tmp/4lqqw1259938463.png") > system("convert tmp/5wono1259938463.ps tmp/5wono1259938463.png") > > > proc.time() user system elapsed 1.470 0.810 1.889