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(111.4,87.4,96.8,114.1,110.3,103.9,101.6,94.6,95.9,104.7,102.8,98.1,113.9,80.9,95.7,113.2,105.9,108.8,102.3,99,100.7,115.5,100.7,109.9,114.6,85.4,100.5,114.8,116.5,112.9,102,106,105.3,118.8,106.1,109.3,117.2,92.5,104.2,112.5,122.4,113.3,100,110.7,112.8,109.8,117.3,109.1,115.9,96,99.8,116.8,115.7,99.4,94.3,91,93.2,103.1,94.1,91.8,102.7) > 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 7.463662 0.000000 13.288176 0.000000 > m$fitted level slope sea Jan 1 111.40000 0.000000000 0.0000000 Feb 1 99.89595 -0.224183712 -12.4959539 Mar 1 94.33931 -0.569131349 2.4606907 Apr 1 101.72356 -0.098844172 12.3764351 May 1 106.85980 0.116819812 3.4401959 Jun 1 107.06397 0.119137785 -3.1639709 Jul 1 104.94813 0.077315108 -3.3481280 Aug 1 100.23202 0.001622091 -5.6320159 Sep 1 97.16680 -0.045218853 -1.2668015 Oct 1 99.29584 -0.011482554 5.4041635 Nov 1 101.29694 0.020245924 1.5030638 Dec 1 100.59111 0.008764324 -2.4911117 Jan 2 102.81422 -0.031859351 11.0857781 Feb 2 99.79355 -0.011712459 -18.8935478 Mar 2 98.98743 -0.024086085 -3.2874252 Apr 2 100.82159 0.025779953 12.3784061 May 2 101.60986 0.047016715 4.2901447 Jun 2 104.72830 0.119765190 4.0716969 Jul 2 104.48541 0.112983400 -2.1854087 Aug 2 104.04218 0.104658715 -5.0421839 Sep 2 103.84629 0.100876709 -3.1462939 Oct 2 106.65123 0.129654256 8.8487675 Nov 2 104.48921 0.111252194 -3.7892104 Dec 2 107.22867 0.122407658 2.6713320 Jan 3 105.88402 0.121336015 8.7159824 Feb 3 105.12261 0.118582982 -19.7226145 Mar 3 105.14315 0.117625157 -4.6431535 Apr 3 104.62037 0.107496289 10.1796350 May 3 108.14351 0.171337116 8.3564884 Jun 3 109.10491 0.185930299 3.7950859 Jul 3 107.40287 0.154943985 -5.4028684 Aug 3 108.60417 0.169321677 -2.6041716 Sep 3 109.36481 0.175880165 -4.0648089 Oct 3 109.50792 0.175598725 9.2920772 Nov 3 110.15824 0.178568839 -4.0582443 Dec 3 108.58835 0.170817746 0.7116494 Jan 4 108.04911 0.168039804 9.1508877 Feb 4 109.66009 0.175858398 -17.1600934 Mar 4 110.04918 0.177665423 -5.8491799 Apr 4 108.04301 0.152169523 4.4569884 May 4 109.98586 0.176858386 12.4141444 Jun 4 110.02308 0.174855752 3.2769220 Jul 4 108.64560 0.153848165 -8.6456036 Aug 4 110.30510 0.171707941 0.3948988 Sep 4 113.21706 0.198633910 -0.4170600 Oct 4 109.03030 0.164403278 0.7697032 Nov 4 112.37014 0.183820112 4.9298610 Dec 4 111.70688 0.179516311 -2.6068753 Jan 5 110.01186 0.170129701 5.8881391 Feb 5 110.76773 0.173635600 -14.7677334 Mar 5 108.71927 0.156503025 -8.9192738 Apr 5 110.06769 0.167911014 6.7323070 May 5 107.72895 0.140447058 7.9710489 Jun 5 102.69597 0.080928095 -3.2959743 Jul 5 102.25697 0.075119340 -7.9569677 Aug 5 98.12063 0.032353947 -7.1206289 Sep 5 94.82116 0.003154854 -1.6211629 Oct 5 97.56718 0.023258994 5.5328165 Nov 5 94.64541 0.005137890 -0.5454119 Dec 5 93.40916 -0.001664256 -1.6091644 Jan 6 94.31739 0.003299044 8.3826120 > m$resid Jan Feb Mar Apr May Jun 1 0.00000000 -3.77471157 -1.33271606 2.46831244 1.83558024 0.03169882 2 0.84910727 -1.13177845 -0.27372081 0.62362345 0.26372919 1.09584152 3 -0.53904502 -0.32169040 -0.03485286 -0.22398659 1.19974495 0.28155200 4 -0.25875673 0.52248071 0.07638440 -0.77612693 0.63649726 -0.04996145 5 -0.68126382 0.21194795 -0.79942868 0.42698895 -0.89761906 -1.85854963 6 0.33035312 Jul Aug Sep Oct Nov Dec 1 -0.81654457 -1.75189481 -1.11964242 0.79286236 0.73338150 -0.26450749 2 -0.13147823 -0.20288370 -0.10982179 0.98790817 -0.83656362 0.96055429 3 -0.68149193 0.38049467 0.21566162 -0.01195669 0.17320452 -0.63798626 4 -0.55986364 0.54622023 0.99712914 -1.59748157 1.15692001 -0.30847110 5 -0.18766396 -1.52625463 -1.21053837 0.99773816 -1.07157936 -0.45145229 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/1xjww1259702445.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/2eolv1259702445.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/3icom1259702445.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/44xfg1259702445.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/5jtsx1259702445.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/6e9wx1259702445.tab") > system("convert tmp/1xjww1259702445.ps tmp/1xjww1259702445.png") > system("convert tmp/2eolv1259702445.ps tmp/2eolv1259702445.png") > system("convert tmp/3icom1259702445.ps tmp/3icom1259702445.png") > system("convert tmp/44xfg1259702445.ps tmp/44xfg1259702445.png") > system("convert tmp/5jtsx1259702445.ps tmp/5jtsx1259702445.png") > > > proc.time() user system elapsed 1.491 0.884 1.752