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(6.02,5.62,4.87,4.24,4.02,3.74,3.45,3.34,3.21,3.12,3.04,2.97,2.93,2.95,2.92,2.9,2.95,2.91,2.89,2.84,2.82,2.78,2.86,2.87,2.94,3.04,3.12,3.19,3.27,3.34,3.4,3.55,3.64,3.76,3.78,3.77,3.81,3.81,3.82,3.96,3.86,3.84,3.68,3.56,3.48,3.4,3.42,3.2,3.11,3.1,2.99,3.1,3,3.05,3.1,3.2,3.1,3.3,3.13,3.14) > 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.000000e+00 1.396548e-02 4.477711e-05 6.046188e-04 > m$fitted level slope sea Jan 1 6.020000 0.000000000 0.000000e+00 Feb 1 5.639022 -0.379507828 -2.623979e-03 Mar 1 4.886652 -0.721980536 -3.162300e-03 Apr 1 4.236281 -0.656005658 1.198649e-03 May 1 4.001684 -0.267677244 3.492106e-03 Jun 1 3.741301 -0.260955194 -1.557567e-03 Jul 1 3.451839 -0.287225201 -8.366096e-04 Aug 1 3.332859 -0.132180292 1.222877e-03 Sep 1 3.210526 -0.123104983 -8.726705e-04 Oct 1 3.119126 -0.093887367 -2.415784e-04 Nov 1 3.039951 -0.080329659 -4.683446e-04 Dec 1 2.970098 -0.070674898 -4.663991e-04 Jan 2 2.923048 -0.049016938 6.124894e-03 Feb 2 2.944395 0.011168436 3.520302e-03 Mar 2 2.922505 -0.019084111 -1.387842e-03 Apr 2 2.904031 -0.018528281 -4.051443e-03 May 2 2.943425 0.034319292 4.592008e-03 Jun 2 2.913111 -0.024657347 -8.979256e-04 Jul 2 2.892177 -0.021260345 -2.304096e-03 Aug 2 2.839870 -0.049588428 1.193403e-03 Sep 2 2.819103 -0.023290034 -9.020480e-05 Oct 2 2.780870 -0.036925375 -3.578581e-04 Nov 2 2.854068 0.063558937 2.161199e-03 Dec 2 2.872830 0.022692047 -1.296785e-03 Jan 3 2.937630 0.061008181 9.302882e-04 Feb 3 3.033996 0.091619835 4.928298e-03 Mar 3 3.121000 0.087429961 -8.459438e-04 Apr 3 3.196954 0.077050963 -6.571101e-03 May 3 3.264156 0.068133486 6.174222e-03 Jun 3 3.340792 0.075833063 -1.077368e-03 Jul 3 3.402050 0.062634854 -1.560990e-03 Aug 3 3.544930 0.135297817 2.377605e-03 Sep 3 3.640912 0.099696714 4.068483e-04 Oct 3 3.762313 0.119350304 -3.040997e-03 Nov 3 3.781940 0.029045300 1.405676e-03 Dec 3 3.773586 -0.004806546 -2.331500e-03 Jan 4 3.808680 0.031291961 -2.089375e-05 Feb 4 3.807095 0.002611127 3.921332e-03 Mar 4 3.820127 0.012010661 -4.708631e-04 Apr 4 3.958861 0.126011918 -3.032123e-03 May 4 3.868668 -0.068654644 -1.519806e-03 Jun 4 3.836266 -0.036004537 2.534804e-03 Jul 4 3.691808 -0.133675621 -8.221456e-03 Aug 4 3.555800 -0.135775974 4.276986e-03 Sep 4 3.478707 -0.082928716 -6.477592e-04 Oct 4 3.400580 -0.078604583 -7.386819e-04 Nov 4 3.411697 0.002198968 5.335383e-03 Dec 4 3.216999 -0.175010066 -1.049260e-02 Jan 5 3.101243 -0.121641569 6.791799e-03 Feb 5 3.088209 -0.026430067 8.398551e-03 Mar 5 3.003391 -0.078854584 -1.147864e-02 Apr 5 3.083295 0.063443029 1.152803e-02 May 5 3.014118 -0.055494903 -9.776744e-03 Jun 5 3.037379 0.015160586 1.004182e-02 Jul 5 3.103745 0.061098628 -5.422500e-03 Aug 5 3.195586 0.088677131 3.406828e-03 Sep 5 3.110706 -0.067019674 -5.022063e-03 Oct 5 3.291282 0.155105811 6.092834e-04 Nov 5 3.135808 -0.123516145 4.363235e-03 Dec 5 3.141886 -0.007344296 -6.126466e-03 > m$resid Jan Feb Mar Apr May Jun 1 0.000000000 -3.293756501 -2.949725962 0.558382614 3.286070282 0.056881927 2 0.188642445 0.504191456 -0.253212731 0.004696592 0.447199628 -0.499057421 3 0.330643733 0.257195090 -0.035238814 -0.087675723 -0.075460509 0.065153232 4 0.309527489 -0.241439876 0.079300523 0.962836036 -1.647281681 0.276281706 5 0.455625078 0.802578220 -0.443130835 1.201743749 -1.006445014 0.597878062 Jul Aug Sep Oct Nov Dec 1 -0.222296274 1.311986919 0.076795083 0.247238883 0.114725052 0.081698393 2 0.028745362 -0.239711667 0.222536481 -0.115381982 0.850297475 -0.345823155 3 -0.111682978 0.614872515 -0.301255824 0.166308317 -0.764163310 -0.286491176 4 -0.826490508 -0.017773141 0.447192453 0.036590773 0.683762571 -1.500004523 5 0.388726345 0.233368725 -1.317503254 1.879628021 -2.357698746 0.983543683 > 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/13ogq1384348275.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/2ualt1384348275.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/3i0yd1384348275.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/48vje1384348275.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/5s4wz1384348275.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/6vyqq1384348275.tab") > > try(system("convert tmp/13ogq1384348275.ps tmp/13ogq1384348275.png",intern=TRUE)) character(0) > try(system("convert tmp/2ualt1384348275.ps tmp/2ualt1384348275.png",intern=TRUE)) character(0) > try(system("convert tmp/3i0yd1384348275.ps tmp/3i0yd1384348275.png",intern=TRUE)) character(0) > try(system("convert tmp/48vje1384348275.ps tmp/48vje1384348275.png",intern=TRUE)) character(0) > try(system("convert tmp/5s4wz1384348275.ps tmp/5s4wz1384348275.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.186 0.524 3.693