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(7.1,6.9,6.8,7.5,7.6,7.8,8.0,8.1,8.2,8.3,8.2,8.0,7.9,7.6,7.6,8.3,8.4,8.4,8.4,8.4,8.6,8.9,8.8,8.3,7.5,7.2,7.4,8.8,9.3,9.3,8.7,8.2,8.3,8.5,8.6,8.5,8.2,8.1,7.9,8.6,8.7,8.7,8.5,8.4,8.5,8.7,8.7,8.6,8.5,8.3,8.0,8.2,8.1,8.1,8.0,7.9,7.9,8.0,8.0,7.9,8.0,7.7,7.2,7.5,7.3,7.0,7.0,7.0,7.2,7.3,7.1,6.8,6.4,6.1,6.5,7.7,7.9,7.5,6.9,6.6,6.9,7.7,8.0,8.0,7.7,7.3,7.4,8.1,8.3,8.2) > 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.000000000 0.078087289 0.001962641 0.000000000 > m$fitted level slope sea Jan 1 7.100000 0.000000000 0.000000e+00 Feb 1 6.907270 -0.193330798 -7.270031e-03 Mar 1 6.788503 -0.125492051 1.149694e-02 Apr 1 7.445911 0.583043512 5.408916e-02 May 1 7.642832 0.234136871 -4.283227e-02 Jun 1 7.798318 0.163006920 1.682234e-03 Jul 1 7.996040 0.194403161 3.959883e-03 Aug 1 8.106747 0.118713362 -6.747052e-03 Sep 1 8.200261 0.095924681 -2.610349e-04 Oct 1 8.299339 0.098776714 6.605657e-04 Nov 1 8.213420 -0.068251335 -1.342017e-02 Dec 1 8.006501 -0.193653804 -6.501455e-03 Jan 2 7.891475 -0.122595520 8.525405e-03 Feb 2 7.592171 -0.282536963 7.828789e-03 Mar 2 7.641824 0.005965984 -4.182417e-02 Apr 2 8.166555 0.459782394 1.334447e-01 May 2 8.459652 0.314615544 -5.965220e-02 Jun 2 8.436127 0.019880940 -3.612741e-02 Jul 2 8.387170 -0.040133871 1.283013e-02 Aug 2 8.395761 0.002343815 4.239186e-03 Sep 2 8.590818 0.170341921 9.181821e-03 Oct 2 8.878517 0.272648614 2.148324e-02 Nov 2 8.831833 -0.005740939 -3.183258e-02 Dec 2 8.362005 -0.410263807 -6.200481e-02 Jan 3 7.493230 -0.809740170 6.769680e-03 Feb 3 7.155110 -0.398327006 4.488987e-02 Mar 3 7.455831 0.201888959 -5.583114e-02 Apr 3 8.580391 0.998089411 2.196088e-01 May 3 9.355776 0.806473460 -5.577572e-02 Jun 3 9.399366 0.150037180 -9.936619e-02 Jul 3 8.748069 -0.539751201 -4.806932e-02 Aug 3 8.199997 -0.546913970 2.812490e-06 Sep 3 8.259281 -0.025109682 4.071912e-02 Oct 3 8.454125 0.164224349 4.587464e-02 Nov 3 8.601614 0.149818622 -1.614115e-03 Dec 3 8.500574 -0.066055940 -5.739969e-04 Jan 4 8.224643 -0.246655837 -2.464254e-02 Feb 4 8.094430 -0.146446878 5.570320e-03 Mar 4 8.091428 -0.023899781 -1.914284e-01 Apr 4 8.374547 0.239146392 2.254531e-01 May 4 8.685848 0.300882147 1.415231e-02 Jun 4 8.705697 0.060546304 -5.697246e-03 Jul 4 8.534304 -0.137888067 -3.430384e-02 Aug 4 8.463296 -0.080664963 -6.329550e-02 Sep 4 8.483687 0.005799141 1.631301e-02 Oct 4 8.652678 0.145426081 4.732158e-02 Nov 4 8.688249 0.051440211 1.175135e-02 Dec 4 8.579968 -0.085164847 2.003150e-02 Jan 5 8.523743 -0.060407910 -2.374288e-02 Feb 5 8.313112 -0.188854973 -1.311180e-02 Mar 5 8.227762 -0.100708918 -2.277622e-01 Apr 5 8.014479 -0.196744756 1.855206e-01 May 5 8.032989 -0.013201492 6.701142e-02 Jun 5 8.062551 0.023236845 3.744894e-02 Jul 5 8.039705 -0.016042062 -3.970540e-02 Aug 5 7.978028 -0.054945006 -7.802831e-02 Sep 5 7.916152 -0.060853518 -1.615240e-02 Oct 5 7.935452 0.007474677 6.454802e-02 Nov 5 7.965201 0.026460192 3.479932e-02 Dec 5 7.898724 -0.052735508 1.276039e-03 Jan 6 7.986233 0.066812164 1.376651e-02 Feb 6 7.756320 -0.185943522 -5.631952e-02 Mar 6 7.414814 -0.318120961 -2.148137e-01 Apr 6 7.323548 -0.125148100 1.764515e-01 May 6 7.238291 -0.091217045 6.170902e-02 Jun 6 6.973577 -0.238688394 2.642299e-02 Jul 6 7.005353 -0.008747369 -5.353436e-03 Aug 6 7.066928 0.051048684 -6.692774e-02 Sep 6 7.217769 0.135906562 -1.776890e-02 Oct 6 7.250714 0.048356838 4.928580e-02 Nov 6 7.076114 -0.141195912 2.388569e-02 Dec 6 6.844175 -0.218330677 -4.417457e-02 Jan 7 6.368119 -0.437471930 3.188140e-02 Feb 7 6.106877 -0.287734886 -6.876636e-03 Mar 7 6.669521 0.433565870 -1.695206e-01 Apr 7 7.490874 0.762752725 2.091263e-01 May 7 7.836395 0.408516713 6.360520e-02 Jun 7 7.573331 -0.161303494 -7.333105e-02 Jul 7 6.960120 -0.544773139 -6.011984e-02 Aug 7 6.668516 -0.329902994 -6.851580e-02 Sep 7 6.864719 0.116633535 3.528087e-02 Oct 7 7.569287 0.615626984 1.307131e-01 Nov 7 7.981835 0.443299262 1.816504e-02 Dec 7 8.013399 0.093946481 -1.339897e-02 Jan 8 7.695477 -0.255609700 4.523134e-03 Feb 8 7.438484 -0.256782820 -1.384840e-01 Mar 8 7.625319 0.118993667 -2.253194e-01 Apr 8 7.854091 0.212037450 2.459095e-01 May 8 8.134006 0.269582263 1.659941e-01 Jun 8 8.195504 0.093268239 4.496130e-03 > m$resid Jan Feb Mar Apr May Jun 1 0.000000000 -0.704226736 0.252756347 2.525889906 -1.249084577 -0.254542712 2 0.254523476 -0.577275217 1.044832371 1.623368169 -0.519354046 -1.054865898 3 -1.431306183 1.474986800 2.155555272 2.852960479 -0.685193451 -2.349513192 4 -0.647074252 0.358638821 0.439135973 0.942689688 0.220765089 -0.860125488 5 0.088678778 -0.459524459 0.315642902 -0.344087289 0.656468789 0.130392331 6 0.428103429 -0.904194444 -0.473185742 0.691228126 0.121381260 -0.527675276 7 -0.784590557 0.535674494 2.581869427 1.178905961 -1.267376879 -2.038821645 8 -1.251331861 -0.004196929 1.344981474 0.333163349 0.205901647 -0.630844684 Jul Aug Sep Oct Nov Dec 1 0.112354031 -0.270861433 -0.081550950 0.010206206 -0.597721993 -0.448761836 2 -0.214765078 0.152009932 0.601193315 0.366112006 -0.996241651 -1.447627692 3 -2.468446251 -0.025632465 1.867315447 0.677547024 -0.051552241 -0.772568313 4 -0.710132747 0.204775138 0.309418720 0.499669444 -0.336333862 -0.488923484 5 -0.140570424 -0.139215456 -0.021144114 0.244520745 0.067940418 -0.283469326 6 0.822912849 0.213983038 0.303671324 -0.313307336 -0.678325316 -0.276101578 7 -1.372346518 0.768927975 1.597968660 1.785702422 -0.616691422 -1.250502144 8 > 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/16s5s1259936244.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/2wscx1259936244.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/39qy01259936244.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/4shgt1259936244.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/595v41259936244.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/683qk1259936244.tab") > system("convert tmp/16s5s1259936244.ps tmp/16s5s1259936244.png") > system("convert tmp/2wscx1259936244.ps tmp/2wscx1259936244.png") > system("convert tmp/39qy01259936244.ps tmp/39qy01259936244.png") > system("convert tmp/4shgt1259936244.ps tmp/4shgt1259936244.png") > system("convert tmp/595v41259936244.ps tmp/595v41259936244.png") > > > proc.time() user system elapsed 1.572 0.821 1.776