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(19,18,19,19,22,23,20,14,14,14,15,11,17,16,20,24,23,20,21,19,23,23,23,23,27,26,17,24,26,24,27,27,26,24,23,23,24,17,21,19,22,22,18,16,14,12,14,16,8,3,0,5,1,1,3,6,7,8,14,14,13) > 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 7.474436 0.000000 0.000000 1.482097 > m$fitted level slope sea Jan 1 19.0000000 0.00000000 0.00000000 Feb 1 18.1108870 -0.05123110 -0.05123110 Mar 1 18.9004944 -0.03982780 -0.03982780 Apr 1 19.0130084 -0.03876732 -0.03876732 May 1 21.5816275 -0.02316132 -0.02316132 Jun 1 22.8048158 -0.01591262 -0.01591262 Jul 1 20.4291933 -0.02951171 -0.02951171 Aug 1 14.9787507 -0.06055865 -0.06055865 Sep 1 14.1883374 -0.06471460 -0.06471460 Oct 1 14.0734900 -0.06499845 -0.06499845 Nov 1 14.9076372 -0.05993623 -0.05993623 Dec 1 11.6240202 -0.07798405 -0.07798405 Jan 2 14.1818884 -0.21520681 2.36727488 Feb 2 15.9234675 -0.16311807 -0.16311807 Mar 2 19.5104962 -0.13974362 -0.13974362 Apr 2 23.4378946 -0.12659444 -0.12659444 May 2 23.1537340 -0.12703467 -0.12703467 Jun 2 20.5529785 -0.13377346 -0.13377346 Jul 2 21.0288149 -0.13212277 -0.13212277 Aug 2 19.3912992 -0.13618610 -0.13618610 Sep 2 22.5661622 -0.12727365 -0.12727365 Oct 2 23.0261721 -0.12569710 -0.12569710 Nov 2 23.0926204 -0.12518267 -0.12518267 Dec 2 23.1020166 -0.12482332 -0.12482332 Jan 3 24.8137439 -0.17032477 1.87357253 Feb 3 25.9640351 -0.14740170 -0.14740170 Mar 3 18.4225733 -0.17737759 -0.17737759 Apr 3 23.3088895 -0.16671061 -0.16671061 May 3 25.7243705 -0.16200472 -0.16200472 Jun 3 24.3667737 -0.16413126 -0.16413126 Jul 3 26.7311015 -0.15965681 -0.15965681 Aug 3 27.0736498 -0.15877009 -0.15877009 Sep 3 26.2693249 -0.15990783 -0.15990783 Oct 3 24.4449517 -0.16283614 -0.16283614 Nov 3 23.3264870 -0.16451443 -0.16451443 Dec 3 23.1641428 -0.16451062 -0.16451062 Jan 4 22.3996664 -0.15475768 1.70233443 Feb 4 17.8555215 -0.21128177 -0.21128177 Mar 4 20.6885603 -0.20213681 -0.20213681 Apr 4 19.3896837 -0.20385018 -0.20385018 May 4 21.7634624 -0.20036458 -0.20036458 Jun 4 22.1073864 -0.19964592 -0.19964592 Jul 4 18.7406489 -0.20380837 -0.20380837 Aug 4 16.5441890 -0.20642258 -0.20642258 Sep 4 14.5173749 -0.20880750 -0.20880750 Oct 4 12.5151494 -0.21115399 -0.21115399 Nov 4 13.9329138 -0.20902552 -0.20902552 Dec 4 15.8464655 -0.20625562 -0.20625562 Jan 5 8.0351443 -0.11426285 1.25689137 Feb 5 3.7832354 -0.15661358 -0.15661358 Mar 5 0.6639918 -0.16368219 -0.16368219 Apr 5 4.4837008 -0.15873699 -0.15873699 May 5 1.6201327 -0.16164446 -0.16164446 Jun 5 1.2048976 -0.16191070 -0.16191070 Jul 5 2.8531682 -0.16001850 -0.16001850 Aug 5 5.6548743 -0.15692731 -0.15692731 Sep 5 6.9152050 -0.15544974 -0.15544974 Oct 5 7.9520906 -0.15420797 -0.15420797 Nov 5 13.2280671 -0.14855855 -0.14855855 Dec 5 13.9927947 -0.14760938 -0.14760938 Jan 6 11.9099693 -0.12897002 1.41867023 > m$resid Jan Feb Mar Apr May 1 0.0000000000 -0.2006265304 0.3053177799 0.0558017299 0.9554882156 2 1.1824094863 0.6029756396 1.3672103148 1.4886407675 -0.0576835874 3 0.7476815756 0.4346381356 -2.6988004367 1.8529651134 0.9450316934 4 -0.2359959454 -1.4874786412 1.1117786716 -0.4012865967 0.9432234630 5 -2.9390996086 -1.4255558915 -1.0822967476 1.4573881391 -0.9896845071 6 -0.7398988045 Jun Jul Aug Sep Oct 1 0.4567474296 -0.8647547325 -1.9865702386 -0.2674618311 -0.0183714315 2 -0.9056258152 0.2231774678 -0.5511215555 1.2121661158 0.2150024379 3 -0.4375692932 0.9253801022 0.1837998212 -0.2362634925 -0.6091690231 4 0.1991718261 -1.1589366277 -0.7291724555 -0.6661368644 -0.6562661027 5 -0.0927883579 0.6623425109 1.0836902063 0.5185722074 0.4362732774 6 Nov Dec 1 0.3294931399 -1.1813099336 2 0.0703435645 0.0492686224 3 -0.3497451433 0.0007942541 4 0.5960703394 0.7767145711 5 1.9868935320 0.3341694458 6 > 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/1vvfz1259929519.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/25rk61259929519.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/3ng9m1259929519.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/41ik01259929519.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/5i2c01259929519.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/6vwh11259929519.tab") > system("convert tmp/1vvfz1259929519.ps tmp/1vvfz1259929519.png") > system("convert tmp/25rk61259929519.ps tmp/25rk61259929519.png") > system("convert tmp/3ng9m1259929519.ps tmp/3ng9m1259929519.png") > system("convert tmp/41ik01259929519.ps tmp/41ik01259929519.png") > system("convert tmp/5i2c01259929519.ps tmp/5i2c01259929519.png") > > > proc.time() user system elapsed 1.355 0.833 1.711