R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 The R Foundation for Statistical Computing Platform: i686-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(41,39,50,40,43,38,44,35,39,35,29,49,50,59,63,32,39,47,53,60,57,52,70,90,74,62,55,84,94,70,108,139,120,97,126,149,158,124,140,109,114,77,120,133,110,92,97,78,99,107,112,90,98,125,155,190,236,189,174,178,136,161,171,149,184,155,276,224,213,279,268,287,238,213,257,293,212,246,353,339,308,247,257,322,298,273,312,249,286,279,309,401,309,328,353,354,327,324,285,243,241,287,355,460,364,487,452,391,500,451,375,372,302,316,398,394,431,431) > par1 = '12' > 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 440.2145349 0.1404037 35.5015519 440.4465096 > m$fitted level slope sea Jan 1 41.00000 0.00000000 0.00000000 Feb 1 39.60627 -0.09349563 -0.15049698 Mar 1 45.88651 0.16877357 0.91746224 Apr 1 42.55330 0.08304512 -0.59038702 May 1 42.70773 0.08432740 0.25126016 Jun 1 39.94646 0.03981097 -0.30144689 Jul 1 42.22707 0.07313752 0.47525777 Aug 1 38.05492 0.01090328 -0.59550147 Sep 1 38.48452 0.01703566 0.27293787 Oct 1 36.45277 -0.01308746 -0.26627752 Nov 1 32.03615 -0.07818540 -0.48677238 Dec 1 41.83167 0.06863624 1.45391540 Jan 2 45.50928 -0.17008694 2.29358402 Feb 2 54.45869 0.11006227 0.43488281 Mar 2 59.15463 0.22511430 1.50756243 Apr 2 44.37381 -0.02976933 -4.19834313 May 2 40.47158 -0.08111215 0.67285712 Jun 2 44.28851 -0.03444053 0.54459268 Jul 2 48.95037 0.02028377 1.43685675 Aug 2 55.78892 0.09986960 0.41782423 Sep 2 56.54665 0.10763959 0.08746259 Oct 2 53.92644 0.07491038 -0.40974169 Nov 2 63.59960 0.19107678 1.06510293 Dec 2 78.47794 0.34122479 3.35098747 Jan 3 77.98459 0.35855190 -3.50667359 Feb 3 68.96174 0.16167212 -2.33676349 Mar 3 58.67560 -0.06166831 1.63838136 Apr 3 74.20633 0.19827276 1.49715225 May 3 85.83097 0.35655786 2.00355988 Jun 3 77.85942 0.25030569 -3.35045311 Jul 3 93.96385 0.44824346 5.44691466 Aug 3 119.55451 0.76316240 5.82518982 Sep 3 121.04974 0.77244280 -1.44620935 Oct 3 109.13092 0.60944720 -5.25934001 Nov 3 118.68121 0.72291088 2.47827421 Dec 3 134.26512 0.87372704 6.68177574 Jan 4 148.56999 0.81571597 1.99817567 Feb 4 136.20456 0.58473314 -5.49899269 Mar 4 138.61602 0.62096892 0.45467758 Apr 4 122.77811 0.33798001 -5.14330908 May 4 115.55347 0.22413535 2.46365742 Jun 4 97.73340 -0.02960158 -11.11695534 Jul 4 108.59795 0.12037736 5.59232425 Aug 4 119.45943 0.26840606 7.81269416 Sep 4 114.82723 0.20026382 -2.21441346 Oct 4 106.31558 0.07844951 -9.67153552 Nov 4 101.23636 0.00837420 -1.48717748 Dec 4 85.60595 -0.16737803 0.73541523 Jan 5 88.60535 -0.15402953 8.67994947 Feb 5 101.75664 0.06421103 -1.61153077 Mar 5 106.13852 0.14623314 3.65927323 Apr 5 99.47721 0.02622479 -5.93310607 May 5 95.35124 -0.04051433 4.83381753 Jun 5 118.57370 0.31333985 -5.85499142 Jul 5 137.70855 0.59376739 7.34806707 Aug 5 162.73533 0.95716151 14.35645803 Sep 5 204.68066 1.56961504 9.66759616 Oct 5 203.46539 1.52806870 -12.99449210 Nov 5 187.42402 1.27490859 -4.14627184 Dec 5 182.34330 1.19505044 -0.98547705 Jan 6 155.47515 0.93791243 -4.49003867 Feb 6 158.93234 0.97875017 0.76284051 Mar 6 162.70444 1.03038362 6.86624801 Apr 6 158.31761 0.93360756 -6.50847058 May 6 171.99110 1.14742272 5.34245359 Jun 6 169.00972 1.08105733 -11.84262793 Jul 6 226.58532 1.97186612 19.74138014 Aug 6 225.11795 1.91786202 0.68860978 Sep 6 213.85698 1.71080242 6.06500825 Oct 6 254.61806 2.32042529 3.87487432 Nov 6 265.83555 2.45477805 -2.50607910 Dec 6 277.00075 2.57474121 5.42439474 Jan 7 260.90573 2.34762865 -13.02625587 Feb 7 234.89019 1.88377612 -7.16848166 Mar 7 242.05880 1.97973879 12.22907633 Apr 7 275.22634 2.53956840 1.63184798 May 7 240.66465 1.90044810 -9.31837136 Jun 7 255.02159 2.10808434 -15.53542157 Jul 7 298.04794 2.77866124 33.53988354 Aug 7 322.19173 3.12677540 5.62713860 Sep 7 318.20710 3.01119244 -6.48576626 Oct 7 279.91306 2.34574231 -11.30385713 Nov 7 268.66335 2.13283512 -4.55412073 Dec 7 292.26523 2.44952017 18.50154240 Jan 8 301.33034 2.54234400 -6.81033586 Feb 8 292.32122 2.35076099 -13.32101153 Mar 8 299.51444 2.43766453 9.99447216 Apr 8 268.71736 1.84117041 -2.53006195 May 8 284.89086 2.09168139 -6.34791257 Jun 8 296.47250 2.25353593 -22.42295181 Jul 8 288.78752 2.08647025 25.40040092 Aug 8 345.74660 3.00282228 26.60791716 Sep 8 328.51052 2.66631998 -8.94644832 Oct 8 334.19016 2.71594914 -7.76247736 Nov 8 350.78153 2.93935076 -5.01796674 Dec 8 344.96912 2.80371775 13.59850046 Jan 9 338.67619 2.66534745 -6.91014436 Feb 9 338.52438 2.61800057 -13.06085502 Mar 9 301.41744 1.91065637 4.05612548 Apr 9 271.71635 1.34474083 -12.37231862 May 9 258.44771 1.08744495 -9.85516488 Jun 9 285.68236 1.53961002 -12.29958615 Jul 9 316.61305 2.04178603 23.07060611 Aug 9 380.32745 3.08848297 47.53283449 Sep 9 381.47290 3.05568049 -16.46052639 Oct 9 446.47531 4.09205388 8.26238489 Nov 9 456.12901 4.18348955 -7.02422963 Dec 9 415.10727 3.45796454 -0.55528880 Jan 10 463.24703 4.17143157 13.40657640 Feb 10 461.84694 4.07678243 -7.95288211 Mar 10 410.05316 3.08722704 -6.21821389 Apr 10 393.92995 2.74451786 -11.99727371 May 10 352.88817 1.97127376 -28.15944740 Jun 10 342.74356 1.76008317 -20.44097203 Jul 10 366.95322 2.14757852 19.36170316 Aug 10 358.83310 1.97147529 40.51110460 Sep 10 414.32931 2.88445877 -11.18036862 Oct 10 422.55444 2.97482217 5.66793734 > m$resid Jan Feb Mar Apr May Jun 1 0.00000000 -0.04549293 0.27660355 -0.16303642 0.00337249 -0.13491108 2 0.21282241 0.37055917 0.20516544 -0.70129489 -0.18276958 0.18436427 3 -0.04344948 -0.41102367 -0.47256791 0.72752907 0.53775220 -0.39265541 4 0.66672839 -0.59581484 0.08317350 -0.76642829 -0.35494340 -0.84838778 5 0.15341944 0.61039514 0.19759599 -0.31655927 -0.19445168 1.09133942 6 -1.34091171 0.11643847 0.12835727 -0.25171854 0.59565606 -0.19337388 7 -0.88472711 -1.31602562 0.24362142 1.44879289 -1.73270144 0.58270393 8 0.31189485 -0.53710105 0.22378327 -1.54393193 0.66882908 0.44355462 9 -0.42745720 -0.13113876 -1.83929850 -1.46883101 -0.68159355 1.22137108 10 2.09508101 -0.25952273 -2.59062548 -0.89285952 -2.04158244 -0.56570786 Jul Aug Sep Oct Nov Dec 1 0.10633093 -0.20146841 0.01986708 -0.09718907 -0.20883428 0.46812044 2 0.22219916 0.32256713 0.03111595 -0.12899562 0.45377864 0.69387901 3 0.74768056 1.18557901 0.03451369 -0.59823940 0.42132271 0.70005159 4 0.51233499 0.50509155 -0.23041652 -0.40955324 -0.24235151 -0.73506723 5 0.88319610 1.14644936 1.92306182 -0.13063349 -0.82364901 -0.29821723 6 2.64660636 -0.16111147 -0.61729965 1.82859299 0.41635207 0.40815046 7 1.91459191 0.99963164 -0.33267907 -1.93156171 -0.63539581 1.00491203 8 -0.46462848 2.56506506 -0.94587762 0.14076545 0.64788329 -0.40930610 9 1.37319892 2.88101376 -0.09074092 2.89151451 0.25952299 -2.11280922 10 1.04841944 -0.47941335 2.49820505 0.24914253 > 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/1i8jc1384510164.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/2ilir1384510164.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/3yvhe1384510164.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/4v9391384510164.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/5grwz1384510164.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/6x5sh1384510164.tab") > > try(system("convert tmp/1i8jc1384510164.ps tmp/1i8jc1384510164.png",intern=TRUE)) character(0) > try(system("convert tmp/2ilir1384510164.ps tmp/2ilir1384510164.png",intern=TRUE)) character(0) > try(system("convert tmp/3yvhe1384510164.ps tmp/3yvhe1384510164.png",intern=TRUE)) character(0) > try(system("convert tmp/4v9391384510164.ps tmp/4v9391384510164.png",intern=TRUE)) character(0) > try(system("convert tmp/5grwz1384510164.ps tmp/5grwz1384510164.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 5.508 0.728 6.211