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(7.4271,7.7662,7.6289,7.5281,7.3831,7.2355,7.0617,7.1237,7.4533,7.5411,7.4978,7.3525,7.3862,7.311,7.2013,7.249,7.3321,7.59,7.9082,8.2123,8.0929,8.118,8.1206,8.2883,8.4281,8.7917,8.9168,8.9446,8.9786,9.5862,9.6533,9.4125,9.2195,9.2882,9.6774,9.6857,10.1688,10.4399,10.4675,10.149,9.9163,9.9268,10.0529,10.1622,10.083,10.1134,10.3423,10.7536,11.0967,10.8588,10.7719,10.9262,10.708,10.5062,10.0683,9.8954,9.9589,9.9177,9.7189,9.5273,9.5746,9.763,9.6117,9.6581,9.8361,10.2353,10.1285,10.1347,10.2141,10.0971,9.9651,10.1286,10.3356,10.1238,10.1326,10.2467,10.44,10.3689,10.2415,10.3899,10.3162,10.4533,10.6741,10.8957,10.7404,10.6568,10.5682,10.9833,11.0237,10.8462,10.7287,10.7809,10.2609,9.8252,9.1071,8.695,9.2205,9.0496,8.7406,8.921,9.011,9.3157,9.5786,9.6246,9.7485,9.9431,10.1152,10.1827,9.9777,9.7436,9.3462,9.2623,9.1505,8.5794,8.3245,8.6538,8.752,8.8104,9.2665,9.0895) > 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.05462224 0.00000000 0.00000000 0.00000000 > m$fitted level slope sea Jan 1 7.427100 0.000000e+00 0.000000e+00 Feb 1 7.748567 1.763320e-02 1.763320e-02 Mar 1 7.611884 1.701594e-02 1.701594e-02 Apr 1 7.511552 1.654841e-02 1.654841e-02 May 1 7.367190 1.590988e-02 1.590988e-02 Jun 1 7.220234 1.526614e-02 1.526614e-02 Jul 1 7.047175 1.452470e-02 1.452470e-02 Aug 1 7.108990 1.471016e-02 1.471016e-02 Sep 1 7.437365 1.593541e-02 1.593541e-02 Oct 1 7.524886 1.621395e-02 1.621395e-02 Nov 1 7.481816 1.598417e-02 1.598417e-02 Dec 1 7.337136 1.536385e-02 1.536385e-02 Jan 2 7.490827 9.511548e-03 -1.046270e-01 Feb 2 7.306189 4.811454e-03 4.811459e-03 Mar 2 7.196696 4.603629e-03 4.603629e-03 Apr 2 7.244318 4.681702e-03 4.681702e-03 May 2 7.327276 4.823507e-03 4.823507e-03 Jun 2 7.584720 5.280324e-03 5.280324e-03 Jul 2 7.902356 5.844143e-03 5.844143e-03 Aug 2 8.205919 6.380575e-03 6.380575e-03 Sep 2 8.086745 6.154757e-03 6.154757e-03 Oct 2 8.111811 6.188709e-03 6.188709e-03 Nov 2 8.114418 6.182289e-03 6.182289e-03 Dec 2 8.281829 6.470714e-03 6.470714e-03 Jan 3 8.461791 3.062848e-03 -3.369133e-02 Feb 3 8.783685 8.014822e-03 8.014831e-03 Mar 3 8.908648 8.152408e-03 8.152408e-03 Apr 3 8.936425 8.175469e-03 8.175469e-03 May 3 8.970394 8.205744e-03 8.205744e-03 Jun 3 9.577292 8.907611e-03 8.907611e-03 Jul 3 9.644324 8.975672e-03 8.975672e-03 Aug 3 9.403816 8.683878e-03 8.683878e-03 Sep 3 9.211051 8.448541e-03 8.448541e-03 Oct 3 9.279681 8.518764e-03 8.518764e-03 Nov 3 9.668438 8.961932e-03 8.961932e-03 Dec 3 9.676739 8.961162e-03 8.961162e-03 Jan 4 10.195627 2.438837e-03 -2.682721e-02 Feb 4 10.434755 5.145042e-03 5.145051e-03 Mar 4 10.462335 5.164551e-03 5.164551e-03 Apr 4 10.144116 4.883593e-03 4.883593e-03 May 4 9.911622 4.677536e-03 4.677536e-03 Jun 4 9.922117 4.682581e-03 4.682581e-03 Jul 4 10.048112 4.787704e-03 4.787704e-03 Aug 4 10.157322 4.878113e-03 4.878113e-03 Sep 4 10.078195 4.805444e-03 4.805444e-03 Oct 4 10.108572 4.827546e-03 4.827546e-03 Nov 4 10.337279 5.020879e-03 5.020879e-03 Dec 4 10.748229 5.371120e-03 5.371120e-03 Jan 5 11.117793 1.917563e-03 -2.109321e-02 Feb 5 10.859239 -4.388286e-04 -4.388202e-04 Mar 5 10.772398 -4.984161e-04 -4.984161e-04 Apr 5 10.926592 -3.918056e-04 -3.918056e-04 May 5 10.708542 -5.417081e-04 -5.417081e-04 Jun 5 10.506880 -6.801251e-04 -6.801251e-04 Jul 5 10.069281 -9.806200e-04 -9.806200e-04 Aug 5 9.896499 -1.098697e-03 -1.098697e-03 Sep 5 9.959954 -1.054360e-03 -1.054360e-03 Oct 5 9.918782 -1.081894e-03 -1.081894e-03 Nov 5 9.720117 -1.217411e-03 -1.217411e-03 Dec 5 9.528648 -1.347810e-03 -1.347810e-03 Jan 6 9.557289 -1.573752e-03 1.731126e-02 Feb 6 9.763022 -2.223033e-05 -2.221600e-05 Mar 6 9.611809 -1.086257e-04 -1.086257e-04 Apr 6 9.658182 -8.207971e-05 -8.207971e-05 May 6 9.836080 1.950737e-05 1.950737e-05 Jun 6 10.235053 2.470904e-04 2.470904e-04 Jul 6 10.128314 1.860949e-04 1.860949e-04 Aug 6 10.134510 1.895197e-04 1.895197e-04 Sep 6 10.213865 2.346025e-04 2.346025e-04 Oct 6 10.096932 1.679161e-04 1.679161e-04 Nov 6 9.965007 9.277799e-05 9.277799e-05 Dec 6 10.128414 1.856230e-04 1.856230e-04 Jan 7 10.324195 -1.036844e-03 1.140527e-02 Feb 7 10.126094 -2.294490e-03 -2.294474e-03 Mar 7 10.134889 -2.289080e-03 -2.289080e-03 Apr 7 10.248932 -2.232361e-03 -2.232361e-03 May 7 10.442137 -2.137118e-03 -2.137118e-03 Jun 7 10.371071 -2.170693e-03 -2.170693e-03 Jul 7 10.243732 -2.231632e-03 -2.231632e-03 Aug 7 10.392058 -2.158368e-03 -2.158368e-03 Sep 7 10.318393 -2.193147e-03 -2.193147e-03 Oct 7 10.455425 -2.125463e-03 -2.125463e-03 Nov 7 10.676117 -2.017195e-03 -2.017195e-03 Dec 7 10.897609 -1.908642e-03 -1.908642e-03 Jan 8 10.729186 -1.019488e-03 1.121436e-02 Feb 8 10.658209 -1.408640e-03 -1.408627e-03 Mar 8 10.569646 -1.445727e-03 -1.445727e-03 Apr 8 10.984569 -1.268624e-03 -1.268624e-03 May 8 11.024951 -1.250915e-03 -1.250915e-03 Jun 8 10.847526 -1.325788e-03 -1.325788e-03 Jul 8 10.730075 -1.375118e-03 -1.375118e-03 Aug 8 10.782252 -1.352379e-03 -1.352379e-03 Sep 8 10.262472 -1.572424e-03 -1.572424e-03 Oct 8 9.826957 -1.756533e-03 -1.756533e-03 Nov 8 9.109160 -2.060197e-03 -2.060197e-03 Dec 8 8.697234 -2.233943e-03 -2.233943e-03 Jan 9 9.171496 -4.454900e-03 4.900388e-02 Feb 9 9.054609 -5.009172e-03 -5.009152e-03 Mar 9 8.745724 -5.123843e-03 -5.123843e-03 Apr 9 8.926054 -5.053887e-03 -5.053887e-03 May 9 9.016018 -5.018058e-03 -5.018058e-03 Jun 9 9.320601 -4.901359e-03 -4.901359e-03 Jul 9 9.583400 -4.800493e-03 -4.800493e-03 Aug 9 9.629381 -4.781366e-03 -4.781366e-03 Sep 9 9.753233 -4.732935e-03 -4.732935e-03 Oct 9 9.947758 -4.657941e-03 -4.657941e-03 Nov 9 10.119791 -4.591466e-03 -4.591466e-03 Dec 9 10.187264 -4.564364e-03 -4.564364e-03 Jan 10 9.938596 -3.554911e-03 3.910400e-02 Feb 10 9.747983 -4.382884e-03 -4.382864e-03 Mar 10 9.350716 -4.516066e-03 -4.516066e-03 Apr 10 9.266843 -4.542957e-03 -4.542957e-03 May 10 9.155079 -4.579279e-03 -4.579279e-03 Jun 10 8.584171 -4.771060e-03 -4.771060e-03 Jul 10 8.329356 -4.855706e-03 -4.855706e-03 Aug 10 8.658543 -4.742662e-03 -4.742662e-03 Sep 10 8.756708 -4.707849e-03 -4.707849e-03 Oct 10 8.815087 -4.686515e-03 -4.686515e-03 Nov 10 9.271031 -4.530791e-03 -4.530791e-03 Dec 10 9.094089 -4.589057e-03 -4.589057e-03 > m$resid Jan Feb Mar Apr May 1 0.000000000 0.825877318 -0.661595986 -0.503101790 -0.689855195 2 0.716470157 -0.708145118 -0.489519151 0.184230784 0.335227487 3 0.818601556 1.240033229 0.500681868 0.084017460 0.110431499 4 2.330283208 0.946054342 0.096037071 -1.384273152 -1.016115948 5 1.637542747 -1.057007320 -0.369816768 0.662113049 -0.931622464 6 0.133525104 0.849405033 -0.647092334 0.198941215 0.761748396 7 0.865187932 -0.812833397 0.047458858 0.497876497 0.836427077 8 -0.733096489 -0.289969790 -0.372989184 1.781909224 0.178251048 9 2.090412482 -0.467769222 -1.300450291 0.793657405 0.406633591 10 -1.067947259 -0.780547989 -1.681330447 -0.339605163 -0.458846589 Jun Jul Aug Sep Oct 1 -0.698236648 -0.807375867 0.202737001 1.344705906 0.306892950 2 1.081869125 1.337693137 1.275009183 -0.537698234 0.080988978 3 2.563146288 0.248844075 -1.068099096 -0.862447943 0.257649660 4 0.024901977 0.519287831 0.446986800 -0.359592339 0.109464989 5 -0.860834418 -1.870104343 -0.735344557 0.276305737 -0.171713579 6 1.707499990 -0.457895461 0.025724569 0.338824073 -0.501472933 7 -0.295001954 -0.535692443 0.644355850 -0.306033163 0.595853436 8 -0.753962665 -0.496972946 0.229185000 -2.218684139 -1.857122280 9 1.324951343 1.145634834 0.217320846 0.550489648 0.852732050 10 -2.423580859 -1.070053970 1.429521348 0.440389733 0.269976022 Nov Dec 1 -0.254152275 -0.688763597 2 -0.015341389 0.690473918 3 1.627885179 -0.002830583 4 0.958332613 1.737610627 5 -0.845693111 -0.814317342 6 -0.565350518 0.698977296 7 0.953606991 0.956566119 8 -3.064393066 -1.754079292 9 0.756157894 0.308402182 10 1.971249514 -0.737825117 > 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 > postscript(file="/var/www/html/rcomp/tmp/1kfaa1293370472.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') > grid() > dev.off() null device 1 > mylagmax <- nx/2 > postscript(file="/var/www/html/rcomp/tmp/2d79v1293370472.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/3d79v1293370472.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/45gqg1293370472.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/5yp711293370472.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/61q671293370472.tab") > > try(system("convert tmp/1kfaa1293370472.ps tmp/1kfaa1293370472.png",intern=TRUE)) character(0) > try(system("convert tmp/2d79v1293370472.ps tmp/2d79v1293370472.png",intern=TRUE)) character(0) > try(system("convert tmp/3d79v1293370472.ps tmp/3d79v1293370472.png",intern=TRUE)) character(0) > try(system("convert tmp/45gqg1293370472.ps tmp/45gqg1293370472.png",intern=TRUE)) character(0) > try(system("convert tmp/5yp711293370472.ps tmp/5yp711293370472.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.994 0.882 5.089