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(1856,1834,2095,2164,2368,2072,2521,1823,1947,2226,1754,1786,2072,1846,2137,2466,2154,2289,2628,2074,2798,2194,2442,2565,2063,2069,2539,1898,2139,2408,2725,2201,2311,2548,2276,2351,2280,2057,2479,2379,2295,2456,2546,2844,2260,2981,2678,3440,2842,2450,2669,2570,2540,2318,2930,2947,2799,2695,2498,2260,2160,2058,2533,2150,2172,2155,3016,2333,2355,2825,2214,2360,2299,1746,2069,2267,1878,2266,2282,2085,2277,2251,1828,1954,1851,1570,1852,2187,1855,2218,2253,2028,2169,1997,2034,1791,1627,1631,2319,1707,1747,2397,2059,2251,2558,2406,2049,2074,1734) > par20 = '' > par19 = '' > par18 = '' > par17 = '' > par16 = '' > par15 = '' > par14 = '' > par13 = '' > par12 = '' > par11 = '' > par10 = '' > par9 = '' > par8 = '' > par7 = '' > par6 = '' > par5 = '' > par4 = '' > par3 = '' > par2 = '' > par1 = '12' > ylab = '' > xlab = '' > main = '' > #'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 5409.079306 5.794034 2659.549357 38348.286900 > m$fitted level slope sea Jan 1 1856.000 0.00000000 0.00000000 Feb 1 1849.004 -0.86646274 -2.24138791 Mar 1 1933.000 7.91207400 30.27390940 Apr 1 2016.713 14.20111470 25.08213069 May 1 2140.532 21.79487575 43.11668689 Jun 1 2130.166 19.86171217 -2.23569239 Jul 1 2261.363 25.85619908 61.13871537 Aug 1 2136.297 18.39152131 -39.35652725 Sep 1 2077.485 14.81501615 11.43904882 Oct 1 2126.379 16.31536349 36.41009956 Nov 1 2017.471 11.01947917 -29.72470985 Dec 1 1944.126 7.56517138 0.05912588 Jan 2 1990.963 4.20203925 -16.16050831 Feb 2 1954.141 2.44566443 -44.05402592 Mar 2 2009.049 4.91468791 46.45907588 Apr 2 2159.950 11.14008324 64.46401373 May 2 2163.917 10.86308406 2.46440826 Jun 2 2218.104 12.41315558 -5.74891867 Jul 2 2330.634 15.80434796 117.69773111 Aug 2 2281.129 13.67474611 -88.93649673 Sep 2 2439.382 18.26858016 95.66441099 Oct 2 2371.677 15.58458039 -20.85026035 Nov 2 2402.098 16.04038720 12.78513237 Dec 2 2464.696 17.35574928 14.70355539 Jan 3 2402.019 18.22221238 -177.68772626 Feb 3 2326.582 15.28444759 -99.08954465 Mar 3 2389.411 17.05125869 71.94975405 Apr 3 2234.432 10.88304727 -47.90823781 May 3 2203.844 9.48014051 6.41385313 Jun 3 2275.623 11.48910128 23.71259711 Jul 3 2381.138 14.41994718 178.42696975 Aug 3 2382.627 14.02588733 -158.76163542 Sep 3 2336.754 12.22715201 80.45177700 Oct 3 2409.993 14.04021372 29.65183494 Nov 3 2384.496 12.88543153 -38.17949471 Dec 3 2368.582 12.11790819 33.88085094 Jan 4 2385.416 12.17255337 -114.17013006 Feb 4 2327.887 10.15927740 -150.95140132 Mar 4 2336.656 10.11283925 144.65873315 Apr 4 2366.850 10.78184023 -21.62738645 May 4 2360.049 10.21380291 -35.02794089 Jun 4 2395.724 11.01244374 16.35827901 Jul 4 2395.639 10.67195500 169.61604301 Aug 4 2573.445 15.72379659 -20.42226365 Sep 4 2488.946 12.72494352 -54.13879759 Oct 4 2620.807 16.25777839 152.18091452 Nov 4 2665.762 17.09335518 -37.91269949 Dec 4 2893.899 22.83609530 176.39335806 Jan 5 2938.739 23.29999498 -135.97232840 Feb 5 2862.075 20.43122350 -239.74928526 Mar 5 2771.643 16.92082910 83.70709813 Apr 5 2720.310 14.73781558 -35.22731392 May 5 2684.969 13.15921773 -59.74127057 Jun 5 2581.023 9.53179945 -62.29186625 Jul 5 2645.206 11.20068429 190.70948754 Aug 5 2742.346 13.79799188 56.35648503 Sep 5 2804.963 15.26206343 -90.30887302 Oct 5 2753.507 13.27732462 56.83397472 Nov 5 2717.675 11.83930427 -134.75846247 Dec 5 2538.552 6.48122319 51.90769429 Jan 6 2444.510 3.91682344 -108.90727951 Feb 6 2381.636 1.97912774 -208.70407755 Mar 6 2387.001 2.08351293 140.27458878 Apr 6 2321.435 -0.02676525 -57.11368809 May 6 2280.266 -1.30257983 -38.33329874 Jun 6 2265.185 -1.72562061 -86.64335977 Jul 6 2432.614 3.42098344 293.44933413 Aug 6 2405.674 2.50387042 -20.54692141 Sep 6 2409.247 2.53595761 -56.08297835 Oct 6 2504.146 5.29069179 162.11883089 Nov 6 2448.368 3.49086567 -129.44950642 Dec 6 2395.477 1.87037825 61.38766792 Jan 7 2388.726 1.63180812 -74.82786832 Feb 7 2262.541 -2.11810716 -297.12361755 Mar 7 2146.889 -5.57044025 114.63578877 Apr 7 2180.767 -4.35887187 19.44864966 May 7 2105.326 -6.53802464 -106.54754573 Jun 7 2182.619 -3.98197202 -59.60092940 Jul 7 2127.312 -5.53807095 242.44302455 Aug 7 2116.240 -5.70502810 -21.76614792 Sep 7 2181.126 -3.58487898 -25.02286254 Oct 7 2149.513 -4.42227991 149.48072278 Nov 7 2082.953 -6.26343536 -148.62538351 Dec 7 2014.266 -8.08688069 46.52992020 Jan 8 1962.565 -9.34124191 -36.64678672 Feb 8 1913.916 -10.50393187 -276.58164633 Mar 8 1854.662 -11.97612740 80.14822062 Apr 8 1926.652 -9.42183872 118.00472858 May 8 1942.172 -8.66317904 -129.54994733 Jun 8 2029.585 -5.74918531 24.70850474 Jul 8 2028.042 -5.62206582 217.77803337 Aug 8 2036.977 -5.18352445 -33.85285863 Sep 8 2074.261 -3.90838651 22.16263343 Oct 8 2001.176 -5.97758201 113.99585145 Nov 8 2036.486 -4.74936232 -72.95932436 Dec 8 1946.626 -7.26110379 -10.37637856 Jan 9 1851.531 -9.83665587 -74.17995321 Feb 9 1852.128 -9.52637354 -238.97109563 Mar 9 1966.084 -5.81027695 142.96694232 Apr 9 1867.117 -8.62772818 -2.04662736 May 9 1867.914 -8.34255613 -136.92749568 Jun 9 2007.447 -3.87464699 137.74209305 Jul 9 1969.183 -4.91149102 148.46654009 Aug 9 2056.996 -2.12194795 35.75780737 Sep 9 2192.071 1.99615023 131.79075640 Oct 9 2233.565 3.17856041 105.06689904 Nov 9 2197.841 2.01809952 -82.54435214 Dec 9 2157.893 0.77181232 -12.38069930 Jan 10 2060.014 -2.15025908 -157.50789965 > m$resid Jan Feb Mar Apr May Jun 1 0.00000000 -0.08556741 0.92081463 0.84556369 1.26237593 -0.38001603 2 0.71019472 -0.45302505 0.58265211 1.70827586 -0.08684007 0.53495066 3 -1.16201889 -1.12782875 0.55946397 -2.07243241 -0.50960457 0.77483875 4 0.06339944 -0.86168201 -0.01677908 0.24482354 -0.21706787 0.31692759 5 0.28548891 -1.24645125 -1.35544153 -0.83789219 -0.61974675 -1.45770808 6 -1.28132609 -0.83491416 0.04171883 -0.83422319 -0.51002174 -0.17153368 7 -0.10887262 -1.59832442 -1.40492822 0.48792981 -0.88226002 1.04382230 8 -0.54793770 -0.49135668 -0.60485262 1.04071033 0.30985179 1.19648835 9 -1.10020246 0.13035624 1.53452833 -1.15625865 0.11715709 1.84177778 10 -1.23347114 Jul Aug Sep Oct Nov Dec 1 1.34112306 -1.84344777 -0.95234672 0.42330039 -1.56298140 -1.05657203 2 1.25039985 -0.82112037 1.82484521 -1.08759196 0.18794606 0.59175701 3 1.17753881 -0.16257600 -0.75466319 0.76959163 -0.49910628 -0.36455705 4 -0.13878029 2.09555971 -1.25832639 1.49678020 0.36064636 2.65685017 5 0.68259940 1.07529535 0.61135164 -0.83572300 -0.61501971 -2.39408691 6 2.11114339 -0.37938122 0.01335905 1.15457647 -0.76297796 -0.70495647 7 -0.64029917 -0.06909765 0.88153398 -0.34987995 -0.77513685 -0.77924944 8 0.05245563 0.18167271 0.52992776 -0.86273771 0.51456075 -1.06144688 9 -0.42882798 1.15673309 1.71115494 0.49230984 -0.48457407 -0.52308033 10 > 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/1av511293633729.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/www/html/rcomp/tmp/22m4m1293633729.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/www/html/rcomp/tmp/3dvlp1293633729.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/www/html/rcomp/tmp/4dvlp1293633729.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/www/html/rcomp/tmp/5642a1293633729.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/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/6kwij1293633729.tab") > > try(system("convert tmp/1av511293633729.ps tmp/1av511293633729.png",intern=TRUE)) character(0) > try(system("convert tmp/22m4m1293633729.ps tmp/22m4m1293633729.png",intern=TRUE)) character(0) > try(system("convert tmp/3dvlp1293633729.ps tmp/3dvlp1293633729.png",intern=TRUE)) character(0) > try(system("convert tmp/4dvlp1293633729.ps tmp/4dvlp1293633729.png",intern=TRUE)) character(0) > try(system("convert tmp/5642a1293633729.ps tmp/5642a1293633729.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.424 0.889 7.885