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(20995,17382,9367,31124,26551,30651,25859,25100,25778,20418,18688,20424,24776,19814,12738,31566,30111,30019,31934,25826,26835,20205,17789,20520,22518,15572,11509,25447,24090,27786,26195,20516,22759,19028,16971,20036,22485,18730,14538,27561,25985,34670,32066,27186,29586,21359,21553,19573,24256,22380,16167,27297,28287,33474,28229,28785,25597,18130,20198,22849,23118) > 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 3574339 0 5047913 0 > m$fitted level slope sea Jan 1 20995.00 0.00000 0.000000 Feb 1 19044.18 -53.68132 -1662.179055 Mar 1 13429.80 -401.96705 -4062.800804 Apr 1 20386.06 -11.10282 10737.939532 May 1 24570.15 133.52772 1980.846659 Jun 1 28209.04 208.61330 2441.962547 Jul 1 28131.52 204.19253 -2272.520955 Aug 1 26787.39 182.89324 -1687.392710 Sep 1 25978.68 169.22346 -200.676242 Oct 1 23358.84 129.76844 -2940.836528 Nov 1 20650.09 89.05541 -1962.092936 Dec 1 19831.38 76.05307 592.615255 Jan 2 20916.88 54.81257 3859.124945 Feb 2 20946.55 54.96004 -1132.553262 Mar 2 21562.61 64.44814 -8824.608353 Apr 2 22838.01 96.50857 8727.991859 May 2 26279.51 182.50482 3831.487644 Jun 2 27531.39 204.59928 2487.608733 Jul 2 30220.93 243.80296 1713.065909 Aug 2 29314.76 229.24442 -3488.757936 Sep 2 27340.04 205.04053 -505.039401 Oct 2 24476.93 175.61123 -4271.931383 Nov 2 21742.41 154.59060 -3953.412855 Dec 2 20594.45 150.32869 -74.452906 Jan 3 19645.47 151.00547 2872.528007 Feb 3 18625.92 148.13518 -3053.918089 Mar 3 19878.08 159.01290 -8369.080382 Apr 3 19942.96 157.52291 5504.035379 May 3 20712.82 168.55933 3377.182877 Jun 3 23329.81 210.38228 4456.187775 Jul 3 23899.38 215.64826 2295.619801 Aug 3 23255.08 205.28922 -2739.082819 Sep 3 22151.11 192.60058 607.891793 Oct 3 21591.03 186.96761 -2563.032713 Nov 3 20796.09 181.78056 -3825.086311 Dec 3 20039.32 178.56233 -3.322189 Jan 4 19589.58 176.72636 2895.422805 Feb 4 20757.16 181.41172 -2027.161585 Mar 4 22111.31 191.01419 -7573.308443 Apr 4 22885.22 197.74795 4675.777615 May 4 23623.14 205.03556 2361.863499 Jun 4 26529.16 242.01262 8140.835997 Jul 4 28163.11 259.49980 3902.889786 Aug 4 28849.14 264.07950 -1663.135024 Sep 4 28789.60 261.26492 796.400241 Oct 4 26521.50 244.23283 -5162.498793 Nov 4 25418.66 237.37903 -3865.664744 Dec 4 22901.68 226.10333 -3328.675298 Jan 5 22225.35 222.37625 2030.645746 Feb 5 23465.26 227.80633 -1085.260637 Mar 5 24242.95 231.83985 -8075.945366 Apr 5 24306.38 230.26121 2990.619428 May 5 25908.64 245.02114 2378.357443 Jun 5 26463.22 248.47319 7010.778983 Jul 5 25766.80 238.45451 2462.204050 Aug 5 27207.78 249.75311 1577.219112 Sep 5 25762.05 236.39132 -165.053052 Oct 5 23895.74 222.96643 -5765.736130 Nov 5 22958.43 216.93831 -2760.430205 Dec 5 24090.35 221.11523 -1241.346688 Jan 6 23499.05 217.33047 -381.049930 > m$resid Jan Feb Mar Apr May Jun 1 0.00000000 -0.86029126 -2.07821580 3.43752947 2.16347095 1.84858421 2 0.56293662 -0.01369856 0.27747964 0.59120559 1.69245117 0.55624826 3 -0.58505745 -0.61703060 0.56637238 -0.04762747 0.31239684 1.26872837 4 -0.33138331 0.51897257 0.60708817 0.29951533 0.27811505 1.40184446 5 -0.47458330 0.53252943 0.28596283 -0.08721513 0.71091813 0.16109072 6 -0.42678430 Jul Aug Sep Oct Nov Dec 1 -0.15135128 -0.81852093 -0.52359507 -1.47135346 -1.49678835 -0.47863087 2 1.30784990 -0.60749767 -1.16516976 -1.62124137 -1.53625382 -0.68851994 3 0.18827347 -0.45332193 -0.69143788 -0.39745295 -0.51826633 -0.49548169 4 0.72831773 0.22433542 -0.17058515 -1.33388318 -0.71027556 -1.45152782 5 -0.49429588 0.63156899 -0.89234338 -1.10748415 -0.61110043 0.48157047 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/wessaorg/rcomp/tmp/1dxaw1322499759.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/2jhzw1322499759.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/3btug1322499759.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/4rnkn1322499759.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/5mqld1322499759.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/60k4d1322499759.tab") > > try(system("convert tmp/1dxaw1322499759.ps tmp/1dxaw1322499759.png",intern=TRUE)) character(0) > try(system("convert tmp/2jhzw1322499759.ps tmp/2jhzw1322499759.png",intern=TRUE)) character(0) > try(system("convert tmp/3btug1322499759.ps tmp/3btug1322499759.png",intern=TRUE)) character(0) > try(system("convert tmp/4rnkn1322499759.ps tmp/4rnkn1322499759.png",intern=TRUE)) character(0) > try(system("convert tmp/5mqld1322499759.ps tmp/5mqld1322499759.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.777 0.274 2.062