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,8.1,7.7,7.5,7.6,7.8,7.8,7.8,7.5,7.5,7.1,7.5,7.5,7.6,7.7,7.7,7.9,8.1,8.2,8.2,8.2,7.9,7.3,6.9,6.6,6.7,6.9,7,7.1,7.2,7.1,6.9,7,6.8,6.4,6.7,6.6,6.4,6.3,6.2,6.5,6.8,6.8,6.4,6.1,5.8,6.1,7.2,7.3,6.9,6.1,5.8,6.2,7.1,7.7,7.9,7.7,7.4,7.5,8,8.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.0000000000 0.1019620467 0.0005129176 0.0000000000 > m$fitted level slope sea Jan 1 8.000000 0.000000000 0.000000e+00 Feb 1 8.099253 0.099315147 7.465517e-04 Mar 1 7.710337 -0.378431686 -1.033729e-02 Apr 1 7.495181 -0.219599500 4.818554e-03 May 1 7.595434 0.091691512 4.566203e-03 Jun 1 7.799975 0.201528226 2.457048e-05 Jul 1 7.804706 0.009987491 -4.705505e-03 Aug 1 7.799907 -0.004403528 9.304201e-05 Sep 1 7.505818 -0.286350290 -5.817702e-03 Oct 1 7.494145 -0.019010512 5.854783e-03 Nov 1 7.108587 -0.375766195 -8.586671e-03 Dec 1 7.484998 0.356316841 1.500203e-02 Jan 2 7.508643 0.032587077 -8.642610e-03 Feb 2 7.584915 0.075118118 1.508510e-02 Mar 2 7.708476 0.121471978 -8.476061e-03 Apr 2 7.705455 0.002614340 -5.455245e-03 May 2 7.894645 0.180749509 5.355432e-03 Jun 2 8.094897 0.199372470 5.103198e-03 Jul 2 8.212195 0.121001741 -1.219543e-02 Aug 2 8.190999 -0.014779135 9.000559e-03 Sep 2 8.218525 0.025616285 -1.852473e-02 Oct 2 7.882499 -0.319706625 1.750106e-02 Nov 2 7.338697 -0.533690186 -3.869729e-02 Dec 2 6.871402 -0.470291520 2.859776e-02 Jan 3 6.603119 -0.277433261 -3.119228e-03 Feb 3 6.679771 0.060800898 2.022895e-02 Mar 3 6.895147 0.206784536 4.852619e-03 Apr 3 7.017675 0.127210418 -1.767499e-02 May 3 7.098848 0.083750929 1.152068e-03 Jun 3 7.193187 0.093748225 6.812782e-03 Jul 3 7.110072 -0.073243155 -1.007201e-02 Aug 3 6.905588 -0.197156910 -5.587959e-03 Sep 3 6.996422 0.074754907 3.578243e-03 Oct 3 6.784247 -0.196156011 1.575326e-02 Nov 3 6.441740 -0.334337352 -4.173984e-02 Dec 3 6.649642 0.177618078 5.035849e-02 Jan 4 6.626242 -0.012142322 -2.624203e-02 Feb 4 6.399276 -0.215023499 7.236778e-04 Mar 4 6.285042 -0.120512429 1.495804e-02 Apr 4 6.212390 -0.075594133 -1.239007e-02 May 4 6.491613 0.257180477 8.386883e-03 Jun 4 6.786248 0.292315280 1.375188e-02 Jul 4 6.806395 0.036997837 -6.394989e-03 Aug 4 6.446778 -0.335055757 -4.677829e-02 Sep 4 6.082242 -0.362710690 1.775819e-02 Oct 4 5.756800 -0.327750061 4.320033e-02 Nov 4 6.149117 0.347731453 -4.911730e-02 Dec 4 7.123165 0.935235839 7.683499e-02 Jan 5 7.346627 0.267642099 -4.662679e-02 Feb 5 6.930410 -0.373894944 -3.040979e-02 Mar 5 6.090483 -0.809120970 9.516614e-03 Apr 5 5.806658 -0.318031898 -6.658311e-03 May 5 6.174446 0.322660083 2.555440e-02 Jun 5 7.062534 0.850975542 3.746601e-02 Jul 5 7.699470 0.650976480 5.304351e-04 Aug 5 7.961492 0.287541530 -6.149210e-02 Sep 5 7.680024 -0.244131221 1.997552e-02 Oct 5 7.380650 -0.295750353 1.935043e-02 Nov 5 7.587455 0.173834196 -8.745451e-02 Dec 5 7.898961 0.302465201 1.010387e-01 Jan 6 8.123419 0.229583419 -2.341871e-02 > m$resid Jan Feb Mar Apr May Jun 1 0.00000000 0.31214466 -1.51214927 0.49720647 0.97488894 0.34397613 2 -1.01407990 0.13356792 0.14627231 -0.37195514 0.55790281 0.05832151 3 0.60414959 1.06092959 0.45930775 -0.24904615 -0.13611122 0.03130854 4 -0.59448717 -0.63580092 0.29679686 0.14061809 1.04216848 0.11003256 5 -2.09154345 -2.00952585 -1.36527913 1.53770947 2.00636950 1.65455577 6 -0.22833451 Jul Aug Sep Oct Nov Dec 1 -0.59984892 -0.04506841 -0.88297384 0.83722909 -1.11725325 2.29266748 2 -0.24543400 -0.42522553 0.12650651 -1.08144919 -0.67013327 0.19854604 3 -0.52296789 -0.38806122 0.85154738 -0.84841285 -0.43274342 1.60329588 4 -0.79957850 -1.16516197 -0.08660707 0.10948635 2.11541275 1.83989654 5 -0.62633683 -1.13817114 -1.66504181 -0.16165588 1.47060399 0.40283837 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/10wnv1259940758.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/2fi5k1259940758.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/3xnim1259940758.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/4gaye1259940758.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/5kpok1259940758.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/6lawn1259940758.tab") > system("convert tmp/10wnv1259940758.ps tmp/10wnv1259940758.png") > system("convert tmp/2fi5k1259940758.ps tmp/2fi5k1259940758.png") > system("convert tmp/3xnim1259940758.ps tmp/3xnim1259940758.png") > system("convert tmp/4gaye1259940758.ps tmp/4gaye1259940758.png") > system("convert tmp/5kpok1259940758.ps tmp/5kpok1259940758.png") > > > proc.time() user system elapsed 1.353 0.794 1.559