R version 2.13.0 (2011-04-13) Copyright (C) 2011 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(4581945 + ,3874038 + ,4086290 + ,4364364 + ,3793586 + ,4533914 + ,4823043 + ,3981535 + ,4746356 + ,5284534 + ,4264830 + ,3924674 + ,3734753 + ,3762290 + ,3609739 + ,3877594 + ,3636415 + ,3578195 + ,3604342 + ,3459513 + ,3366571 + ,3371277 + ,3724848 + ,3350830 + ,3305159 + ,3390736 + ,3349758 + ,3253655 + ,3734250 + ,3455433 + ,2966726 + ,2993716 + ,3009320 + ,3169713 + ,3170061 + ,3368934 + ,3292638 + ,3337344 + ,3208306 + ,3359130 + ,3223078 + ,3437159 + ,3400156 + ,3657576 + ,3765613 + ,3481921 + ,3604800 + ,3981340 + ,3734078 + ,4018173 + ,3887417 + ,3919880 + ,4014466 + ,4197758 + ,3896531 + ,3964742 + ,4201847 + ,4050512 + ,3997402 + ,4314479 + ,4925744 + ,5130631 + ,4444855 + ,3967319 + ,3931250 + ,4235952 + ,4169219 + ,3779064 + ,3558810 + ,3699466 + ,3650693 + ,3525633 + ,3470276 + ,3859094 + ,3661155 + ,3356365 + ,3344440 + ,3338684 + ,3404294 + ,3289319 + ,3469252 + ,3571850 + ,3639914 + ,3091730 + ,3078149 + ,3188115 + ,3246082 + ,3486992 + ,3378187 + ,3282306 + ,3288345 + ,3325749 + ,3352262 + ,3531954 + ,3722622 + ,3809365 + ,3750617 + ,3615286 + ,3696556 + ,4123959 + ,4136163 + ,3933392 + ,4035576 + ,4551202 + ,4032195 + ,3970893 + ,4489016 + ,5426127 + ,4578224 + ,4126390 + ,4892100 + ,4128697 + ,4408721 + ,4199465 + ,4074767 + ,4161758 + ,3891319 + ,4470302 + ,4283111 + ,3845962 + ,3911471 + ,3798478 + ,3644313 + ,3784029 + ,3647134 + ,3994662 + ,3607836 + ,3566008 + ,3511412 + ,3258665 + ,3486573 + ,3369443 + ,3465544 + ,3905224 + ,3733881 + ,3220642 + ,3225812 + ,3354461 + ,3352261 + ,3450652) > 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 26905405369 0 0 42705113457 > m$fitted level slope sea Jan 1 4581945 0.00000 0.00000 Feb 1 4133246 -33907.28625 -33907.28625 Mar 1 4111055 -33383.21408 -33383.21408 Apr 1 4252143 -28254.22552 -28254.22552 May 1 4006637 -33082.16497 -33082.16497 Jun 1 4293286 -27062.22282 -27062.22282 Jul 1 4580454 -21672.32357 -21672.32357 Aug 1 4259918 -26531.76585 -26531.76585 Sep 1 4523553 -21968.81723 -21968.81723 Oct 1 4934478 -15320.78083 -15320.78083 Nov 1 4575496 -20499.17534 -20499.17534 Dec 1 4227026 -25359.34739 -25359.34739 Jan 2 3942042 -2845.99240 31305.91643 Feb 2 3835243 -6420.35781 -6420.35783 Mar 2 3711255 -8819.92561 -8819.92561 Apr 2 3802253 -7466.64615 -7466.64615 May 2 3713331 -8310.12469 -8310.12469 Jun 2 3641152 -8875.79455 -8875.79455 Jul 2 3622011 -8959.35240 -8959.35240 Aug 2 3535200 -9565.19835 -9565.19835 Sep 2 3445142 -10175.98232 -10175.98232 Oct 2 3406155 -10391.19245 -10391.19245 Nov 2 3578534 -9041.22058 -9041.22058 Dec 2 3456635 -9867.24794 -9867.24794 Jan 3 3339879 -5450.34040 59953.74444 Feb 3 3369979 -4651.81984 -4651.81986 Mar 3 3359346 -4730.98452 -4730.98452 Apr 3 3302527 -5189.75396 -5189.75396 May 3 3535848 -3580.24290 -3580.24290 Jun 3 3492789 -3808.79106 -3808.79106 Jul 3 3209685 -5299.09631 -5299.09631 Aug 3 3093766 -5864.90153 -5864.90153 Sep 3 3048736 -6060.74111 -6060.74111 Oct 3 3114360 -5706.98230 -5706.98230 Nov 3 3144800 -5530.15091 -5530.15091 Dec 3 3265941 -4914.56983 -4914.56983 Jan 4 3250699 -4634.45096 50978.96059 Feb 4 3300326 -3729.45305 -3729.45306 Mar 4 3250466 -4181.18312 -4181.18312 Apr 4 3309559 -3768.47686 -3768.47686 May 4 3263212 -3981.57667 -3981.57667 Jun 4 3357267 -3560.02832 -3560.02832 Jul 4 3380651 -3453.09714 -3453.09714 Aug 4 3530102 -2870.64021 -2870.64021 Sep 4 3657192 -2386.04629 -2386.04629 Oct 4 3562962 -2724.45520 -2724.45520 Nov 4 3585710 -2631.29887 -2631.29887 Dec 4 3799029 -1845.79912 -1845.79912 Jan 5 3757318 -1041.02774 11451.30513 Feb 5 3903530 912.06553 912.06552 Mar 5 3894682 836.21337 836.21337 Apr 5 3908229 902.04589 902.04589 May 5 3965449 1126.04086 1126.04086 Jun 5 4090561 1550.08030 1550.08030 Jul 5 3985895 1214.51947 1214.51947 Aug 5 3974404 1175.96405 1175.96405 Sep 5 4096846 1536.46582 1536.46582 Oct 5 4071765 1458.21633 1458.21633 Nov 5 4031591 1336.64670 1336.64670 Dec 5 4183887 1775.39824 1775.39824 Jan 6 4557280 -4198.86903 46187.55937 Feb 6 4876727 -635.73290 -635.73290 Mar 6 4642164 -2142.59464 -2142.59464 Apr 6 4277859 -3697.81676 -3697.81676 May 6 4091252 -4301.39958 -4301.39958 Jun 6 4169571 -4066.82770 -4066.82770 Jul 6 4169697 -4055.82559 -4055.82559 Aug 6 3959540 -4575.58519 -4575.58519 Sep 6 3743990 -5097.05004 -5097.05004 Oct 6 3720397 -5142.28078 -5142.28078 Nov 6 3683241 -5220.07968 -5220.07968 Dec 6 3598732 -5411.96411 -5411.96411 Jan 7 3502584 -4200.05650 46200.62149 Feb 7 3700449 -2298.60692 -2298.60691 Mar 7 3679323 -2402.16578 -2402.16578 Apr 7 3505142 -3032.21009 -3032.21009 May 7 3418733 -3267.30313 -3267.30313 Jun 7 3375846 -3363.45619 -3363.45619 Jul 7 3391437 -3320.92513 -3320.92513 Aug 7 3336671 -3431.90612 -3431.90612 Sep 7 3408373 -3272.98788 -3272.98788 Oct 7 3496708 -3081.21296 -3081.21296 Nov 7 3574106 -2913.72716 -2913.72716 Dec 7 3314431 -3446.02837 -3446.02837 Jan 8 3174898 -1891.43081 20805.73891 Feb 8 3182387 -1814.35115 -1814.35114 Mar 8 3217073 -1639.17893 -1639.17893 Apr 8 3362906 -1167.15084 -1167.15084 May 8 3371236 -1143.77364 -1143.77364 Jun 8 3323397 -1242.73022 -1242.73022 Jul 8 3304605 -1277.12491 -1277.12491 Aug 8 3316097 -1253.05660 -1253.05660 Sep 8 3335681 -1214.53993 -1214.53993 Oct 8 3441531 -1018.61238 -1018.61238 Nov 8 3593066 -741.00801 -741.00801 Dec 8 3709669 -528.23956 -528.23956 Jan 9 3727222 -708.68127 7795.49392 Feb 9 3665690 -1152.17746 -1152.17745 Mar 9 3682509 -1075.68005 -1075.68005 Apr 9 3920847 -395.91321 -395.91321 May 9 4036961 -141.46478 -141.46478 Jun 9 3981154 -246.15704 -246.15704 Jul 9 4010500 -194.67343 -194.67343 Aug 9 4301872 293.25908 293.25908 Sep 9 4156537 54.20135 54.20135 Oct 9 4056502 -108.49041 -108.49041 Nov 9 4289562 268.46261 268.46261 Dec 9 4901956 1254.72079 1254.72079 Jan 10 4744394 2661.75329 -29279.28618 Feb 10 4404745 418.28395 418.28394 Mar 10 4668614 1425.78885 1425.78885 Apr 10 4377147 678.56714 678.56714 May 10 4394116 710.53985 710.53985 Jun 10 4289154 531.89891 531.89891 Jul 10 4173583 350.30268 350.30268 Aug 10 4167184 340.14641 340.14641 Sep 10 4018508 120.15578 120.15578 Oct 10 4261945 475.89811 475.89811 Nov 10 4273313 491.73904 491.73904 Dec 10 4043000 157.14280 157.14280 Jan 11 3976475 688.30156 -7571.31711 Feb 11 3878828 103.03929 103.03928 Mar 11 3751885 -338.01880 -338.01880 Apr 11 3769255 -297.00287 -297.00287 May 11 3703443 -413.75901 -413.75901 Jun 11 3860427 -172.11545 -172.11545 Jul 11 3724321 -365.22699 -365.22699 Aug 11 3639040 -481.30099 -481.30099 Sep 11 3570304 -572.84738 -572.84738 Oct 11 3402420 -795.11819 -795.11819 Nov 11 3447828 -734.05258 -734.05258 Dec 11 3405647 -788.66348 -788.66348 Jan 12 3431663 -982.60680 10808.67478 Feb 12 3690994 436.33654 436.33654 Mar 12 3714163 508.59364 508.59364 Apr 12 3447861 -57.24581 -57.24581 May 12 3328162 -252.50120 -252.50120 Jun 12 3342356 -232.18918 -232.18918 Jul 12 3347712 -224.91736 -224.91736 Aug 12 3403201 -155.15039 -155.15039 > m$resid Jan Feb Mar Apr May Jun 1 0.00000000 -1.93254226 0.06487896 1.02608922 -1.30166029 1.92870349 2 -2.04136674 -0.52074783 -0.67941741 0.59728093 -0.49237187 -0.38741059 3 -0.74468794 0.19168803 -0.03523737 -0.31373836 1.44603146 -0.23988747 4 -0.06893335 0.30251983 -0.27423012 0.38232066 -0.25851476 0.59621986 5 -0.26030281 0.83680578 -0.05833107 0.07695017 0.34221990 0.75440808 6 2.39425205 1.86210948 -1.40281261 -2.19500925 -1.11209355 0.50288466 7 -0.57934693 1.17270885 -0.11317817 -1.04201854 -0.50713614 -0.24120783 8 -0.86329068 0.05479423 0.21981028 0.89514576 0.05778510 -0.28433420 9 0.11414270 -0.35701738 0.10837842 1.45394189 0.70903121 -0.33900024 10 -0.99874884 -2.01717522 1.59054233 -1.77942173 0.09915462 -0.64360851 11 -0.41806143 -0.58131479 -0.76771847 0.10762106 -0.39882861 0.95873203 12 0.16762886 1.54292580 0.13747369 -1.62191360 -0.72841897 0.08799749 Jul Aug Sep Oct Nov Dec 1 1.90081175 -1.81010415 1.75847801 2.62425918 -2.08370583 -1.98882410 2 -0.06234689 -0.47313785 -0.48931962 -0.17516868 1.11128913 -0.68623412 3 -1.69859365 -0.67300802 -0.23831881 0.43623820 0.21997929 0.77090384 4 0.16396514 0.93075669 0.79118767 -0.55917317 0.15508819 1.31482647 5 -0.64661860 -0.07736137 0.73847162 -0.16209905 -0.25354887 0.91937130 6 0.02553136 -1.25522526 -1.28500820 -0.11265957 -0.19499801 -0.48296905 7 0.11543758 -0.31335758 0.45768462 0.55806152 0.49027222 -1.56418400 8 -0.10689188 0.07778971 0.12694221 0.65227982 0.92943508 0.71492003 9 0.18026518 1.77634345 -0.88727374 -0.60983317 1.42068549 3.72967086 10 -0.70732039 -0.04112337 -0.90797144 1.48259288 0.06636836 -1.40637167 11 -0.82818282 -0.51740896 -0.41590362 -1.01951403 0.28154210 -0.25256135 12 0.03404836 0.33949248 > 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/10xhh1322734420.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/2zrdk1322734420.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/3vtb91322734420.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/4p7g31322734420.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/5ikqa1322734420.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/6n4ku1322734420.tab") > > try(system("convert tmp/10xhh1322734420.ps tmp/10xhh1322734420.png",intern=TRUE)) character(0) > try(system("convert tmp/2zrdk1322734420.ps tmp/2zrdk1322734420.png",intern=TRUE)) character(0) > try(system("convert tmp/3vtb91322734420.ps tmp/3vtb91322734420.png",intern=TRUE)) character(0) > try(system("convert tmp/4p7g31322734420.ps tmp/4p7g31322734420.png",intern=TRUE)) character(0) > try(system("convert tmp/5ikqa1322734420.ps tmp/5ikqa1322734420.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.238 0.272 2.519