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(114,116,153,162,161,149,139,135,130,127,122,117,112,113,149,157,157,147,137,132,125,123,117,114,111,112,144,150,149,134,123,116,117,111,105,102,95,93,124,130,124,115,106,105,105,101,95,93,84,87,116,120,117,109,105,107,109,109,108,107) > 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.4822417 38.5899916 4.5267154 0.0000000 > m$fitted level slope sea Jan 1 114.00000 0.0000000 0.000000000 Feb 1 115.70264 1.6689605 0.297356259 Mar 1 146.49498 23.6504665 6.505022147 Apr 1 164.65715 19.3405365 -2.657147603 May 1 164.27142 4.1302701 -3.271417160 Jun 1 151.00628 -9.3017670 -2.006279203 Jul 1 138.32367 -11.9161279 0.676329690 Aug 1 133.11929 -6.7258894 1.880708589 Sep 1 129.44270 -4.3682224 0.557301880 Oct 1 126.54498 -3.2313358 0.455023700 Nov 1 122.00862 -4.2402980 -0.008616712 Dec 1 116.78254 -5.0024522 0.217459461 Jan 2 112.41781 -4.5108216 -0.417809434 Feb 2 118.48352 3.6157346 -5.483516781 Mar 2 139.91774 16.7862874 9.082259146 Apr 2 157.03440 17.0329433 -0.034397051 May 2 159.55604 6.2214418 -2.556040950 Jun 2 150.46714 -5.1390679 -3.467136774 Jul 2 138.28020 -10.3766718 -1.280202615 Aug 2 129.81187 -8.9576169 2.188127050 Sep 2 124.15373 -6.5040859 0.846267794 Oct 2 121.58652 -3.5767156 1.413477146 Nov 2 116.66684 -4.5750844 0.333163604 Dec 2 112.45563 -4.3048231 1.544368762 Jan 3 112.39867 -1.1489673 -1.398667600 Feb 3 120.97583 6.0700697 -8.975831257 Mar 3 135.12862 11.9974008 8.871384077 Apr 3 147.55849 12.3153389 2.441507504 May 3 150.04188 5.0719831 -1.041880900 Jun 3 138.67650 -6.9963398 -4.676504476 Jul 3 125.33364 -11.6566247 -2.333643000 Aug 3 114.23693 -11.2451011 1.763073633 Sep 3 114.57609 -2.7290185 2.423909436 Oct 3 109.63885 -4.3522255 1.361152616 Nov 3 104.07127 -5.2451383 0.928727998 Dec 3 100.34098 -4.1329062 1.659018253 Jan 4 98.33747 -2.5682632 -3.337469302 Feb 4 103.36073 3.0019903 -10.360733954 Mar 4 114.98922 9.2952921 9.010776967 Apr 4 125.74731 10.3634583 4.252690816 May 4 123.47154 1.1138767 0.528455814 Jun 4 118.48887 -3.3389712 -3.488865605 Jul 4 109.45915 -7.4929244 -3.459149886 Aug 4 105.48742 -4.9206745 -0.487422200 Sep 4 101.73800 -4.0647617 3.261998653 Oct 4 98.69531 -3.3179498 2.304691496 Nov 4 94.02639 -4.3045859 0.973607863 Dec 4 90.88877 -3.4525392 2.111232013 Jan 5 89.00083 -2.3094551 -5.000825880 Feb 5 98.04957 5.9774550 -11.049567025 Mar 5 107.66584 8.6234569 8.334158815 Apr 5 113.44764 6.5561105 6.552359926 May 5 115.68811 3.4110444 1.311888600 Jun 5 112.28361 -1.5509581 -3.283608379 Jul 5 109.55087 -2.4106734 -4.550869707 Aug 5 107.75151 -1.9657616 -0.751506810 Sep 5 105.87378 -1.9016652 3.126220003 Oct 5 105.53889 -0.7610191 3.461111358 Nov 5 106.27378 0.3276421 1.726223998 Dec 5 105.19624 -0.6950110 1.803763201 > m$resid Jan Feb Mar Apr May Jun 1 0.00000000 0.29487673 3.77191065 -0.69617385 -2.44030142 -2.16432048 2 0.07970023 1.32125873 2.12504634 0.04010539 -1.73463267 -1.82834303 3 0.50976242 1.16243050 0.95401262 0.05145660 -1.16503411 -1.94055269 4 0.25234667 0.89611298 1.01286249 0.17246251 -1.48917830 -0.71603846 5 0.18419748 1.33313803 0.42588331 -0.33340060 -0.50649753 -0.79813575 Jul Aug Sep Oct Nov Dec 1 -0.42084426 0.83550974 0.37953088 0.18301199 -0.16241929 -0.12268895 2 -0.84344358 0.22842533 0.39495998 0.47125226 -0.16071362 0.04352661 3 -0.75042548 0.06624935 1.37086005 -0.26131190 -0.14373988 0.17918413 4 -0.66869704 0.41411490 0.13777969 0.12022188 -0.15883814 0.13726594 5 -0.13836615 0.07162543 0.01031801 0.18361874 0.17527494 -0.16473000 > 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/1cyb31259947223.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/2t70a1259947223.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/3yfwy1259947223.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/4n9xd1259947223.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/5yuef1259947223.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/69ycu1259947223.tab") > system("convert tmp/1cyb31259947223.ps tmp/1cyb31259947223.png") > system("convert tmp/2t70a1259947223.ps tmp/2t70a1259947223.png") > system("convert tmp/3yfwy1259947223.ps tmp/3yfwy1259947223.png") > system("convert tmp/4n9xd1259947223.ps tmp/4n9xd1259947223.png") > system("convert tmp/5yuef1259947223.ps tmp/5yuef1259947223.png") > > > proc.time() user system elapsed 1.272 0.799 1.469