R version 2.7.1 (2008-06-23) 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. 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(112,118,132,129,121,135,148,148,136,119,104,118,115,126,141,135,125,149,170,170,158,133,114,140,145,150,178,163,172,178,199,199,184,162,146,166,171,180,193,181,183,218,230,242,209,191,172,194,196,196,236,235,229,243,264,272,237,211,180,201,204,188,235,227,234,264,302,293,259,229,203,229,242,233,267,269,270,315,364,347,312,274,237,278,284,277,317,313,318,374,413,405,355,306,271,306,315,301,356,348,355,422,465,467,404,347,305,336,340,318,362,348,363,435,491,505,404,359,310,337,360,342,406,396,420,472,548,559,463,407,362,405,417,391,419,461,472,535,622,606,508,461,390,432) > 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 0.00000 160.97552 29.84652 0.00000 > m$fitted level slope sea Jan 1 112.0000 0.0000000 0.0000000 Feb 1 116.6627 4.7731846 1.3373393 Mar 1 130.3654 11.0862936 1.6346056 Apr 1 132.2554 4.1962646 -3.2554039 May 1 123.4946 -5.3023160 -2.4946263 Jun 1 130.6818 3.8213588 4.3182049 Jul 1 145.9541 12.2106078 2.0458538 Aug 1 150.7955 6.8093281 -2.7954622 Sep 1 139.9905 -6.0992166 -3.9905205 Oct 1 120.9578 -15.5758530 -1.9578026 Nov 1 103.4520 -16.9899079 0.5480121 Dec 1 111.3207 1.2240597 6.6792751 Jan 2 116.0844 3.8113458 -1.0844083 Feb 2 126.6033 8.7319366 -0.6032926 Mar 2 136.8854 9.8266025 4.1145709 Apr 2 136.6235 2.7026425 -1.6235105 May 2 132.2658 -2.3064439 -7.2657825 Jun 2 144.7753 8.1259296 4.2246820 Jul 2 165.1234 16.7344098 4.8765654 Aug 2 172.0741 9.8336802 -2.0740602 Sep 2 162.3749 -3.9467954 -4.3749104 Oct 2 137.8905 -18.4354259 -4.8905437 Nov 2 118.5544 -19.0706501 -4.5544023 Dec 2 126.4104 -0.0991672 13.5895797 Jan 3 144.5567 12.7565716 0.4432864 Feb 3 153.0599 9.7558766 -3.0598761 Mar 3 168.0546 13.4122460 9.9454195 Apr 3 166.1793 2.7649581 -3.1793491 May 3 180.7019 10.9918316 -8.7019076 Jun 3 182.6633 4.6935147 -4.6632713 Jul 3 191.5728 7.6291331 7.4272186 Aug 3 196.3072 5.6113721 2.6928138 Sep 3 184.8344 -6.3042907 -0.8343701 Oct 3 167.3629 -14.0929320 -5.3629440 Nov 3 156.8838 -11.5736791 -10.8838101 Dec 3 155.2560 -4.6447546 10.7440428 Jan 4 165.8134 5.9535705 5.1866107 Feb 4 181.9197 13.0291186 -1.9196704 Mar 4 182.2668 4.2362944 10.7331803 Apr 4 187.0905 4.6430325 -6.0904729 May 4 190.4105 3.7242179 -7.4104741 Jun 4 218.8996 20.9062887 -0.8996352 Jul 4 227.0411 12.0647608 2.9588641 Aug 4 234.3416 8.7635814 7.6583886 Sep 4 213.3321 -11.8793694 -4.3320563 Oct 4 196.5211 -15.2988630 -5.5210878 Nov 4 184.6596 -12.9163868 -12.6595537 Dec 4 184.9232 -3.7828298 9.0768476 Jan 5 191.2187 3.2056318 4.7812589 Feb 5 193.5794 2.6201147 2.4206347 Mar 5 218.3071 17.8926386 17.6928680 Apr 5 241.2295 21.3648407 -6.2294954 May 5 249.1423 12.0615504 -20.1423307 Jun 5 245.7061 1.3444864 -2.7060599 Jul 5 257.0653 8.2612595 6.9347390 Aug 5 257.4232 2.8034225 14.5767573 Sep 5 242.9183 -9.1545606 -5.9183193 Oct 5 219.7176 -18.8597752 -8.7176216 Nov 5 196.5544 -21.8326821 -16.5544020 Dec 5 189.5524 -11.5865156 11.4476000 Jan 6 194.8948 0.1139696 9.1052244 Feb 6 193.9680 -0.6047999 -5.9680102 Mar 6 213.7698 13.4610167 21.2301768 Apr 6 229.3182 14.8991855 -2.3182450 May 6 249.2278 18.3554253 -15.2277664 Jun 6 270.8827 20.6319762 -6.8827109 Jul 6 293.3736 21.9134539 8.6263882 Aug 6 281.8732 -1.1123282 11.1267973 Sep 6 262.8385 -13.4650232 -3.8385441 Oct 6 237.9917 -21.3106155 -8.9917209 Nov 6 221.8125 -17.7735208 -18.8125444 Dec 6 217.8790 -8.2316577 11.1209842 Jan 7 227.4850 4.0691593 14.5150225 Feb 7 242.2508 11.4403318 -9.2507601 Mar 7 248.0626 7.5670766 18.9373603 Apr 7 270.0310 17.4745675 -1.0310427 May 7 289.2444 18.6718157 -19.2443593 Jun 7 320.6910 27.4708743 -5.6910074 Jul 7 346.4582 26.2981469 17.5417691 Aug 7 338.3996 2.6597389 8.6004471 Sep 7 316.2412 -14.4152507 -4.2412466 Oct 7 286.8088 -24.7480933 -12.8088389 Nov 7 259.8360 -26.2790737 -22.8359541 Dec 7 264.0103 -5.3172980 13.9897036 Jan 8 269.6684 2.2380933 14.3316285 Feb 8 281.2219 8.6466174 -4.2219020 Mar 8 299.7337 15.4262942 17.2662835 Apr 8 316.1650 16.1167838 -3.1649527 May 8 341.7878 22.6527974 -23.7878075 Jun 8 378.0812 32.0346741 -4.0812186 Jul 8 390.9817 18.8801434 22.0182915 Aug 8 391.7170 6.4123129 13.2830406 Sep 8 361.6475 -18.6508147 -6.6475177 Oct 8 321.6317 -33.3295989 -15.6317120 Nov 8 299.2090 -25.8346024 -28.2089817 Dec 8 290.6476 -13.9615004 15.3523596 Jan 9 297.7003 0.4832662 17.2997352 Feb 9 305.7670 5.6928955 -4.7669959 Mar 9 333.3221 20.6993533 22.6778576 Apr 9 356.3835 22.3204232 -8.3835016 May 9 384.0880 26.0176014 -29.0880097 Jun 9 420.3627 33.0633138 1.6372748 Jul 9 441.5824 24.9304680 23.4175885 Aug 9 445.9233 10.7993930 21.0766968 Sep 9 413.0913 -19.1376659 -9.0913354 Oct 9 369.4977 -35.9184597 -22.4976913 Nov 9 336.3594 -34.0103332 -31.3594266 Dec 9 321.2343 -21.0453304 14.7656714 Jan 10 319.8876 -7.5223810 20.1124253 Feb 10 325.7851 1.6852145 -7.7850991 Mar 10 337.5925 8.6255536 24.4074598 Apr 10 357.2402 16.1821124 -9.2402331 May 10 393.3108 29.8234812 -30.3108113 Jun 10 431.3385 35.4524332 3.6614925 Jul 10 463.2158 33.0001119 27.7842281 Aug 10 474.7164 18.2605079 30.2835813 Sep 10 421.5512 -30.6917993 -17.5511736 Oct 10 381.0457 -37.4178140 -22.0457121 Nov 10 346.0975 -35.7247511 -36.0975301 Dec 10 323.9909 -26.3863192 13.0090646 Jan 11 333.6135 -1.6953703 26.3865155 Feb 11 348.3405 9.5595366 -6.3404606 Mar 11 379.5356 24.3788300 26.4644261 Apr 11 411.7351 29.7351664 -15.7350828 May 11 453.4403 37.9365978 -33.4402919 Jun 11 475.7819 27.2483812 -3.7818531 Jul 11 510.9559 32.6792162 37.0441051 Aug 11 513.6633 12.1518515 45.3367099 Sep 11 484.8765 -15.8768915 -21.8765116 Oct 11 434.8407 -39.2639975 -27.8406873 Nov 11 399.1402 -36.8235512 -37.1402198 Dec 11 394.1817 -14.9955799 10.8182571 Jan 12 392.7148 -5.7290279 24.2851873 Feb 12 400.3772 3.4391874 -9.3771850 Mar 12 397.7033 -0.7439362 21.2966637 Apr 12 463.8640 45.0355882 -2.8639611 May 12 506.9738 43.7174068 -34.9737543 Jun 12 544.9161 39.7633944 -9.9160916 Jul 12 578.0951 35.2560029 43.9049215 Aug 12 560.0433 -1.2195623 45.9567447 Sep 12 524.0762 -24.9870462 -16.0761883 Oct 12 490.5008 -30.8615125 -29.5007565 Nov 12 441.0112 -43.6064595 -51.0112310 Dec 12 417.8508 -29.6143515 14.1492386 > m$resid Jan Feb Mar Apr May Jun 1 0.00000000 0.42422809 0.52904818 -0.55572225 -0.74310514 0.72013014 2 0.20450776 0.39384249 0.08591047 -0.57008286 -0.39434193 0.82076550 3 1.01622754 -0.23684207 0.28757658 -0.84393694 0.64940043 -0.49550888 4 0.83683713 0.55759286 -0.69229478 0.03214198 -0.07253048 1.35283019 5 0.55134683 -0.04613040 1.20301536 0.27407022 -0.73415965 -0.84427593 6 0.92265738 -0.05662757 1.10820944 0.11345860 0.27267332 0.17940001 7 0.96973954 0.58074584 -0.30520033 0.78139771 0.09443710 0.69351420 8 0.59554286 0.50491919 0.53425438 0.05444996 0.51548476 0.73951735 9 1.13849103 0.41047252 1.18259471 0.12782039 0.29156373 0.55539741 10 1.06578526 0.72549657 0.54695369 0.59579175 1.07570035 0.44372704 11 1.94591938 0.88683245 1.16789995 0.42229734 0.64669522 -0.84255214 12 0.73029748 0.72242702 -0.32967404 3.60916422 -0.10393600 -0.31169451 Jul Aug Sep Oct Nov Dec 1 0.66141393 -0.42569262 -1.01743382 -0.74692093 -0.11145158 1.43557121 2 0.67899937 -0.54395057 -1.08607976 -1.14202128 -0.05006679 1.49570940 3 0.23138002 -0.15907690 -0.93911986 -0.61390470 0.19856133 0.54645410 4 -0.69655474 -0.26022768 -1.62704133 -0.26951536 0.18779440 0.72034231 5 0.54486511 -0.43015892 -0.94252760 -0.76495796 -0.23435472 0.80801810 6 0.10095301 -1.81455027 -0.97363009 -0.61842045 0.27885046 0.75239996 7 -0.09239376 -1.86269968 -1.34581034 -0.81452213 -0.12070278 1.65275188 8 -1.03646641 -0.98242996 -1.97537636 -1.15715377 0.59092595 0.93608881 9 -0.64083988 -1.11347788 -2.35948271 -1.32289021 0.15044418 1.02212985 10 -0.19324345 -1.16143084 -3.85812331 -0.53024103 0.13348802 0.73619548 11 0.42796598 -1.61750230 -2.20904066 -1.84370693 0.19241344 1.72076553 12 -0.35520528 -2.87421683 -1.87319018 -0.46310653 -1.00484347 1.10301852 > 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/1q8v81223135307.ps",horizontal=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/20bja1223135307.ps",horizontal=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/35b681223135307.ps",horizontal=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/411j61223135307.ps",horizontal=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/5gb8j1223135307.ps",horizontal=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/6hhhs1223135308.tab") > > system("convert tmp/1q8v81223135307.ps tmp/1q8v81223135307.png") > system("convert tmp/20bja1223135307.ps tmp/20bja1223135307.png") > system("convert tmp/35b681223135307.ps tmp/35b681223135307.png") > system("convert tmp/411j61223135307.ps tmp/411j61223135307.png") > system("convert tmp/5gb8j1223135307.ps tmp/5gb8j1223135307.png") > > > proc.time() user system elapsed 2.270 0.854 2.808