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(8.6,8.5,8.3,7.8,7.8,8,8.6,8.9,8.9,8.6,8.3,8.3,8.3,8.4,8.5,8.4,8.6,8.5,8.5,8.4,8.5,8.5,8.5,8.5,8.5,8.5,8.5,8.5,8.6,8.4,8.1,8,8,8,8,7.9,7.8,7.8,7.9,8.1,8,7.6,7.3,7,6.8,7,7.1,7.2,7.1,6.9,6.7,6.7,6.6,6.9,7.3,7.5,7.3,7.1,6.9,7.1) > 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 0.00000000 0.04101695 0.00000000 0.00000000 > m$fitted level slope sea Jan 1 8.6 0.000000e+00 0.000000e+00 Feb 1 8.5 -1.000000e-01 -8.869452e-12 Mar 1 8.3 -2.000000e-01 -3.547781e-11 Apr 1 7.8 -5.000000e-01 5.765144e-11 May 1 7.8 -1.110223e-16 5.765144e-11 Jun 1 8.0 2.000000e-01 5.765144e-11 Jul 1 8.6 6.000000e-01 5.765144e-11 Aug 1 8.9 3.000000e-01 5.765144e-11 Sep 1 8.9 -1.110223e-16 5.765144e-11 Oct 1 8.6 -3.000000e-01 5.765144e-11 Nov 1 8.3 -3.000000e-01 5.765144e-11 Dec 1 8.3 5.551115e-16 5.765144e-11 Jan 2 8.3 4.301692e-10 -3.725170e-10 Feb 2 8.4 1.000000e-01 -4.966893e-10 Mar 2 8.5 1.000000e-01 7.095561e-11 Apr 2 8.4 -1.000000e-01 1.330418e-10 May 2 8.6 2.000000e-01 1.330418e-10 Jun 2 8.5 -1.000000e-01 1.330418e-10 Jul 2 8.5 8.049117e-16 1.330418e-10 Aug 2 8.4 -1.000000e-01 1.330418e-10 Sep 2 8.5 1.000000e-01 1.330418e-10 Oct 2 8.5 -2.498002e-16 1.330418e-10 Nov 2 8.5 -6.171702e-18 1.330418e-10 Dec 2 8.5 2.374568e-16 1.330418e-10 Jan 3 8.5 7.361650e-10 -6.031227e-10 Feb 3 8.5 1.241722e-10 -7.272951e-10 Mar 3 8.5 -8.603378e-10 1.330418e-10 Apr 3 8.5 6.175907e-17 1.330418e-10 May 3 8.6 1.000000e-01 1.330418e-10 Jun 3 8.4 -2.000000e-01 1.330418e-10 Jul 3 8.1 -3.000000e-01 1.330418e-10 Aug 3 8.0 -1.000000e-01 1.330418e-10 Sep 3 8.0 3.885781e-16 1.330418e-10 Oct 3 8.0 6.331112e-16 1.330418e-10 Nov 3 8.0 -1.053406e-17 1.330418e-10 Dec 3 7.9 -1.000000e-01 1.330418e-10 Jan 4 7.8 -1.000000e-01 -6.031227e-10 Feb 4 7.8 5.765143e-10 -1.019987e-09 Mar 4 7.9 1.000000e-01 1.862585e-10 Apr 4 8.1 2.000000e-01 1.552154e-10 May 4 8.0 -1.000000e-01 1.552154e-10 Jun 4 7.6 -4.000000e-01 1.552154e-10 Jul 4 7.3 -3.000000e-01 1.552154e-10 Aug 4 7.0 -3.000000e-01 1.552154e-10 Sep 4 6.8 -2.000000e-01 1.552154e-10 Oct 4 7.0 2.000000e-01 1.552154e-10 Nov 4 7.1 1.000000e-01 1.552154e-10 Dec 4 7.2 1.000000e-01 1.552154e-10 Jan 5 7.1 -1.000000e-01 -6.563394e-10 Feb 5 6.9 -2.000000e-01 -1.046595e-09 Mar 5 6.7 -2.000000e-01 1.862585e-10 Apr 5 6.7 -1.665335e-16 1.241723e-10 May 5 6.6 -1.000000e-01 1.241723e-10 Jun 5 6.9 3.000000e-01 1.241723e-10 Jul 5 7.3 4.000000e-01 1.241723e-10 Aug 5 7.5 2.000000e-01 1.241723e-10 Sep 5 7.3 -2.000000e-01 1.241723e-10 Oct 5 7.1 -2.000000e-01 1.241723e-10 Nov 5 6.9 -2.000000e-01 1.241723e-10 Dec 5 7.1 2.000000e-01 1.241723e-10 > m$resid Jan Feb Mar Apr May 1 0.000000e+00 -4.937627e-01 -4.937627e-01 -1.481288e+00 2.468814e+00 2 2.124012e-09 4.937627e-01 -4.204228e-09 -9.875255e-01 1.481288e+00 3 3.634907e-09 -3.021792e-09 -4.861144e-09 4.248028e-09 4.937627e-01 4 3.634903e-09 4.937627e-01 4.937627e-01 4.937627e-01 -1.481288e+00 5 -9.875255e-01 -4.937627e-01 -7.226029e-09 9.875255e-01 -4.937627e-01 Jun Jul Aug Sep Oct 1 9.875255e-01 1.975051e+00 -1.481288e+00 -1.481288e+00 -1.481288e+00 2 -1.481288e+00 4.937627e-01 -4.937627e-01 9.875255e-01 -4.937627e-01 3 -1.481288e+00 -4.937627e-01 9.875255e-01 4.937627e-01 1.207414e-15 4 -1.481288e+00 4.937627e-01 -4.630318e-17 4.937627e-01 1.975051e+00 5 1.975051e+00 4.937627e-01 -9.875255e-01 -1.975051e+00 -2.662140e-15 Nov Dec 1 9.874283e-15 1.481288e+00 2 1.202947e-15 1.202947e-15 3 -3.178080e-15 -4.937627e-01 4 -4.937627e-01 4.339191e-15 5 6.108849e-15 1.975051e+00 > 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/1bs3p1259922644.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/2lir71259922644.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/32ng61259922644.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/4u71c1259922644.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/5tx4a1259922644.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/6u1wn1259922644.tab") > system("convert tmp/1bs3p1259922644.ps tmp/1bs3p1259922644.png") > system("convert tmp/2lir71259922644.ps tmp/2lir71259922644.png") > system("convert tmp/32ng61259922644.ps tmp/32ng61259922644.png") > system("convert tmp/4u71c1259922644.ps tmp/4u71c1259922644.png") > system("convert tmp/5tx4a1259922644.ps tmp/5tx4a1259922644.png") > > > proc.time() user system elapsed 1.292 0.798 1.807