R version 2.15.1 (2012-06-22) -- "Roasted Marshmallows" Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 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(426.113 + ,383.703 + ,232.444 + ,70.939 + ,226.731 + ,947.293 + ,611.281 + ,158.047 + ,33.999 + ,37.028 + ,388.3 + ,506.652 + ,392.25 + ,180.818 + ,198.296 + ,217.465 + ,275.562 + ,1030.944 + ,57.47 + ,136.452 + ,556.277 + ,213.361 + ,274.482 + ,220.553 + ,236.71 + ,260.642 + ,2763.544 + ,213.923 + ,169.861 + ,403.064 + ,449.594 + ,406.167 + ,206.893 + ,156.187 + ,257.102 + ,62.156 + ,662.883 + ,251.422 + ,171.328 + ,350.089 + ,221.588 + ,4.813 + ,183.186 + ,190.379 + ,223.166 + ,232.669 + ,356.725 + ,109.215 + ,475.834 + ,315.955 + ,694.87 + ,8.95 + ,278.741 + ,308.16 + ,207.533 + ,192.797 + ,601.162 + ,289.714 + ,293.671 + ,386.688 + ,699.645 + ,85.094 + ,131.812 + ,645.285 + ,197.549 + ,308.174 + ,86.58 + ,242.205 + ,238.502 + ,187.881 + ,140.321 + ,440.31 + ,421.403 + ,218.761 + ,1305.923 + ,137.55 + ,262.517 + ,348.821 + ,150.034 + ,64.016 + ,261.596 + ,259.7 + ,171.26 + ,203.077 + ,249.148 + ,211.655 + ,252.64 + ,438.555 + ,239.89 + ,401.915 + ,216.886 + ,184.641 + ,380.155 + ,653.641 + ,313.906 + ,366.936 + ,236.302 + ,229.641 + ,235.577 + ,103.898 + ,263.906 + ,241.171 + ,216.548 + ,295.281 + ,193.299 + ,204.386 + ,257.567 + ,136.813 + ,240.755 + ,59.609 + ,213.511 + ,380.531 + ,242.344 + ,250.407 + ,183.613 + ,191.835 + ,266.793 + ,246.542 + ,330.563 + ,403.556 + ,208.108 + ,324.04 + ,308.532 + ,199.297 + ,200.156 + ,262.875 + ,287.069 + ,190.157 + ,199.746 + ,265.777 + ,435.956 + ,72.844 + ,756.46 + ,206.771 + ,4202.361 + ,401.422 + ,216.046 + ,39.047 + ,441.437) > 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') Warning message: In StructTS(x, type = "BSM") : possible convergence problem: optim gave code=52 ERROR: ABNORMAL_TERMINATION_IN_LNSRCH > m$coef level slope seas epsilon 0.000000e+00 1.911015e+00 1.858439e+04 1.256941e+05 > m$fitted level slope sea Jan 1 426.1130 0.000000e+00 0.0000000 Feb 1 422.4306 -1.227789e+00 -8.2394476 Mar 1 388.8886 -9.309394e+00 -39.9163482 Apr 1 318.1280 -2.160776e+01 -63.1929734 May 1 281.2878 -2.414925e+01 -10.9967066 Jun 1 399.5041 -3.777195e+00 135.6904222 Jul 1 450.5744 3.095937e+00 -4.7591925 Aug 1 402.1182 -2.652895e+00 -79.6091928 Sep 1 329.9697 -9.638126e+00 -59.9896285 Oct 1 267.5830 -1.446739e+01 -39.5060646 Nov 1 272.8402 -1.280796e+01 39.2833369 Dec 1 301.9106 -9.545727e+00 32.5642483 Jan 2 294.0702 -9.415658e+00 78.9894787 Feb 2 269.4068 -1.045800e+01 -21.4720748 Mar 2 249.5437 -1.105973e+01 -14.3981175 Apr 2 241.6826 -1.086637e+01 -37.2984856 May 2 245.7192 -1.001022e+01 -35.4167196 Jun 2 322.5464 -5.247557e+00 301.6249323 Jul 2 296.3992 -6.346443e+00 -134.7592426 Aug 2 275.5710 -7.079263e+00 -62.7323804 Sep 2 300.4321 -5.517949e+00 78.4156494 Oct 2 295.4625 -5.491961e+00 -85.2969281 Nov 2 286.6747 -5.643988e+00 7.9213304 Dec 2 271.9333 -6.056143e+00 7.7128740 Jan 3 257.2855 -6.466366e+00 50.8042656 Feb 3 251.6205 -6.430851e+00 3.4544366 Mar 3 467.5984 3.017401e+00 828.5351724 Apr 3 487.1505 3.703623e+00 -383.2701398 May 3 477.9800 3.177075e+00 -220.1929272 Jun 3 446.4786 1.772818e+00 200.4004406 Jul 3 452.9028 1.959865e+00 -36.9391811 Aug 3 458.4178 2.102176e+00 -78.6286419 Sep 3 435.0144 1.083771e+00 -34.3570112 Oct 3 416.7990 3.133195e-01 -110.7428567 Nov 3 400.5154 -3.520344e-01 -11.6173398 Dec 3 373.2205 -1.451543e+00 -90.5279554 Jan 4 391.2505 -6.068010e-01 101.9019072 Feb 4 405.1651 -4.427849e-04 -275.5419182 Mar 4 334.0531 -2.891308e+00 422.7210051 Apr 4 346.7022 -2.265799e+00 -124.5460014 May 4 349.1662 -2.075594e+00 -166.7817096 Jun 4 310.5568 -3.549524e+00 -0.3747745 Jul 4 295.0161 -4.035757e+00 -10.7895586 Aug 4 283.7024 -4.332638e+00 -31.5567910 Sep 4 273.7337 -4.564059e+00 -2.4429584 Oct 4 270.7026 -4.500628e+00 -51.1913994 Nov 4 270.6955 -4.312688e+00 47.2833880 Dec 4 264.4160 -4.396488e+00 -138.1639531 Jan 5 266.4844 -4.112500e+00 152.9928902 Feb 5 277.7463 -3.446342e+00 -95.0063645 Mar 5 277.9619 -3.289842e+00 385.3083385 Apr 5 265.3166 -3.687301e+00 -175.6847721 May 5 268.1765 -3.409341e+00 -45.9272500 Jun 5 266.9639 -3.315900e+00 22.2324141 Jul 5 260.1161 -3.466584e+00 -22.0904127 Aug 5 253.5392 -3.599742e+00 -33.8976560 Sep 5 273.3688 -2.592950e+00 125.7492348 Oct 5 279.5578 -2.213959e+00 -65.4633365 Nov 5 277.2598 -2.217605e+00 17.1328030 Dec 5 293.4002 -1.414324e+00 -63.7709913 Jan 6 313.7556 -4.524530e-01 200.3861212 Feb 6 308.2439 -6.749185e-01 -180.0222379 Mar 6 269.0574 -2.357914e+00 191.3763106 Apr 6 299.0534 -9.490572e-01 69.9025717 May 6 298.8650 -9.159762e-01 -107.8150723 Jun 6 297.5734 -9.323120e-01 13.8090383 Jul 6 284.8390 -1.445759e+00 -97.5561364 Aug 6 284.3081 -1.405926e+00 -49.8995069 Sep 6 272.7424 -1.848730e+00 52.2009433 Oct 6 268.9594 -1.933141e+00 -64.6554349 Nov 6 259.3554 -2.268428e+00 -54.0953740 Dec 6 274.3907 -1.510486e+00 19.9619732 Jan 7 270.2750 -1.624812e+00 173.0419146 Feb 7 274.1460 -1.384027e+00 -101.6740388 Mar 7 333.9637 1.291590e+00 455.5201138 Apr 7 326.2301 8.976084e-01 -112.4117846 May 7 329.4940 1.000826e+00 -86.9893647 Jun 7 330.1385 9.852870e-01 21.6968125 Jul 7 325.4734 7.389262e-01 -127.6590350 Aug 7 310.0981 3.632248e-02 -109.9056326 Sep 7 300.8336 -3.692354e-01 39.2855246 Oct 7 300.3686 -3.734095e-01 -39.8616035 Nov 7 296.9262 -5.072596e-01 -99.8338972 Dec 7 288.9138 -8.345955e-01 -22.7833410 Jan 8 275.0398 -1.403250e+00 83.5512330 Feb 8 280.5037 -1.103881e+00 -126.5414708 Mar 8 246.3702 -2.543281e+00 284.0932969 Apr 8 259.6634 -1.853288e+00 45.5515187 May 8 263.4957 -1.605594e+00 -71.5091073 Jun 8 269.3138 -1.282199e+00 70.0346776 Jul 8 272.1820 -1.101405e+00 -90.2757804 Aug 8 272.2462 -1.050634e+00 -97.4265540 Sep 8 275.8656 -8.472356e-01 64.9564512 Oct 8 303.2462 3.819851e-01 112.8069642 Nov 8 314.0282 8.347507e-01 -87.5858270 Dec 8 320.5761 1.083385e+00 -1.6523877 Jan 9 311.5359 6.429451e-01 9.8287619 Feb 9 311.2454 6.023310e-01 -73.7572310 Mar 9 289.4961 -3.703492e-01 134.0607543 Apr 9 271.3625 -1.143531e+00 -18.0139603 May 9 272.7829 -1.031911e+00 -30.4554167 Jun 9 265.6377 -1.298076e+00 26.9929898 Jul 9 266.8921 -1.186938e+00 -71.8316875 Aug 9 275.9711 -7.399787e-01 -67.1029616 Sep 9 270.0077 -9.673734e-01 -32.7496811 Oct 9 257.4120 -1.473515e+00 44.8069259 Nov 9 260.1955 -1.288266e+00 -38.4324645 Dec 9 249.5235 -1.696490e+00 -33.8054973 Jan 10 244.1564 -1.856142e+00 27.4650243 Feb 10 231.2231 -2.337989e+00 -78.4500802 Mar 10 215.1470 -2.935726e+00 113.9126730 Apr 10 222.6236 -2.482588e+00 70.3290474 May 10 224.2552 -2.303511e+00 -16.5175632 Jun 10 223.0310 -2.256527e+00 18.2966856 Jul 10 223.9949 -2.116333e+00 -67.4733804 Aug 10 223.8378 -2.031048e+00 -48.4837126 Sep 10 226.0524 -1.846241e+00 5.0280059 Oct 10 223.3315 -1.884309e+00 30.5668025 Nov 10 230.0547 -1.509743e+00 28.1227417 Dec 10 243.0780 -8.774211e-01 38.2644562 Jan 11 238.9261 -1.019877e+00 -3.2798253 Feb 11 247.9166 -5.843488e-01 -8.0663166 Mar 11 246.6872 -6.124166e-01 67.2691723 Apr 11 238.9509 -9.224442e-01 20.2482163 May 11 236.0407 -1.008957e+00 -19.1714481 Jun 11 235.9063 -9.708937e-01 19.6156585 Jul 11 243.5855 -5.943848e-01 -29.2508367 Aug 11 244.6393 -5.226474e-01 -68.3408769 Sep 11 241.6166 -6.314589e-01 -20.8493576 Oct 11 241.7579 -5.978254e-01 17.5212626 Nov 11 254.0848 -3.537363e-02 73.2035110 Dec 11 241.0529 -6.009094e-01 -58.9348141 Jan 12 274.8267 8.948352e-01 192.5931129 Feb 12 276.1751 9.145731e-01 -73.2181840 Mar 12 537.3929 1.224206e+01 1476.4357325 Apr 12 576.1052 1.339400e+01 -397.2101510 May 12 574.9967 1.276285e+01 -237.0393840 Jun 12 551.4743 1.118368e+01 -207.4089036 Jul 12 553.2452 1.077403e+01 -32.6814972 > m$resid Jan Feb Mar Apr May 1 0.000000000 -0.101424275 -0.421942378 -0.680735968 -0.161656009 2 0.064951911 -0.246743578 -0.138455244 0.049080358 0.243521241 3 -0.257772815 0.020498626 5.444634979 0.408659404 -0.326178383 4 0.625012020 0.450403129 -2.171063782 0.474757658 0.145469408 5 0.209240832 0.494942752 0.117508951 -0.300127483 0.210157122 6 0.691743691 -0.160819931 -1.225621580 1.030678914 0.024241264 7 -0.081890117 0.172959084 1.929650809 -0.284973739 0.074774895 8 -0.409355364 0.215775366 -1.039058991 0.498695375 0.179160228 9 -0.318309586 -0.029363471 -0.703407442 -0.559248622 0.080749102 10 -0.115538482 -0.348724150 -0.432518487 0.327832405 0.129545875 11 -0.103103585 0.315205219 -0.020309134 -0.224283152 -0.062578943 12 1.082344764 0.014282240 8.195294854 0.833305806 -0.456535777 Jun Jul Aug Sep Oct 1 1.523385248 0.607449518 -0.598953293 -0.852492571 -0.684870124 2 1.509625505 -0.384733799 -0.280937364 0.650162904 0.011670878 3 -0.903133976 0.124389018 0.097431190 -0.714818708 -0.552238803 4 -1.132733797 -0.374660727 -0.228952105 -0.178329420 0.048743208 5 0.070547041 -0.113433895 -0.099861903 0.751617579 0.281327718 6 -0.011967525 -0.375636353 0.029083038 -0.322476427 -0.061274795 7 -0.011262627 -0.178529196 -0.508830534 -0.293420276 -0.003015939 8 0.234000524 0.130825628 0.036732712 0.147111828 0.888668803 9 -0.192569206 0.080409682 0.323370923 -0.164503820 -0.366122060 10 0.033988096 0.101416372 0.061696124 0.133690048 -0.027538746 11 0.027532190 0.272341765 0.051891209 -0.078710559 0.024330110 12 -1.142253438 -0.296320184 Nov Dec 1 0.271133208 0.608846589 2 -0.073231481 -0.214088099 3 -0.485022041 -0.810290705 4 0.143501450 -0.063112240 5 -0.002685174 0.584834111 6 -0.242354807 0.545028983 7 -0.096556144 -0.235764014 8 0.327185318 0.179639166 9 0.133998575 -0.295336566 10 0.270989592 0.457554601 11 0.406900725 -0.409183482 12 > 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/1pob31348837109.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/2b36j1348837109.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/3z4s51348837109.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/4rnal1348837109.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/5gs511348837109.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/697na1348837109.tab") > > try(system("convert tmp/1pob31348837109.ps tmp/1pob31348837109.png",intern=TRUE)) character(0) > try(system("convert tmp/2b36j1348837109.ps tmp/2b36j1348837109.png",intern=TRUE)) character(0) > try(system("convert tmp/3z4s51348837109.ps tmp/3z4s51348837109.png",intern=TRUE)) character(0) > try(system("convert tmp/4rnal1348837109.ps tmp/4rnal1348837109.png",intern=TRUE)) character(0) > try(system("convert tmp/5gs511348837109.ps tmp/5gs511348837109.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 4.505 0.479 4.972