R version 2.8.0 (2008-10-20) Copyright (C) 2008 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. Natural language support but running in an English locale 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(5745,4549,5074,3602,2732,2589,2148,2330,2752,3241,4517,6550,6778,6240,5570,3558,3299,2447,2380,2378,2947,3651,4816,6436,7090,4682,4198,3860,3056,2563,2568,2472,2821,4015,4686,5418,5649,4572,4695,3766,2900,2528,2549,2478,2828,4139,5390,5621,5291,5272,4677,3520,2842,2723,2581,2429,2606,3787,4630,5505,5577,4911,4701,3557,2921,2734,2636,2433,2640,3794,4745,5698,5909,5119,5200,3876,3104,2251,2386,2794,2967,3392,4741,5909,5901,4962,4751,3909,3130,2860,2568,2540,2894,4216,4530,5144,6206,5645,4601,3645,3140,2264,2557,2431,2747,4587,4512,5313,6011,5328,5014,3630,3102,2739,2877,2659,2957,3785,4785,5757,5458,5427,5018,3498,3204,2763,2589,2591,2805,3278,4615,5524,6167,5380,5377,3603,2774,2470,2407,2512,2451,3134,4210,4859,5022,4584,4267,3022,2777,2428,2389,2496,2820,3854,4748,5666,5293,4905,4920,3854,2659,2491,2455,2472,3030,3987,4453,5417) > 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 88085.117 279087.538 1086.898 0.000 > m$fitted level slope sea Jan 1 5745.000 0.000000 0.000000 Feb 1 4583.125 -634.740600 -34.124961 Mar 1 5107.501 297.690233 -33.500815 Apr 1 3659.418 -1081.596092 -57.417915 May 1 2765.245 -933.300439 -33.245154 Jun 1 2621.464 -308.375151 -32.463927 Jul 1 2190.241 -405.619454 -42.241345 Aug 1 2363.634 52.726844 -33.634079 Sep 1 2789.213 347.877830 -37.212896 Oct 1 3279.814 460.858323 -38.814165 Nov 1 4549.183 1100.878648 -32.182721 Dec 1 6582.661 1839.128403 -32.660592 Jan 2 6680.278 484.020720 97.721912 Feb 2 6297.190 -106.402029 -57.190220 Mar 2 5563.043 -602.798094 6.956535 Apr 2 3612.302 -1660.223536 -54.302380 May 2 3294.482 -605.999398 4.517874 Jun 2 2463.534 -782.692012 -16.534465 Jul 2 2394.024 -222.494341 -14.023849 Aug 2 2394.959 -46.990943 -16.959429 Sep 2 2951.121 426.784166 -4.121431 Oct 2 3669.420 655.768518 -18.419710 Nov 2 4843.463 1062.902075 -27.463006 Dec 2 6423.134 1468.676482 12.865544 Jan 3 6981.025 757.934137 108.975164 Feb 3 4793.816 -1359.921749 -111.816170 Mar 3 4143.293 -803.660917 54.706977 Apr 3 3963.971 -316.778149 -103.971372 May 3 3081.245 -758.534612 -25.244722 Jun 3 2610.926 -533.514363 -47.925930 Jul 3 2596.202 -128.480755 -28.201977 Aug 3 2527.813 -81.565497 -55.813098 Sep 3 2842.613 227.887425 -21.613458 Oct 3 4043.014 987.166853 -28.013720 Nov 3 4779.166 791.171736 -93.165987 Dec 3 5425.047 677.818852 -7.046658 Jan 4 5192.635 -31.127555 456.365440 Feb 4 4701.315 -370.179295 -129.315180 Mar 4 4657.300 -116.006130 37.700420 Apr 4 3865.547 -640.695837 -99.546508 May 4 2929.747 -869.993505 -29.747008 Jun 4 2574.145 -470.188140 -46.145448 Jul 4 2560.918 -115.026486 -11.918451 Aug 4 2529.731 -49.865447 -51.731145 Sep 4 2871.092 254.201362 -43.091775 Oct 4 4133.892 1038.130634 5.108395 Nov 4 5488.176 1283.876118 -98.175903 Dec 4 5637.048 402.593267 -16.047778 Jan 5 4859.766 -514.058855 431.234179 Feb 5 5399.680 272.740100 -127.680470 Mar 5 4636.181 -531.078057 40.819265 Apr 5 3597.000 -924.397334 -77.000083 May 5 2862.411 -777.405379 -20.410700 Jun 5 2754.084 -259.057503 -31.083695 Jul 5 2577.304 -195.315580 3.695563 Aug 5 2462.455 -132.979285 -33.454761 Sep 5 2659.783 122.907993 -53.782656 Oct 5 3774.421 891.241489 12.578773 Nov 5 4692.405 911.959713 -62.404668 Dec 5 5471.954 809.499671 33.046012 Jan 6 5313.085 58.935780 263.915472 Feb 6 5014.049 -210.407149 -103.048968 Mar 6 4634.409 -341.238233 66.591139 Apr 6 3646.420 -840.816310 -89.420393 May 6 2959.126 -722.213917 -38.125527 Jun 6 2749.819 -325.790564 -15.818781 Jul 6 2621.994 -172.782028 14.005664 Aug 6 2461.087 -163.603976 -28.087497 Sep 6 2718.617 161.882459 -78.616550 Oct 6 3758.862 840.799536 35.138487 Nov 6 4815.549 1007.655585 -70.549125 Dec 6 5639.873 866.134121 58.126761 Jan 7 5667.648 217.652666 241.351811 Feb 7 5243.137 -267.954517 -124.137113 Mar 7 5092.633 -177.381958 107.367370 Apr 7 3990.480 -890.626741 -114.479527 May 7 3157.287 -846.335990 -53.286643 Jun 7 2274.891 -874.157477 -23.891281 Jul 7 2331.337 -156.126373 54.662552 Aug 7 2805.294 330.012094 -11.293699 Sep 7 3084.764 291.015918 -117.763606 Oct 7 3372.920 288.809427 19.080078 Nov 7 4784.227 1154.807638 -43.226776 Dec 7 5830.299 1071.012874 78.701094 Jan 8 5675.364 124.330204 225.636294 Feb 8 5128.297 -385.077426 -166.296987 Mar 8 4601.205 -494.392193 149.795339 Apr 8 4024.435 -557.855091 -115.435451 May 8 3171.003 -785.485101 -41.003125 Jun 8 2899.439 -389.497726 -39.438908 Jul 8 2544.839 -362.606259 23.160944 Aug 8 2532.758 -92.509125 7.242121 Sep 8 2973.035 318.035816 -79.034975 Oct 8 4227.040 1039.298064 -11.039724 Nov 8 4618.741 540.370524 -88.741032 Dec 8 5024.984 437.133924 119.016186 Jan 9 5923.457 792.883309 282.543190 Feb 9 5832.296 120.610214 -187.296070 Mar 9 4500.936 -995.506523 100.064030 Apr 9 3730.600 -822.187554 -85.599613 May 9 3195.689 -601.179318 -55.688633 Jun 9 2308.881 -821.033267 -44.881023 Jul 9 2505.570 -37.589327 51.429830 Aug 9 2441.415 -58.039466 -10.414682 Sep 9 2872.071 318.155695 -125.070678 Oct 9 4526.651 1346.966674 60.349427 Nov 9 4636.781 395.103021 -124.781229 Dec 9 5228.060 545.962276 84.939518 Jan 10 5695.198 485.249279 315.801635 Feb 10 5456.693 -65.999598 -128.693486 Mar 10 4937.991 -413.632232 76.009019 Apr 10 3755.530 -1005.003593 -125.530475 May 10 3113.554 -725.945783 -11.553523 Jun 10 2816.770 -395.887234 -77.770094 Jul 10 2796.574 -106.912016 80.426274 Aug 10 2679.151 -114.996590 -20.150971 Sep 10 3151.367 336.678704 -194.366619 Oct 10 3656.580 466.314970 128.420242 Nov 10 4900.829 1064.489800 -115.828811 Dec 10 5692.219 854.618972 64.781121 Jan 11 5163.288 -210.011551 294.711925 Feb 11 5529.483 229.345316 -102.483089 Mar 11 4918.991 -415.068951 99.008997 Apr 11 3657.225 -1065.955781 -159.225280 May 11 3207.377 -592.662020 -3.376847 Jun 11 2846.336 -414.650357 -83.336156 Jul 11 2492.890 -367.603771 96.109697 Aug 11 2614.658 8.565875 -23.658473 Sep 11 2982.391 284.653472 -177.390615 Oct 11 3201.946 234.613555 76.054197 Nov 11 4695.562 1202.008235 -80.561992 Dec 11 5405.859 824.339713 118.141493 Jan 12 5938.543 600.092958 228.456900 Feb 12 5481.812 -206.371538 -101.812461 Mar 12 5224.681 -245.297122 152.319430 Apr 12 3827.359 -1130.458247 -224.358996 May 12 2782.241 -1064.934562 -8.240699 Jun 12 2519.115 -449.063694 -49.115427 Jul 12 2321.168 -256.142114 85.832114 Aug 12 2532.925 103.330126 -20.925482 Sep 12 2608.390 81.921851 -157.390326 Oct 12 3120.116 412.118746 13.883749 Nov 12 4253.244 965.802835 -43.243989 Dec 12 4759.342 612.869458 99.657872 Jan 13 4766.310 147.318924 255.689944 Feb 13 4711.088 -7.327982 -127.088302 Mar 13 4068.874 -493.963988 198.126466 Apr 13 3245.690 -746.810569 -223.689586 May 13 2809.014 -508.793432 -32.014173 Jun 13 2475.986 -373.854608 -47.985797 Jul 13 2317.050 -208.819156 71.950010 Aug 13 2490.597 84.807556 5.402769 Sep 13 2977.222 393.374137 -157.222140 Oct 13 3873.125 779.255285 -19.124572 Nov 13 4776.493 874.518407 -28.493113 Dec 13 5547.148 794.806809 118.852033 Jan 14 5080.834 -173.637708 212.166440 Feb 14 5000.158 -102.628693 -95.158264 Mar 14 4703.365 -251.399085 216.634679 Apr 14 4100.029 -521.587842 -246.029368 May 14 2721.373 -1179.116436 -62.372606 Jun 14 2507.558 -438.347626 -16.557870 Jul 14 2378.628 -200.843193 76.372228 Aug 14 2466.292 20.620797 5.708092 Sep 14 3189.454 559.909305 -159.454184 Oct 14 4013.777 762.861905 -26.776907 Nov 14 4506.222 555.390608 -53.222057 Dec 14 5229.293 684.040023 187.706817 > m$resid Jan Feb Mar Apr May 1 0.000000000 -1.609211687 1.629216222 -2.598778236 0.280676793 2 -2.815065467 -1.064427950 -0.916404627 -1.995605849 1.995460474 3 -1.407544230 -3.916170784 1.040238997 0.918820902 -0.836170005 4 -1.378542313 -0.632649102 0.478391762 -0.990071048 -0.434014673 5 -1.765199503 1.474860631 -1.518269416 -0.742180566 0.278217132 6 -1.436926904 -0.506265719 -0.247605231 -0.942800674 0.224471958 7 -1.236849831 -0.914386650 0.171598775 -1.346316901 0.083821356 8 -1.801136726 -0.960373952 -0.207222833 -0.119824293 -0.430766186 9 0.675707382 -1.268522501 -2.116297132 0.327338873 0.418206959 10 -0.115185422 -1.040821412 -0.659202772 -1.117219297 0.528019745 11 -2.018225043 0.829950334 -1.221945776 -1.229996765 0.895496442 12 -0.424870115 -1.523971105 -0.073805237 -1.673135946 0.123969012 13 -0.881715003 -0.292316866 -0.922593537 -0.478040660 0.450307932 14 -1.833655402 0.134252114 -0.282015305 -0.510930686 -1.243962086 Jun Jul Aug Sep Oct 1 1.182921098 -0.184074586 0.867607904 0.558694011 0.213861813 2 -0.334462818 1.060403187 0.332211990 0.896813254 0.433446582 3 0.425942929 0.766691810 0.088806322 0.585766287 1.437247089 4 0.756794755 0.672288784 0.123343925 0.575570878 1.483908176 5 0.981183788 0.120657655 0.117996940 0.484371392 1.454390266 6 0.750392196 0.289631019 0.017373220 0.616116257 1.285137569 7 -0.052663555 1.359164823 0.920215968 -0.073816232 -0.004176735 8 0.749570407 0.050902920 0.511269276 0.777124904 1.365303307 9 -0.416166026 1.482980687 -0.038710237 0.712104725 1.947474933 10 0.624775700 0.547000515 -0.015303347 0.854983587 0.245393001 11 0.336962504 0.089054341 0.712053561 0.522611867 -0.094721993 12 1.165793887 0.365180800 0.680446301 -0.040524251 0.625036446 13 0.255427131 0.312395509 0.555806539 0.584094441 0.730438854 14 1.402199711 0.449572630 0.419209245 1.020836133 0.384169586 Nov Dec 1 1.211500348 1.397439739 2 0.770669383 0.768127981 3 -0.371005288 -0.214611665 4 0.465181407 -1.668974333 5 0.039218162 -0.194094889 6 0.315843500 -0.268159398 7 1.639240314 -0.158807570 8 -0.944412076 -0.195677568 9 -1.801777026 0.285959637 10 1.132297087 -0.397821398 11 1.831238149 -0.715869392 12 1.048127126 -0.668946668 13 0.180338492 -0.151073747 14 -0.392765608 0.243803621 > 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/freestat/rcomp/tmp/1csay1293018846.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/freestat/rcomp/tmp/2csay1293018846.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/freestat/rcomp/tmp/34jaj1293018846.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/freestat/rcomp/tmp/44jaj1293018846.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/freestat/rcomp/tmp/5fa9m1293018846.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/freestat/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/freestat/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/freestat/rcomp/tmp/6jt7a1293018846.tab") > > try(system("convert tmp/1csay1293018846.ps tmp/1csay1293018846.png",intern=TRUE)) character(0) > try(system("convert tmp/2csay1293018846.ps tmp/2csay1293018846.png",intern=TRUE)) character(0) > try(system("convert tmp/34jaj1293018846.ps tmp/34jaj1293018846.png",intern=TRUE)) character(0) > try(system("convert tmp/44jaj1293018846.ps tmp/44jaj1293018846.png",intern=TRUE)) character(0) > try(system("convert tmp/5fa9m1293018846.ps tmp/5fa9m1293018846.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.028 1.276 3.745