R version 2.15.2 (2012-10-26) -- "Trick or Treat" 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(1.4761,1.4721,1.487,1.5167,1.5812,1.554,1.5508,1.5764,1.5611,1.4735,1.4303,1.2757,1.2727,1.3917,1.2816,1.2644,1.3308,1.3275,1.4098,1.4134,1.4138,1.4272,1.4643,1.48,1.5023,1.4406,1.3966,1.357,1.3479,1.3315,1.2307,1.2271,1.3028,1.268,1.3648,1.3857,1.2998,1.3362,1.3692,1.3834,1.4207,1.486,1.4385,1.4453,1.426,1.445,1.3503,1.4001,1.3418,1.2939,1.3176,1.3443,1.3356,1.3214,1.2403,1.259,1.2284,1.2611,1.293,1.2993,1.2986) > 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 0.0023170768 0.0000000000 0.0000000000 0.0001801306 > m$fitted level slope sea Jan 1 1.476100 0.000000e+00 0.000000e+00 Feb 1 1.472405 -2.067394e-04 -2.067394e-04 Mar 1 1.486093 -9.312099e-05 -9.312099e-05 Apr 1 1.514581 4.892707e-05 4.892707e-05 May 1 1.576384 3.412786e-04 3.412786e-04 Jun 1 1.555311 2.406836e-04 2.406836e-04 Jul 1 1.550917 2.190172e-04 2.190172e-04 Aug 1 1.574388 3.272052e-04 3.272052e-04 Sep 1 1.561771 2.672561e-04 2.672561e-04 Oct 1 1.479587 -1.128359e-04 -1.128359e-04 Nov 1 1.433923 -3.218635e-04 -3.218635e-04 Dec 1 1.287292 -9.901756e-04 -9.901756e-04 Jan 2 1.270841 -2.712268e-04 2.983495e-03 Feb 2 1.383278 2.576971e-03 2.576971e-03 Mar 2 1.286569 2.205536e-03 2.205536e-03 Apr 2 1.264043 2.148891e-03 2.148891e-03 May 2 1.324312 2.276073e-03 2.276073e-03 Jun 2 1.325319 2.273310e-03 2.273310e-03 Jul 2 1.401974 2.434853e-03 2.434853e-03 Aug 2 1.410510 2.448073e-03 2.448073e-03 Sep 2 1.411463 2.444842e-03 2.444842e-03 Oct 2 1.424002 2.466620e-03 2.466620e-03 Nov 2 1.459377 2.537475e-03 2.537475e-03 Dec 2 1.476383 2.568559e-03 2.568559e-03 Jan 3 1.518244 1.708785e-03 -1.879664e-02 Feb 3 1.444581 4.759278e-04 4.759277e-04 Mar 3 1.399528 3.653911e-04 3.653911e-04 Apr 3 1.359614 3.054439e-04 3.054439e-04 May 3 1.348443 2.891124e-04 2.891124e-04 Jun 3 1.332417 2.659976e-04 2.659976e-04 Jul 3 1.237470 1.313222e-04 1.313222e-04 Aug 3 1.227700 1.173380e-04 1.173380e-04 Sep 3 1.297532 2.156664e-04 2.156664e-04 Oct 3 1.269846 1.763683e-04 1.763683e-04 Nov 3 1.358115 3.002695e-04 3.002695e-04 Dec 3 1.383543 3.355621e-04 3.355621e-04 Jan 4 1.318520 1.270638e-03 -1.397701e-02 Feb 4 1.333877 1.440974e-03 1.440974e-03 Mar 4 1.365519 1.495246e-03 1.495246e-03 Apr 4 1.380884 1.510534e-03 1.510534e-03 May 4 1.416669 1.546671e-03 1.546671e-03 Jun 4 1.479916 1.611461e-03 1.611461e-03 Jul 4 1.439946 1.567852e-03 1.567852e-03 Aug 4 1.443580 1.570017e-03 1.570017e-03 Sep 4 1.425849 1.549817e-03 1.549817e-03 Oct 4 1.442351 1.565449e-03 1.565449e-03 Nov 4 1.355253 1.472853e-03 1.472853e-03 Dec 4 1.395757 1.513573e-03 1.513573e-03 Jan 5 1.364633 1.860445e-03 -2.046490e-02 Feb 5 1.297186 1.195711e-03 1.195711e-03 Mar 5 1.315165 1.219652e-03 1.219652e-03 Apr 5 1.341256 1.241420e-03 1.241420e-03 May 5 1.334915 1.235070e-03 1.235070e-03 Jun 5 1.321257 1.222647e-03 1.222647e-03 Jul 5 1.244774 1.157895e-03 1.157895e-03 Aug 5 1.257029 1.167134e-03 1.167134e-03 Sep 5 1.229348 1.143135e-03 1.143135e-03 Oct 5 1.257944 1.165955e-03 1.165955e-03 Nov 5 1.289599 1.191276e-03 1.191276e-03 Dec 5 1.297609 1.196935e-03 1.196935e-03 Jan 6 1.309926 1.102929e-03 -1.213222e-02 > m$resid Jan Feb Mar Apr May Jun 1 0.00000000 -0.04660251 0.28870265 0.59493217 1.28549672 -0.44576128 2 -0.39102958 1.98474181 -2.06278976 -0.51424977 1.20852714 -0.02639062 3 0.90400170 -1.41623757 -0.94588993 -0.83728983 -0.23856265 -0.33914641 4 -1.45481157 0.27227260 0.62743391 0.28827096 0.71235092 1.28237297 5 -0.71433694 -1.36096384 0.34868942 0.51686526 -0.15758546 -0.30950030 6 0.24089560 Jul Aug Sep Oct Nov Dec 1 -0.09647917 0.48400857 -0.26944457 -1.71623815 -0.94816989 -3.04541327 2 1.54668650 0.12685462 -0.03107390 0.20988128 0.68429521 0.30083982 3 -1.97919273 -0.20580515 1.44914297 -0.57998398 1.83117687 0.52233476 4 -0.86422804 0.04294615 -0.40114913 0.31075589 -1.84274384 0.81121129 5 -1.61485745 0.23060314 -0.59951272 0.57052881 0.63361132 0.14170528 6 > 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/18nva1356087629.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/2e3bd1356087629.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/30fcg1356087629.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/4u2ou1356087629.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/5jq971356087629.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/6ivsc1356087629.tab") > > try(system("convert tmp/18nva1356087629.ps tmp/18nva1356087629.png",intern=TRUE)) character(0) > try(system("convert tmp/2e3bd1356087629.ps tmp/2e3bd1356087629.png",intern=TRUE)) character(0) > try(system("convert tmp/30fcg1356087629.ps tmp/30fcg1356087629.png",intern=TRUE)) character(0) > try(system("convert tmp/4u2ou1356087629.ps tmp/4u2ou1356087629.png",intern=TRUE)) character(0) > try(system("convert tmp/5jq971356087629.ps tmp/5jq971356087629.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.336 0.656 3.973