R version 2.13.0 (2011-04-13) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-pc-linux-gnu (32-bit) 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(101.76,102.37,102.38,102.86,102.87,102.92,102.95,103.02,104.08,104.16,104.24,104.33,104.73,104.86,105.03,105.62,105.63,105.63,105.94,106.61,107.69,107.78,107.93,108.48,108.14,108.48,108.48,108.89,108.93,109.21,109.47,109.80,111.73,111.85,112.12,112.15,112.17,112.67,112.80,113.44,113.53,114.53,114.51,115.05,116.67,117.07,116.92,117.00,117.02,117.35,117.36,117.82,117.88,118.24,118.50,118.80,119.76,120.09) > 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.078186056 0.002137863 0.006093098 0.000000000 > m$fitted level slope sea Jan 1 101.7600 0.00000000 0.000000000 Feb 1 102.3175 0.03471860 0.052527282 Mar 1 102.3631 0.03537100 0.016903297 Apr 1 102.7660 0.06182677 0.093987862 May 1 102.8565 0.06439382 0.013474006 Jun 1 102.8951 0.06170220 0.024855807 Jul 1 102.9233 0.05780779 0.026733595 Aug 1 102.9864 0.05846742 0.033639220 Sep 1 103.9064 0.17168656 0.173615991 Oct 1 104.1624 0.18317896 -0.002351654 Nov 1 104.2311 0.16715974 0.008888937 Dec 1 104.3064 0.15405268 0.023597775 Jan 2 104.8605 0.20711741 -0.130469594 Feb 2 104.8566 0.17623744 0.003363404 Mar 2 105.0690 0.18151456 -0.039025951 Apr 2 105.4947 0.21728865 0.125267205 May 2 105.6576 0.20928709 -0.027563137 Jun 2 105.6520 0.17763983 -0.022031425 Jul 2 105.8812 0.18524587 0.058808507 Aug 2 106.5981 0.26384910 0.011924597 Sep 2 107.4500 0.35088914 0.239995875 Oct 2 107.8200 0.35372170 -0.040014813 Nov 2 107.9715 0.32375640 -0.041538110 Dec 2 108.4742 0.35019604 0.005820055 Jan 3 108.3698 0.28346985 -0.229835685 Feb 3 108.5026 0.26120384 -0.022559420 Mar 3 108.5958 0.23651896 -0.115840947 Apr 3 108.7541 0.22496301 0.135922516 May 3 108.9060 0.21416193 0.023991444 Jun 3 109.1951 0.22523895 0.014932550 Jul 3 109.4916 0.23578814 -0.021641959 Aug 3 109.8725 0.25724097 -0.072496921 Sep 3 111.2279 0.41965620 0.502063440 Oct 3 111.8671 0.45211776 -0.017074626 Nov 3 112.2490 0.44174303 -0.129011290 Dec 3 112.1890 0.36773034 -0.038971201 Jan 4 112.3902 0.34318023 -0.220198531 Feb 4 112.6631 0.33280180 0.006944535 Mar 4 112.9088 0.32000483 -0.108784345 Apr 4 113.2630 0.32504795 0.176976886 May 4 113.5193 0.31489911 0.010674793 Jun 4 114.3620 0.39283914 0.167971386 Jul 4 114.6179 0.37261819 -0.107911585 Aug 4 115.2849 0.41608041 -0.234914565 Sep 4 116.1315 0.47963653 0.538533115 Oct 4 117.0003 0.53709727 0.069684043 Nov 4 117.0856 0.47044060 -0.165593724 Dec 4 117.1084 0.40449440 -0.108378747 Jan 5 117.2707 0.36878406 -0.250661658 Feb 5 117.3729 0.32947823 -0.022915778 Mar 5 117.4977 0.29937926 -0.137660005 Apr 5 117.6493 0.27763154 0.170744600 May 5 117.9503 0.28108931 -0.070340427 Jun 5 118.0704 0.25733535 0.169612596 Jul 5 118.5967 0.29700405 -0.096688310 Aug 5 119.1029 0.32785373 -0.302877514 Sep 5 119.3481 0.31566802 0.411897415 Oct 5 119.8734 0.34657441 0.216624672 > m$resid Jan Feb Mar Apr May Jun 1 0.00000000 1.21653408 0.03748073 1.26006629 0.09706146 -0.08633555 2 1.47412310 -0.61391939 0.11447027 0.78666831 -0.17480508 -0.68946249 3 -1.52703398 -0.46657340 -0.52880654 -0.25096350 -0.23353341 0.23928721 4 -0.54425958 -0.22151203 -0.27444783 0.10944001 -0.21964080 1.68370953 5 -0.78260587 -0.84439173 -0.64651014 -0.47142213 0.07488751 -0.51339088 Jul Aug Sep Oct Nov Dec 1 -0.11155892 0.01744955 2.82958576 0.27575522 -0.37330015 -0.29909095 2 0.16539289 1.70670020 1.88783101 0.06139018 -0.64903430 0.57327706 3 0.22800990 0.46385685 3.51250251 0.70208973 -0.22428567 -1.60540473 4 -0.43693661 0.93960182 1.37440659 1.24250556 -1.44086873 -1.43164645 5 0.85719464 0.66689515 -0.26348913 0.66816765 > 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/wessaorg/rcomp/tmp/1z0r11322602668.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/2o1861322602668.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/31l501322602668.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/4afom1322602668.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/5dbcf1322602668.ps",horizontal=F,onefile=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/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/wessaorg/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/wessaorg/rcomp/tmp/60mjl1322602668.tab") > > try(system("convert tmp/1z0r11322602668.ps tmp/1z0r11322602668.png",intern=TRUE)) character(0) > try(system("convert tmp/2o1861322602668.ps tmp/2o1861322602668.png",intern=TRUE)) character(0) > try(system("convert tmp/31l501322602668.ps tmp/31l501322602668.png",intern=TRUE)) character(0) > try(system("convert tmp/4afom1322602668.ps tmp/4afom1322602668.png",intern=TRUE)) character(0) > try(system("convert tmp/5dbcf1322602668.ps tmp/5dbcf1322602668.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.769 0.271 2.040