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(9911,8915,9452,9112,8472,8230,8384,8625,8221,8649,8625,10443,10357,8586,8892,8329,8101,7922,8120,7838,7735,8406,8209,9451,10041,9411,10405,8467,8464,8102,7627,7513,7510,8291,8064,9383,9706,8579,9474,8318,8213,8059,9111,7708,7680,8014,8007,8718,9486,9113,9025,8476,7952,7759,7835,7600,7651,8319,8812,8630) > 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 236704.3 0.0 13247.4 0.0 > m$fitted level slope sea Jan 1 9911.000 0.00000 0.00000 Feb 1 8991.945 -49.50247 -76.94534 Mar 1 9409.599 -42.12086 42.40087 Apr 1 9200.528 -42.89093 -88.52789 May 1 8588.581 -45.41988 -116.58114 Jun 1 8284.746 -46.67757 -54.74597 Jul 1 8395.293 -45.90364 -11.29252 Aug 1 8637.100 -44.49602 -12.10013 Sep 1 8319.090 -45.82648 -98.09030 Oct 1 8629.938 -44.10006 19.06153 Nov 1 8673.910 -43.67581 -48.91014 Dec 1 10256.462 -35.87958 186.53752 Jan 2 10079.458 -30.25394 277.54211 Feb 2 8903.134 -52.47819 -317.13415 Mar 2 8802.857 -53.10046 89.14337 Apr 2 8424.305 -54.52938 -95.30497 May 2 8202.943 -54.94281 -101.94269 Jun 2 8015.452 -55.29641 -93.45171 Jul 2 8132.812 -54.79842 -12.81160 Aug 2 7871.327 -55.40330 -33.32739 Sep 2 7849.909 -55.30339 -114.90925 Oct 2 8274.044 -53.82583 131.95626 Nov 2 8463.964 -53.06805 -254.96374 Dec 2 9124.845 -53.32088 326.15493 Jan 3 9372.529 -57.75852 668.47123 Feb 3 9675.154 -54.29547 -264.15437 Mar 3 10162.195 -48.55093 242.80506 Apr 3 8864.856 -54.82072 -397.85641 May 3 8540.579 -55.47583 -76.57917 Jun 3 8251.041 -55.96678 -149.04094 Jul 3 7693.327 -57.11192 -66.32718 Aug 3 7530.700 -57.36745 -17.70031 Sep 3 7640.228 -56.94184 -130.22806 Oct 3 8076.501 -55.61323 214.49863 Nov 3 8379.390 -54.87561 -315.39033 Dec 3 8980.497 -55.98872 402.50322 Jan 4 9123.659 -57.40993 582.34112 Feb 4 8990.220 -57.84023 -411.21992 Mar 4 8993.407 -57.31956 480.59304 Apr 4 8732.996 -58.38132 -414.99610 May 4 8326.504 -59.31946 -113.50374 Jun 4 8122.875 -59.60179 -63.87489 Jul 4 8919.640 -57.89096 191.35978 Aug 4 7999.334 -59.78069 -291.33415 Sep 4 7874.448 -59.93567 -194.44780 Oct 4 7848.046 -59.85682 165.95362 Nov 4 8317.745 -59.18372 -310.74487 Dec 4 8355.004 -59.35697 362.99593 Jan 5 8773.316 -61.14827 712.68446 Feb 5 9400.512 -58.48582 -287.51230 Mar 5 8698.807 -62.93608 326.19337 Apr 5 8770.837 -62.24664 -294.83726 May 5 8193.923 -63.75665 -241.92276 Jun 5 7999.119 -64.01747 -240.11877 Jul 5 7554.761 -64.73179 280.23934 Aug 5 7775.558 -64.14595 -175.55770 Sep 5 7827.283 -63.88990 -176.28285 Oct 5 8156.414 -63.10598 162.58578 Nov 5 8948.001 -62.44394 -136.00060 Dec 5 8514.622 -61.88606 115.37795 > m$resid Jan Feb Mar Apr May Jun 1 0.00000000 -1.15169175 0.95382194 -0.34403812 -1.17209511 -0.53221549 2 -0.33995865 -2.09169921 -0.09646191 -0.67007941 -0.34337129 -0.27274341 3 0.65564153 0.70485925 1.08957524 -2.56769334 -0.55457870 -0.48157189 4 0.42021552 -0.15232848 0.12305578 -0.41689270 -0.71641104 -0.29691267 5 0.99454211 1.39297540 -1.30075355 0.27667515 -1.05891745 -0.26963335 Jul Aug Sep Oct Nov Dec 1 0.32380665 0.59254518 -0.56330030 0.73456247 0.18137979 3.34911245 2 0.35524993 -0.42526533 0.06992745 0.98664310 0.50171897 1.46783845 3 -1.03216548 -0.21705259 0.34335209 1.01496612 0.73751442 1.35020176 4 1.76161484 -1.77399346 -0.13394391 0.06900268 1.08889585 0.19864846 5 -0.78242019 0.58736386 0.23839249 0.80855785 1.75704981 -0.76405725 > 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/15vjm1324470152.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/24ixg1324470152.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/3ndtz1324470152.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/4vngs1324470152.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/5m88u1324470152.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/61yk21324470152.tab") > > try(system("convert tmp/15vjm1324470152.ps tmp/15vjm1324470152.png",intern=TRUE)) character(0) > try(system("convert tmp/24ixg1324470152.ps tmp/24ixg1324470152.png",intern=TRUE)) character(0) > try(system("convert tmp/3ndtz1324470152.ps tmp/3ndtz1324470152.png",intern=TRUE)) character(0) > try(system("convert tmp/4vngs1324470152.ps tmp/4vngs1324470152.png",intern=TRUE)) character(0) > try(system("convert tmp/5m88u1324470152.ps tmp/5m88u1324470152.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.835 0.381 2.216