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.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,8) > 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.1042804581 0.0004487108 0.0000000000 > m$fitted level slope sea Jan 1 8.100000 0.000000000 0.0000000000 Feb 1 7.702557 -0.397654568 -0.0025567326 Mar 1 7.494897 -0.211174079 0.0051033051 Apr 1 7.595696 0.093416014 0.0043035444 May 1 7.799383 0.201121008 0.0006174757 Jun 1 7.803466 0.008657403 -0.0034659295 Jul 1 7.799290 -0.003878003 0.0007101123 Aug 1 7.504464 -0.288068718 -0.0044642000 Sep 1 7.494279 -0.016638191 0.0057205277 Oct 1 7.106910 -0.378759895 -0.0069098622 Nov 1 7.486307 0.361789855 0.0136931480 Dec 1 7.508357 0.029940118 -0.0083569901 Jan 2 7.597897 0.088147462 0.0021028461 Feb 2 7.701556 0.103302538 -0.0015558831 Mar 2 7.703294 0.005583051 -0.0032941160 Apr 2 7.895264 0.184490441 0.0047358522 May 2 8.095239 0.199355413 0.0047606228 Jun 2 8.210449 0.118569235 -0.0104487506 Jul 2 8.191420 -0.013533187 0.0085799201 Aug 2 8.216204 0.023253009 -0.0162035973 Sep 2 7.883965 -0.318039696 0.0160354536 Oct 2 7.333904 -0.540792911 -0.0339040927 Nov 2 6.873818 -0.463309815 0.0261823250 Dec 2 6.604637 -0.276935581 -0.0046369294 Jan 3 6.690910 0.071711868 0.0090896655 Feb 3 6.891132 0.195129219 0.0088684264 Mar 3 7.013864 0.126330844 -0.0138635588 Apr 3 7.098845 0.087050809 0.0011546336 May 3 7.193943 0.094693235 0.0060565494 Jun 3 7.108990 -0.075940895 -0.0089902382 Jul 3 6.904121 -0.198401706 -0.0041205968 Aug 3 6.997054 0.078314959 0.0029462710 Sep 3 6.785387 -0.197116473 0.0146132189 Oct 3 6.437623 -0.340204554 -0.0376234194 Nov 3 6.653328 0.187815237 0.0466715911 Dec 3 6.626443 -0.016109800 -0.0264426658 Jan 4 6.404133 -0.211931831 -0.0041331520 Feb 4 6.283612 -0.125085726 0.0163875795 Mar 4 6.209516 -0.076973540 -0.0095157390 Apr 4 6.492042 0.262436075 0.0079580102 May 4 6.788114 0.294175283 0.0118860545 Jun 4 6.805493 0.032941926 -0.0054927783 Jul 4 6.441495 -0.341684370 -0.0414952648 Aug 4 6.084132 -0.356481461 0.0158677148 Sep 4 5.759909 -0.326036754 0.0400906456 Oct 4 6.145367 0.345454696 -0.0453671019 Nov 4 7.128373 0.947164762 0.0716267361 Dec 4 7.346156 0.258814332 -0.0461558170 Jan 5 6.930559 -0.377588104 -0.0305589169 Feb 5 6.088273 -0.816192245 0.0117266516 Mar 5 5.803129 -0.317186100 -0.0031293977 Apr 5 6.175680 0.331486771 0.0243199938 May 5 7.066521 0.857215545 0.0334792138 Jun 5 7.698999 0.645953411 0.0010013915 Jul 5 7.955997 0.280310793 -0.0559972288 Aug 5 7.681030 -0.241680984 0.0189700469 Sep 5 7.379416 -0.298021236 0.0205843364 Oct 5 7.580681 0.171335087 -0.0806807643 Nov 5 7.904551 0.314727586 0.0954485430 Dec 5 8.128525 0.229418842 -0.0285254381 Jan 6 8.004034 -0.103240101 -0.0040342249 > m$resid Jan Feb Mar Apr May Jun 1 0.00000000 -1.23520546 0.58280444 0.94292093 0.33353363 -0.59600130 2 0.18028963 0.04704587 -0.30468882 0.55368700 0.04603455 -0.25016995 3 1.07992154 0.38275268 -0.21399176 -0.12156817 0.02366769 -0.52840114 4 -0.60658661 0.26912486 0.14939647 1.05063560 0.09828959 -0.80896259 5 -1.97142932 -1.35856658 1.54791397 2.00833140 1.62799411 -0.65422155 6 -1.03050744 Jul Aug Sep Oct Nov Dec 1 -0.03881834 -0.88005217 0.84053775 -1.12138073 2.29325724 -1.02763766 2 -0.40908107 0.11391565 -1.05687966 -0.68979893 0.23994159 0.57714468 3 -0.37922405 0.85690730 -0.85292734 -0.44310025 1.63511750 -0.63149475 4 -1.16010381 -0.04582209 0.09427800 2.07940472 1.86331594 -2.13161705 5 -1.13228289 -1.61645008 -0.17446862 1.45345384 0.44404401 -0.26417695 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/13xt01259864651.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/2ehnq1259864651.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/3g7ns1259864651.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/44mw61259864651.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/54o6j1259864651.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/6p1hu1259864651.tab") > > system("convert tmp/13xt01259864651.ps tmp/13xt01259864651.png") > system("convert tmp/2ehnq1259864651.ps tmp/2ehnq1259864651.png") > system("convert tmp/3g7ns1259864651.ps tmp/3g7ns1259864651.png") > system("convert tmp/44mw61259864651.ps tmp/44mw61259864651.png") > system("convert tmp/54o6j1259864651.ps tmp/54o6j1259864651.png") > > > proc.time() user system elapsed 1.456 0.815 1.867