R version 2.12.0 (2010-10-15) Copyright (C) 2010 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(13328,12873,14000,13477,14237,13674,13529,14058,12975,14326,14008,16193,14483,14011,15057,14884,15414,14440,14900,15074,14442,15307,14938,17193,15528,14765,15838,15723,16150,15486,15986,15983,15692,16490,15686,18897,16316,15636,17163,16534,16518,16375,16290,16352,15943,16362,16393,19051,16747,16320,17910,16961,17480,17049,16879,17473,16998,17307,17418,20169,17871,17226,19062,17804,19100,18522,18060,18869,18127,18871,18890,21263,19547,18450,20254,19240,20216,19420,19415,20018,18652,19978,19509,21971) > 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 15123.8925 51.9884 56600.9232 0.0000 > m$fitted level slope sea Jan 1 13328.00 0.000000 0.00000 Feb 1 13200.61 3.821533 -327.60964 Mar 1 13460.25 21.998825 539.74732 Apr 1 13535.99 26.277875 -58.98692 May 1 13789.38 42.162268 447.61934 Jun 1 13834.08 42.304895 -160.07859 Jul 1 13756.19 36.769597 -227.19425 Aug 1 13824.11 38.041401 233.89185 Sep 1 13582.50 27.030707 -607.49840 Oct 1 13729.75 31.841450 596.25301 Nov 1 13869.99 36.341649 138.00505 Dec 1 14657.75 68.755213 1535.24858 Jan 2 14940.97 73.377380 -457.96872 Feb 2 14973.31 72.310967 -962.30547 Mar 2 14910.20 66.740643 146.79576 Apr 2 14966.77 66.209609 -82.76659 May 2 14983.39 63.397120 430.61484 Jun 2 14841.90 51.759861 -401.90173 Jul 2 14877.57 50.878192 22.42748 Aug 2 14855.28 47.043459 218.71693 Sep 2 14996.14 51.771212 -554.13901 Oct 2 15086.87 53.673262 220.12550 Nov 2 15227.87 57.817225 -289.86820 Dec 2 15465.19 66.119221 1727.81145 Jan 3 15699.36 73.785751 -171.35754 Feb 3 15768.90 73.587173 -1003.89750 Mar 3 15770.23 70.023412 67.77441 Apr 3 15767.79 66.259056 -44.79442 May 3 15725.55 60.428802 424.44985 Jun 3 15780.16 60.111807 -294.15555 Jul 3 15877.23 62.117940 108.77081 Aug 3 15928.55 61.539014 54.45159 Sep 3 16100.19 67.347624 -408.19225 Oct 3 16281.84 73.282936 208.16353 Nov 3 16325.10 71.743776 -639.10178 Dec 3 16660.86 85.183815 2236.13709 Jan 4 16722.82 84.001356 -406.82119 Feb 4 16713.58 79.216840 -1077.57710 Mar 4 16831.78 81.242862 331.22430 Apr 4 16796.04 75.081046 -262.03614 May 4 16595.76 60.429534 -77.76335 Jun 4 16599.69 57.407495 -224.69356 Jul 4 16513.57 49.727150 -223.57406 Aug 4 16484.46 45.521398 -132.45877 Sep 4 16491.13 43.459683 -548.13229 Oct 4 16429.67 37.921577 -67.66523 Nov 4 16668.18 48.461548 -275.18040 Dec 4 16787.46 52.173454 2263.53751 Jan 5 16927.77 56.792743 -180.77220 Feb 5 17113.10 63.544381 -793.10419 Mar 5 17270.62 68.498015 639.37915 Apr 5 17247.87 63.669408 -286.86552 May 5 17325.07 64.387690 154.93180 Jun 5 17312.03 60.271038 -263.02794 Jul 5 17242.32 53.358113 -363.32341 Aug 5 17351.46 56.322625 121.53642 Sep 5 17478.67 60.084165 -480.67220 Oct 5 17568.38 61.653653 -261.38453 Nov 5 17693.24 64.996617 -275.23927 Dec 5 17860.16 70.382995 2308.84047 Jan 6 18029.55 75.614397 -158.54566 Feb 6 18110.44 75.893580 -884.44050 Mar 6 18234.47 78.441189 827.52958 Apr 6 18242.10 74.689292 -438.09946 May 6 18466.82 82.646023 633.17641 Jun 6 18650.02 87.981599 -128.02301 Jul 6 18689.53 85.408832 -629.52614 Aug 6 18776.60 85.496982 92.40369 Sep 6 18804.52 82.443515 -677.52119 Oct 6 18980.91 87.423696 -109.91369 Nov 6 19161.23 92.345376 -271.22699 Dec 6 19208.34 89.949544 2054.65942 Jan 7 19420.03 96.397182 126.97324 Feb 7 19505.23 95.804423 -1055.23376 Mar 7 19548.79 93.036172 705.20617 Apr 7 19679.91 95.054370 -439.90632 May 7 19740.47 93.225728 475.52971 Jun 7 19722.55 87.332088 -302.55447 Jul 7 19854.63 89.704699 -439.62633 Aug 7 19957.11 90.382539 60.88653 Sep 7 19856.40 80.250385 -1204.40468 Oct 7 19952.88 81.110616 25.11853 Nov 7 19964.53 77.428599 -455.52839 Dec 7 20006.57 75.553236 1964.42666 > m$resid Jan Feb Mar Apr May Jun 1 0.00000000 -1.30910991 1.31766721 0.31190210 1.58143734 0.01924003 2 1.70441403 -0.32902089 -1.01366963 -0.07218924 -0.35218512 -1.49386944 3 1.26382719 -0.03188334 -0.53599549 -0.52967147 -0.78914868 -0.04257444 4 -0.17202318 -0.69027661 0.28759250 -0.85920716 -2.01772616 -0.41444467 5 0.64952499 0.94730097 0.69187125 -0.67085874 0.09939844 -0.56879138 6 0.72843193 0.03885560 0.35411267 -0.52066657 1.10276756 0.73907939 7 0.89524652 -0.08229765 -0.38420456 0.27996648 -0.25356379 -0.81706658 Jul Aug Sep Oct Nov Dec 1 -0.93687538 0.24393247 -2.18563597 0.93563572 0.83989280 5.79778378 2 -0.11989604 -0.55070546 0.70731938 0.29317480 0.65522053 1.34613438 3 0.27249805 -0.08004502 0.81698322 0.84680101 -0.22207411 1.95349649 4 -1.05580417 -0.58126282 -0.28653900 -0.77335595 1.47741620 0.52164513 5 -0.95569743 0.41050325 0.52176265 0.21801432 0.46490500 0.74974631 6 -0.35643002 0.01221846 -0.42345902 0.69094260 0.68305589 -0.33260232 7 0.32893991 0.09399091 -1.40517489 0.11931478 -0.51074564 -0.26016164 > 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 > postscript(file="/var/www/rcomp/tmp/11jl61291922403.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') > grid() > dev.off() null device 1 > mylagmax <- nx/2 > postscript(file="/var/www/rcomp/tmp/21jl61291922403.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/rcomp/tmp/3ct2r1291922403.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/rcomp/tmp/4ct2r1291922403.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/rcomp/tmp/5ftjf1291922403.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/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/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/rcomp/tmp/6flxt1291922403.tab") > > try(system("convert tmp/11jl61291922403.ps tmp/11jl61291922403.png",intern=TRUE)) character(0) > try(system("convert tmp/21jl61291922403.ps tmp/21jl61291922403.png",intern=TRUE)) character(0) > try(system("convert tmp/3ct2r1291922403.ps tmp/3ct2r1291922403.png",intern=TRUE)) character(0) > try(system("convert tmp/4ct2r1291922403.ps tmp/4ct2r1291922403.png",intern=TRUE)) character(0) > try(system("convert tmp/5ftjf1291922403.ps tmp/5ftjf1291922403.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.840 0.840 2.709