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(20366,22782,19169,13807,29743,25591,29096,26482,22405,27044,17970,18730,19684,19785,18479,10698,31956,29506,34506,27165,26736,23691,18157,17328,18205,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) > 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 2488893 2582893 0 > m$fitted level slope sea Jan 1 20366.00 0.00000 0.00000 Feb 1 21193.67 958.93472 1588.33241 Mar 1 20924.48 237.38539 -1755.48433 Apr 1 16727.05 -2218.62355 -2920.05175 May 1 23291.23 2908.04817 6451.77101 Jun 1 27164.68 3456.87450 -1573.67867 Jul 1 29875.39 3038.29427 -779.38735 Aug 1 28863.12 756.64060 -2381.11832 Sep 1 24643.73 -2055.24970 -2238.73484 Oct 1 24815.34 -796.28708 2228.65871 Nov 1 20594.93 -2731.72090 -2624.93336 Dec 1 18041.78 -2630.82113 688.22140 Jan 2 17941.32 -1209.02972 1742.67734 Feb 2 16976.29 -1071.19204 2808.71036 Mar 2 17684.27 -79.07371 794.72780 Apr 2 17853.99 56.02499 -7155.98576 May 2 23170.37 2935.28302 8785.62652 Jun 2 29557.84 4837.45981 -51.83913 Jul 2 34023.32 4634.14817 482.67853 Aug 2 31726.03 861.48980 -4561.03474 Sep 2 29994.30 -552.50351 -3258.29676 Oct 2 23175.84 -3974.65823 515.16153 Nov 2 19624.50 -3743.49813 -1467.50081 Dec 2 16921.96 -3175.53144 406.03717 Jan 3 15390.12 -2278.08333 2814.87891 Feb 3 16664.03 -335.95237 4330.97245 Mar 3 17277.07 180.33466 104.92766 Apr 3 19047.41 1038.85127 -9680.40812 May 3 23112.60 2674.76342 8011.39983 Jun 3 26437.70 3027.88550 113.30184 Jul 3 27996.17 2230.95820 2654.83132 Aug 3 29000.19 1567.90793 -3141.19205 Sep 3 27138.43 -283.37274 -2038.42994 Oct 3 25487.93 -1021.70397 290.07186 Nov 3 22909.05 -1863.04917 -2491.05471 Dec 3 19652.42 -2616.40031 -964.41713 Jan 4 18146.00 -2015.79184 2278.00272 Feb 4 19263.66 -320.68012 5512.33892 Mar 4 20470.22 502.92846 -656.22329 Apr 4 23113.38 1653.24788 -10375.37567 May 4 24521.76 1521.58062 7044.24340 Jun 4 28220.23 2695.13436 1890.76737 Jul 4 28458.00 1369.96959 1561.00151 Aug 4 31875.25 2471.55407 58.74751 Sep 4 29872.17 68.74044 -4046.17483 Oct 4 26574.13 -1738.24411 260.86989 Nov 4 22653.10 -2910.44968 -2448.09602 Dec 4 19330.22 -3132.16343 -1541.21739 Jan 5 18392.08 -1951.85279 2127.91873 Feb 5 17551.11 -1354.67934 4966.89408 Mar 5 16924.25 -964.33248 -1352.24735 Apr 5 19977.68 1186.26400 -8468.68136 May 5 20501.47 831.54447 4945.52899 Jun 5 21504.45 923.49413 2585.55432 Jul 5 25317.59 2474.25325 2468.41365 Aug 5 25493.74 1242.73860 701.25705 Sep 5 23839.92 -306.43166 -3323.92174 Oct 5 21787.77 -1239.25411 971.22602 Nov 5 20893.52 -1054.81739 -1865.51513 Dec 5 19615.37 -1174.34134 -2644.37226 Jan 6 18351.98 -1222.03046 1684.02366 > m$resid Jan Feb Mar Apr May Jun 1 0.00000000 0.99727698 -0.43749246 -1.73937111 3.32856330 0.34289543 2 0.90567168 0.08886839 0.62377747 0.08586502 1.85693006 1.20767470 3 0.57058954 1.23324770 0.32623638 0.54411825 1.04324385 0.22460505 4 0.38123988 1.07411934 0.52108691 0.72916230 -0.08371751 0.74587922 5 0.74870643 0.37824148 0.24709737 1.36333039 -0.22530481 0.05840384 6 -0.03024288 Jul Aug Sep Oct Nov Dec 1 -0.26521820 -1.45026659 -1.78290176 0.79788886 -1.22685550 0.06395897 2 -0.12823340 -2.38993447 -0.89706647 -2.16959438 0.14654542 0.36036861 3 -0.50430381 -0.41944932 -1.17310080 -0.46824196 -0.53378553 -0.47821908 4 -0.83981457 0.69711850 -1.52170871 -1.14590189 -0.74404159 -0.14075587 5 0.98320747 -0.77967694 -0.98100859 -0.59146769 0.11707214 -0.07587409 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/1ghsj1259929518.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/2wss31259929518.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/3pu5t1259929518.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/42mpr1259929518.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/55wlw1259929518.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/60w8u1259929518.tab") > system("convert tmp/1ghsj1259929518.ps tmp/1ghsj1259929518.png") > system("convert tmp/2wss31259929518.ps tmp/2wss31259929518.png") > system("convert tmp/3pu5t1259929518.ps tmp/3pu5t1259929518.png") > system("convert tmp/42mpr1259929518.ps tmp/42mpr1259929518.png") > system("convert tmp/55wlw1259929518.ps tmp/55wlw1259929518.png") > > > proc.time() user system elapsed 1.541 0.826 2.148