R version 2.9.0 (2009-04-17) Copyright (C) 2009 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(27951,29781,32914,33488,35652,36488,35387,35676,34844,32447,31068,29010,29812,30951,32974,32936,34012,32946,31948,30599,27691,25073,23406,22248,22896,25317,26558,26471,27543,26198,24725,25005,23462,20780,19815,19761,21454,23899,24939,23580,24562,24696,23785,23812,21917,19713,19282,18788,21453,24482,27474,27264,27349,30632,29429,30084,26290,24379,23335,21346,21106,24514,28353,30805,31348,34556,33855,34787,32529,29998,29257,28155,30466,35704,39327,39351,42234,43630,43722,43121,37985,37135,34646,33026,35087,38846,42013,43908,42868,44423,44167,43636,44382,42142,43452,36912,42413,45344,44873,47510,49554,47369,45998,48140,48441,44928,40454,38661,37246,36843,36424,37594,38144,38737,34560,36080,33508,35462,33374,32110,35533,35532,37903,36763,40399,44164,44496,43110,43880,43930,44327) > 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 4030922.57 0.00 17000.99 0.00 > m$fitted level slope sea Jan 1 27951.00 0.00000 0.000000 Feb 1 29682.28 94.83604 98.719109 Mar 1 32768.59 109.95275 145.407268 Apr 1 33382.27 111.91072 105.732969 May 1 35508.96 120.06351 143.038887 Jun 1 36364.21 123.03196 123.788771 Jul 1 35286.80 118.20515 100.202244 Aug 1 35550.40 118.78743 125.597732 Sep 1 34741.07 115.08540 102.928800 Oct 1 32368.89 105.20374 78.114820 Nov 1 30976.99 99.27947 91.008805 Dec 1 28939.50 90.85722 70.500917 Jan 2 30226.24 40.52803 -414.241509 Feb 2 30918.29 56.02862 32.708008 Mar 2 32835.78 62.02559 138.223763 Apr 2 32916.50 62.05779 19.498297 May 2 33916.82 63.84148 95.176896 Jun 2 32901.39 61.76835 44.610931 Jul 2 31928.24 59.78523 19.762083 Aug 2 30559.48 57.05351 39.523642 Sep 2 27685.91 51.46094 5.089236 Oct 2 25083.68 46.39766 -10.684884 Nov 2 23361.47 42.89487 44.531939 Dec 2 22251.99 41.19568 -3.990377 Jan 3 23120.21 25.44585 -224.213502 Feb 3 25278.94 57.14812 38.059341 Mar 3 26399.79 60.22385 158.213898 Apr 3 26494.22 60.26244 -23.220822 May 3 27405.06 61.34645 137.937312 Jun 3 26194.52 59.66917 3.483946 Jul 3 24733.67 57.66595 -8.665043 Aug 3 24895.24 57.80256 109.756572 Sep 3 23454.44 55.83594 7.556300 Oct 3 20825.44 52.27890 -45.443514 Nov 3 19735.86 50.63972 79.135263 Dec 3 19757.05 50.62386 3.947680 Jan 4 21689.10 28.23992 -235.102441 Feb 4 23843.34 50.67463 55.662730 Mar 4 24773.27 53.15259 165.731447 Apr 4 23711.46 52.14691 -131.464369 May 4 24366.49 52.73503 195.511691 Jun 4 24647.08 52.97254 48.921783 Jul 4 23857.58 52.09088 -72.576848 Aug 4 23683.96 51.85537 128.039499 Sep 4 21910.22 49.95261 6.783752 Oct 4 19790.80 47.62565 -77.802662 Nov 4 19183.34 46.85457 98.661360 Dec 4 18840.87 46.85549 -52.866610 Jan 5 21599.16 24.22141 -146.162848 Feb 5 24388.85 46.33477 93.146028 Mar 5 27166.42 53.96382 307.584198 Apr 5 27446.50 54.15041 -182.502334 May 5 27192.34 53.90290 156.660335 Jun 5 30398.50 56.69134 233.501162 Jul 5 29593.33 55.91830 -164.330644 Aug 5 29885.19 56.12918 198.808315 Sep 5 26371.92 52.93162 -81.915476 Oct 5 24470.52 51.08578 -91.518850 Nov 5 23212.79 49.76843 122.209641 Dec 5 21545.59 50.37044 -199.594383 Jan 6 21544.47 50.68993 -438.473036 Feb 6 24419.36 68.49211 94.644740 Mar 6 27882.35 77.86744 470.645280 Apr 6 30819.12 80.21295 -14.124803 May 6 31339.92 80.51926 8.084622 Jun 6 34138.13 82.64206 417.866700 Jul 6 34089.58 82.53667 -234.582478 Aug 6 34416.34 82.73243 370.664718 Sep 6 32613.16 81.20603 -84.157814 Oct 6 30125.02 78.96669 -127.017728 Nov 6 29037.10 77.95343 219.904710 Dec 6 28349.50 78.39572 -194.496496 Jan 7 30966.74 66.28958 -500.743775 Feb 7 35566.55 89.43968 137.450103 Mar 7 38851.19 98.10211 475.806809 Apr 7 39372.60 98.46231 -21.602199 May 7 42206.54 100.18000 27.462698 Jun 7 43182.27 100.79877 447.732759 Jul 7 43960.76 101.29928 -238.755482 Aug 7 42754.36 100.33079 366.639939 Sep 7 38182.45 96.79806 -197.454756 Oct 7 37176.85 95.88976 -41.850055 Nov 7 34452.81 93.78714 193.189125 Dec 7 33337.23 94.65884 -311.229217 Jan 8 35768.83 85.91131 -681.827980 Feb 8 38738.89 98.09190 107.108166 Mar 8 41419.58 104.91275 593.420655 Apr 8 43956.08 107.09308 -48.078909 May 8 42984.94 106.45927 -116.940703 Jun 8 43981.48 107.03804 441.522742 Jul 8 44372.56 107.23408 -205.556693 Aug 8 43126.53 106.28908 509.467335 Sep 8 44455.38 107.17211 -73.377090 Oct 8 42173.11 105.29119 -31.112240 Nov 8 43075.64 105.79658 376.356245 Dec 8 37649.31 110.24294 -737.310900 Jan 9 42907.16 94.89935 -494.164949 Feb 9 45281.76 102.99775 62.240192 Mar 9 44516.62 100.77850 356.384985 Apr 9 47338.73 103.35393 171.270775 May 9 49625.36 104.59143 -71.356694 Jun 9 47143.97 103.02369 225.034892 Jul 9 46178.30 102.32703 -180.297062 Aug 9 47620.40 103.22176 519.595758 Sep 9 48373.43 103.67652 67.574116 Oct 9 45232.57 101.22889 -304.570867 Nov 9 40011.46 98.39413 442.539711 Dec 9 39602.69 98.82193 -941.691085 Jan 10 37977.85 102.95415 -731.853951 Feb 10 36747.90 98.91300 95.096903 Mar 10 36233.84 97.40401 190.158132 Apr 10 37489.35 98.55498 104.647895 May 10 38058.14 98.81796 85.856730 Jun 10 38439.67 98.97961 297.325227 Jul 10 35055.12 96.81832 -495.119919 Aug 10 35590.01 97.10088 489.994348 Sep 10 33438.39 95.56320 69.606746 Oct 10 35351.44 96.87619 110.559884 Nov 10 33080.00 95.82956 294.001493 Dec 10 32953.19 96.01937 -843.188169 Jan 11 35928.75 90.42831 -395.752608 Feb 11 35435.74 88.89894 96.263299 Mar 11 37658.67 93.93896 244.328056 Apr 11 36790.52 92.94241 -27.519793 May 11 40156.19 94.77840 242.814261 Jun 11 43508.97 96.55424 655.026629 Jul 11 44989.39 97.37643 -493.386420 Aug 11 42675.13 95.86363 434.871049 Sep 11 43845.56 96.58464 34.444605 Oct 11 43689.80 96.41049 240.197942 Nov 11 43986.74 96.48307 340.260647 > m$resid Jan Feb Mar Apr May Jun 1 0.00000000 0.51836230 1.49314801 0.25139532 1.00551777 0.36690679 2 0.71869069 0.27768234 0.92795418 0.00932279 0.46776320 -0.53806304 3 0.45169057 0.97164151 0.52991538 0.01705093 0.42392180 -0.63390061 4 0.99319749 0.99693422 0.43775732 -0.55564236 0.30042879 0.11354542 5 1.40610890 1.31841347 1.35896161 0.11268466 -0.15362939 1.57072477 6 -0.02641147 1.36078342 1.68801480 1.42467365 0.21952701 1.35412856 7 1.29268001 2.20042295 1.58811285 0.21094507 1.36297836 0.43624118 8 1.18369036 1.40725564 1.28310811 1.21171072 -0.53723523 0.44347076 9 2.59742206 1.11666393 -0.43118502 1.35606618 1.08782718 -1.28841970 10 -0.86726446 -0.65482296 -0.30438225 0.57707263 0.23429820 0.14085580 11 1.44571718 -0.28728178 1.05953910 -0.47937544 1.63066365 1.62322339 Jul Aug Sep Oct Nov Dec 1 -0.59909701 0.07256276 -0.46318164 -1.24127417 -0.74712169 -1.06634067 2 -0.51594899 -0.71218675 -1.46102589 -1.32296617 -0.88179180 -0.57432412 3 -0.75781427 0.05178902 -0.74688870 -1.33811259 -0.56917153 -0.01467183 4 -0.41982489 -0.11247522 -0.90973840 -1.08107774 -0.32650367 -0.19391798 5 -0.42945291 0.11756697 -1.77858826 -0.97386641 -0.65228014 -0.85521970 6 -0.06536855 0.12168378 -0.93968565 -1.28031142 -0.58150674 -0.38136912 7 0.33765665 -0.65155500 -2.32796502 -0.54932642 -1.40517462 -0.60256132 8 0.14151945 -0.67424219 0.60913727 -1.19065244 0.39723515 -2.75681604 9 -0.53245079 0.66751694 0.32376089 -1.61674087 -2.65172658 -0.25277136 10 -1.73556802 0.21825556 -1.12041491 0.90564183 -1.17987808 -0.11097742 11 0.68946051 -1.20152563 0.53539913 -0.12573732 0.09989524 > 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/1v0fi1292704943.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/rcomp/tmp/2v0fi1292704943.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/rcomp/tmp/3osel1292704943.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/rcomp/tmp/4z1do1292704943.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/rcomp/tmp/5z1do1292704943.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/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/6dtbe1292704943.tab") > > try(system("convert tmp/1v0fi1292704943.ps tmp/1v0fi1292704943.png",intern=TRUE)) character(0) > try(system("convert tmp/2v0fi1292704943.ps tmp/2v0fi1292704943.png",intern=TRUE)) character(0) > try(system("convert tmp/3osel1292704943.ps tmp/3osel1292704943.png",intern=TRUE)) character(0) > try(system("convert tmp/4z1do1292704943.ps tmp/4z1do1292704943.png",intern=TRUE)) character(0) > try(system("convert tmp/5z1do1292704943.ps tmp/5z1do1292704943.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.333 0.953 7.796