R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 The R Foundation for Statistical Computing Platform: i686-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(19008,19869,19868,19960,20307,22074,20682,20858,21421,21374,21380,21331,21850,22641,24483,22146,23840,23879,24078,24652,25048,25627,26496,26291,24730,25569,25582,26157,26258,26625,27189,27079,26075,25992,25656,28739,27501,26833,27275,27673,27562,27350,27333,27339,28820,26405,27783,27952,27966,26689,28880,27305,26687,26864,27140,26915,27021,27967,28198,28616,27703,29599,29404,29883,30736,30730,30440,31010,32028,31234,29905,30825,32396,31714,32811,32348,32355,33217,34555,34685,34923,35184,35801,35123,36142,36028,35507,35897,37439,37072,36679,36643,37242,37189,37494,38699,38643,39670,40384,40310,39839,41181,41711,42588,42258,42489,42643,42863,41876,43383,42595,42904,42343,42765,41364,43794,43482,43445,43540,42620,43138,42255,41169,41772,41309,39223,40617,40616,40692,41700,41952,45308,43474,43189,44347,44483,45297,45832,45593,45544,45764,45205,48060,46181,48641,47022,47295,46719,47787,47313,48716,48417,49966,50635,50165,50896,50546,51147,51121,51711,51716,52887) > par1 = '12' > 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') Warning message: In StructTS(x, type = "BSM") : possible convergence problem: 'optim' gave code = 52 and message 'ERROR: ABNORMAL_TERMINATION_IN_LNSRCH' > m$coef level slope seas epsilon 362256.4013 389.7007 0.0000 238354.3353 > m$fitted level slope sea Jan 1 19008.00 0.00000 0.000000 Feb 1 19679.94 43.11447 42.875466 Mar 1 19793.76 45.16428 44.823334 Apr 1 19891.22 46.08923 45.615031 May 1 20159.52 49.38100 48.105265 Jun 1 21455.48 67.49159 60.442579 Jul 1 20904.20 58.19756 54.631299 Aug 1 20853.17 56.47929 53.634028 Sep 1 21224.18 61.66671 56.446602 Oct 1 21307.65 62.04273 56.637856 Nov 1 21337.82 61.46961 56.363550 Dec 1 21313.50 59.86573 55.639323 Jan 2 21869.70 34.93084 -245.936203 Feb 2 22430.11 55.74307 38.028564 Mar 2 23845.85 89.02863 54.775749 Apr 2 22660.77 63.40398 46.431274 May 2 23463.35 77.64009 49.907856 Jun 2 23740.22 81.51813 50.720075 Jul 2 23963.93 84.35859 51.264411 Aug 2 24430.62 92.21959 52.677576 Sep 2 24849.95 99.13802 53.855268 Oct 2 25381.28 108.52667 55.374631 Nov 2 26148.52 123.19831 57.636619 Dec 2 26245.14 122.59227 57.547473 Jan 3 25810.16 124.68075 -834.434643 Feb 3 25616.12 113.40830 69.732212 Mar 3 25578.37 109.27952 68.595095 Apr 3 25965.83 116.26403 69.632718 May 3 26155.88 118.08966 69.818229 Jun 3 26469.30 122.95627 70.228615 Jul 3 26958.07 132.19023 70.937716 Aug 3 27033.14 130.72783 70.831804 Sep 3 26357.76 109.80498 69.385196 Oct 3 26088.69 99.84219 68.724727 Nov 3 25770.43 88.71242 68.016038 Dec 3 27814.82 141.37170 71.239489 Jan 4 28151.82 144.09433 -735.700832 Feb 4 27202.02 106.73802 51.519527 Mar 4 27249.34 104.97633 51.210270 Apr 4 27540.45 110.26779 51.650313 May 4 27553.00 107.50994 51.507871 Jun 4 27408.43 100.37201 51.216810 Jul 4 27350.70 95.86759 51.052404 Aug 4 27336.08 92.69890 50.943667 Sep 4 28362.45 119.65210 51.828260 Oct 4 26998.87 76.56864 50.468115 Nov 4 27533.29 89.94529 50.875156 Dec 4 27816.88 95.63387 51.042131 Jan 5 28292.42 104.15868 -490.007209 Feb 5 27150.26 62.40980 30.809617 Mar 5 28354.00 97.69773 35.251466 Apr 5 27628.03 72.80930 33.919959 May 5 26970.44 50.83392 33.266264 Jun 5 26888.42 46.83167 33.178820 Jul 5 27054.89 50.44581 33.247340 Aug 5 26949.41 45.72095 33.163959 Sep 5 26990.04 45.56622 33.161353 Oct 5 27662.09 64.66320 33.470894 Nov 5 28032.10 73.99647 33.616895 Dec 5 28438.32 84.17723 33.770742 Jan 6 28239.44 76.60026 -414.962989 Feb 6 29198.79 105.73870 45.725221 Mar 6 29342.03 106.92025 45.840726 Apr 6 29719.68 115.33807 46.160179 May 6 30431.34 133.82851 46.506425 Jun 6 30647.73 136.38923 46.538386 Jul 6 30511.53 127.92361 46.451066 Aug 6 30865.61 134.95719 46.517375 Sep 6 31685.08 156.27591 46.708096 Oct 6 31384.92 142.04137 46.585703 Nov 6 30362.54 105.68130 46.283959 Dec 6 30684.91 112.45575 46.338296 Jan 7 32149.93 151.71287 -333.699844 Feb 7 31864.60 137.45046 26.970017 Mar 7 32547.77 154.77518 28.358089 Apr 7 32435.41 146.36072 28.114724 May 7 32403.90 140.76778 28.043876 Jun 7 32994.35 154.90767 28.149487 Jul 7 34110.82 185.15831 28.322915 Aug 7 34547.75 193.08430 28.363186 Sep 7 34848.19 196.46614 28.379319 Oct 7 35122.12 198.90755 28.390475 Nov 7 35636.25 208.84956 28.434286 Dec 7 35321.18 192.31659 28.363875 Jan 8 36123.62 210.75972 -243.091582 Feb 8 36102.48 203.25542 20.544622 Mar 8 35733.92 185.05451 19.304638 Apr 8 35890.17 184.14183 19.283408 May 8 37013.40 213.85938 19.554521 Jun 8 37105.23 209.99792 19.536571 Jul 8 36857.43 195.50919 19.490286 Aug 8 36753.14 186.01828 19.464806 Sep 8 37136.99 192.28321 19.480287 Oct 8 37217.74 188.75021 19.471979 Nov 8 37453.99 190.25518 19.475385 Dec 8 38367.03 213.16237 19.525453 Jan 9 38761.81 218.77213 -196.662331 Feb 9 39454.05 234.00337 20.691122 Mar 9 40159.37 249.01498 21.583673 Apr 9 40324.66 246.35577 21.531862 May 9 40044.99 229.66105 21.415921 Jun 9 40892.46 249.26680 21.474824 Jul 9 41524.19 261.40460 21.496046 Aug 9 42330.81 278.71018 21.519074 Sep 9 42349.07 270.44208 21.509359 Oct 9 42513.37 267.07226 21.505646 Nov 9 42669.47 263.54840 21.501928 Dec 9 42869.12 261.51926 21.499863 Jan 10 42460.00 240.55691 -296.386361 Feb 10 43162.24 255.34953 29.408712 Mar 10 42822.88 236.40978 28.406998 Apr 10 42931.08 232.33353 28.338411 May 10 42570.89 213.50387 28.233955 Jun 10 42751.14 212.44727 28.231821 Jul 10 41827.03 176.33116 28.198942 Aug 10 43233.93 215.43665 28.220661 Sep 10 43452.45 215.53467 28.220704 Oct 10 43492.59 209.96021 28.218528 Nov 10 43569.35 205.72666 28.216972 Dec 10 42948.87 179.46499 28.207707 Jan 11 43340.24 186.13340 -293.162822 Feb 11 42612.90 156.94281 22.221121 Mar 11 41636.89 120.87140 20.499622 Apr 11 41753.39 120.73247 20.497556 May 11 41465.28 107.73237 20.437575 Jun 11 39917.96 55.10949 20.363042 Jul 11 40408.46 68.95296 20.368857 Aug 11 40559.96 71.57756 20.369146 Sep 11 40659.53 72.46778 20.369158 Oct 11 41393.67 93.50749 20.368839 Nov 11 41797.51 103.37573 20.368605 Dec 11 44265.63 178.57356 20.366671 Jan 12 43947.76 162.88915 -260.650867 Feb 12 43445.82 141.68076 20.740093 Mar 12 44103.19 158.09487 21.454819 Apr 12 44401.07 162.54141 21.514280 May 12 45060.61 178.34860 21.576957 Jun 12 45637.96 191.03855 21.590137 Jul 12 45649.14 185.31832 21.589379 Aug 12 45616.57 178.38862 21.590377 Sep 12 45758.27 177.22154 21.590639 Oct 12 45410.36 160.51962 21.594704 Nov 12 47293.81 215.31830 21.581344 Dec 12 46566.70 185.34374 21.588493 Jan 13 48172.21 230.31755 -141.139712 Feb 13 47423.18 199.11048 8.810785 Mar 13 47387.67 191.64422 8.511526 Apr 13 46972.85 172.35130 8.276411 May 13 47587.50 186.42056 8.325603 Jun 13 47446.28 175.99900 8.317299 Jul 13 48380.15 200.10519 8.316444 Aug 13 48460.46 196.29460 8.317533 Sep 13 49565.12 225.18819 8.307274 Oct 13 50374.31 243.76432 8.300437 Nov 13 50295.92 233.51707 8.304165 Dec 13 50779.59 241.47407 8.301345 Jan 14 50763.93 233.31960 -107.456766 Feb 14 51095.59 236.45096 10.143851 Mar 14 51177.64 231.53818 9.961305 Apr 14 51612.91 238.01937 10.034028 May 14 51749.72 234.79985 10.023903 Jun 14 52607.65 254.62166 10.036559 > m$resid Jan Feb Mar Apr May 1 0.000000000 0.726665940 0.112232186 0.086085431 0.367571043 2 1.016518132 0.719600498 2.187861515 -2.083466396 1.210769631 3 -1.017732149 -0.465337819 -0.243339085 0.452055629 0.120005182 4 0.341994610 -1.642900733 -0.095605583 0.301301764 -0.158223282 5 0.649652934 -1.901881706 1.835612694 -1.330425392 -1.179912357 6 -0.477849394 1.360864057 0.060314953 0.436830612 0.962193484 7 2.264589959 -0.678513097 0.877821570 -0.430790563 -0.286837275 8 1.015742671 -0.361872679 -0.919971165 -0.046445211 1.513915398 9 0.301114505 0.741704254 0.758432636 -0.134969629 -0.847892749 10 -1.108395167 0.725425845 -0.957131232 -0.206663465 -0.954997169 11 0.349349025 -1.438773205 -1.823636936 -0.007040323 -0.658922981 12 -0.816794958 -1.049217265 0.830154687 0.225297282 0.800977697 13 2.332663166 -1.548135683 -0.377726770 -0.977476565 0.712823835 14 -0.421743339 0.155669687 -0.248600697 0.328364008 -0.163108774 Jun Jul Aug Sep Oct 1 2.062584923 -1.023189624 -0.180453637 0.519192870 0.035952512 2 0.326252942 0.232716695 0.625303752 0.534634900 0.705942053 3 0.317553689 0.594488578 -0.092793495 -1.308938346 -0.614966068 4 -0.408084839 -0.255886377 -0.178768546 1.510422248 -2.398970222 5 -0.214585019 0.193208691 -0.251775427 -0.008219213 1.011384590 6 0.133187838 -0.439732212 0.364804879 1.104099507 -0.736180545 7 0.725081356 1.550320725 0.405923883 0.173080811 0.124869268 8 -0.196714620 -0.737908394 -0.483219618 0.318872546 -0.179768828 9 0.995748817 0.616388868 0.878695627 -0.419754273 -0.171055009 10 -0.053588422 -1.831615366 1.983086104 0.004970168 -0.282650209 11 -2.667190167 0.701631571 0.133018590 0.045116506 1.066259342 12 0.642999659 -0.289836815 -0.351112125 -0.059132445 -0.846224531 13 -0.527988431 1.221266242 -0.193049769 1.463777177 0.941078570 14 1.004169822 Nov Dec 1 -0.052508483 -0.141239916 2 1.075267019 -0.043366410 3 -0.678395147 3.172081028 4 0.740378661 0.313087166 5 0.492901927 0.536238662 6 -1.877996379 0.349469391 7 0.508188477 -0.844603224 8 0.076555396 1.164942845 9 -0.178851173 -0.102974612 10 -0.214647581 -1.331430608 11 0.500092818 3.810704037 12 2.776411315 -1.518663360 13 -0.519129119 0.403102627 14 > 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/104ea1385743590.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/2851v1385743590.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/3hxf31385743590.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/44ady1385743590.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/57ikb1385743590.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/66kkv1385743590.tab") > > try(system("convert tmp/104ea1385743590.ps tmp/104ea1385743590.png",intern=TRUE)) character(0) > try(system("convert tmp/2851v1385743590.ps tmp/2851v1385743590.png",intern=TRUE)) character(0) > try(system("convert tmp/3hxf31385743590.ps tmp/3hxf31385743590.png",intern=TRUE)) character(0) > try(system("convert tmp/44ady1385743590.ps tmp/44ady1385743590.png",intern=TRUE)) character(0) > try(system("convert tmp/57ikb1385743590.ps tmp/57ikb1385743590.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 6.306 0.803 7.085