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(0.6348,0.634,0.62915,0.62168,0.61328,0.6089,0.60857,0.62672,0.62291,0.62393,0.61838,0.62012,0.61659,0.6116,0.61573,0.61407,0.62823,0.64405,0.6387,0.63633,0.63059,0.62994,0.63709,0.64217,0.65711,0.66977,0.68255,0.68902,0.71322,0.70224,0.70045,0.69919,0.69693,0.69763,0.69278,0.70196,0.69215,0.6769,0.67124,0.66532,0.67157,0.66428,0.66576,0.66942,0.6813,0.69144,0.69862,0.695,0.69867,0.68968,0.69233,0.68293,0.68399,0.66895,0.68756,0.68527,0.6776,0.68137,0.67933,0.67922) > 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 6.464211e-05 0.000000e+00 3.815336e-07 0.000000e+00 > m$fitted level slope sea Jan 1 0.6348000 0.000000e+00 0.000000e+00 Feb 1 0.6340438 -4.140195e-05 -4.377580e-05 Mar 1 0.6292986 -6.710877e-05 -1.486121e-04 Apr 1 0.6218756 -9.548785e-05 -1.955504e-04 May 1 0.6135095 -1.291791e-04 -2.295388e-04 Jun 1 0.6090732 -1.467145e-04 -1.732315e-04 Jul 1 0.6086966 -1.476464e-04 -1.266338e-04 Aug 1 0.6264837 -7.523876e-05 2.363127e-04 Sep 1 0.6231586 -8.830671e-05 -2.485724e-04 Oct 1 0.6239801 -8.466297e-05 -5.007120e-05 Nov 1 0.6185830 -1.058540e-04 -2.030197e-04 Dec 1 0.6201593 -9.917083e-05 -3.925505e-05 Jan 2 0.6170032 2.921644e-05 -4.131622e-04 Feb 2 0.6117237 -9.621593e-05 -1.236731e-04 Mar 2 0.6156381 -8.121269e-05 9.192438e-05 Apr 2 0.6142224 -8.350269e-05 -1.524038e-04 May 2 0.6278488 -5.709949e-05 3.812430e-04 Jun 2 0.6436322 -2.599684e-05 4.178397e-04 Jul 2 0.6393490 -3.433606e-05 -6.489574e-04 Aug 2 0.6360636 -4.068959e-05 2.663596e-04 Sep 2 0.6309733 -5.053687e-05 -3.832640e-04 Oct 2 0.6298398 -5.265126e-05 1.002137e-04 Nov 2 0.6370249 -3.782769e-05 6.505153e-05 Dec 2 0.6420144 -3.098176e-05 1.555588e-04 Jan 3 0.6540089 -2.573478e-04 3.101086e-03 Feb 3 0.6696103 -2.566489e-05 1.597250e-04 Mar 3 0.6818088 1.678663e-05 7.412379e-04 Apr 3 0.6892039 2.543217e-05 -1.839081e-04 May 3 0.7123400 5.541167e-05 8.800431e-04 Jun 3 0.7024363 4.177091e-05 -1.963202e-04 Jul 3 0.7009175 3.963024e-05 -4.674794e-04 Aug 3 0.6987572 3.662104e-05 4.327530e-04 Sep 3 0.6971660 3.439858e-05 -2.360021e-04 Oct 3 0.6975716 3.491390e-05 5.836579e-05 Nov 3 0.6928766 2.774103e-05 -9.664974e-05 Dec 3 0.7016439 3.067301e-05 3.160999e-04 Jan 4 0.6936465 1.237251e-04 -1.496465e-03 Feb 4 0.6777741 -4.012676e-05 -8.741494e-04 Mar 4 0.6708087 -6.373624e-05 4.312808e-04 Apr 4 0.6667962 -6.771117e-05 -1.476170e-03 May 4 0.6701409 -6.430082e-05 1.429099e-03 Jun 4 0.6648792 -6.999998e-05 -5.991770e-04 Jul 4 0.6661113 -6.855521e-05 -3.512688e-04 Aug 4 0.6688808 -6.541737e-05 5.391504e-04 Sep 4 0.6810537 -5.188246e-05 2.463116e-04 Oct 4 0.6908398 -4.052432e-05 6.002395e-04 Nov 4 0.6990226 -3.026429e-05 -4.026407e-04 Dec 4 0.6948400 -2.923024e-05 1.600324e-04 Jan 5 0.6977395 -5.262362e-05 9.304544e-04 Feb 5 0.6906210 -1.067231e-04 -9.410201e-04 Mar 5 0.6915545 -1.032327e-04 7.754620e-04 Apr 5 0.6850740 -1.095416e-04 -2.143982e-03 May 5 0.6823723 -1.117034e-04 1.617693e-03 Jun 5 0.6702690 -1.229501e-04 -1.318996e-03 Jul 5 0.6867069 -1.069689e-04 8.530599e-04 Aug 5 0.6855655 -1.079649e-04 -2.954817e-04 Sep 5 0.6783076 -1.149014e-04 -7.075800e-04 Oct 5 0.6810223 -1.119594e-04 3.477234e-04 Nov 5 0.6797010 -1.132313e-04 -3.709685e-04 Dec 5 0.6792563 -1.130309e-04 -3.632173e-05 > m$resid Jan Feb Mar Apr May Jun 1 0.00000000 -0.05656685 -0.58628287 -0.91675432 -1.03071857 -0.53677438 2 -0.45818114 -0.56583873 0.49917227 -0.16613686 1.70679882 1.97205034 3 1.63678159 1.80766020 1.52002415 0.91834767 2.87629889 -1.23947833 4 -1.05565262 -1.87796195 -0.86034447 -0.49144904 0.42465227 -0.64677297 5 0.37824802 -0.84350335 0.12912142 -0.79367242 -0.32255153 -1.49214259 Jul Aug Sep Oct Nov Dec 1 -0.02864889 2.23507033 -0.40500508 0.11338062 -0.66202852 0.20961993 2 -0.52999674 -0.40472698 -0.62865326 -0.13481962 0.90115802 0.62561600 3 -0.19422998 -0.27378935 -0.20259972 0.04620373 -0.58877766 1.08709315 4 0.16203393 0.35318091 1.52294353 1.22430799 1.02354166 -0.51647899 5 2.06070863 -0.12872376 -0.88968849 0.35212331 -0.15050975 -0.04122725 > 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/www/html/rcomp/tmp/1gknz1259927771.ps",horizontal=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/2ptww1259927771.ps",horizontal=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/36uws1259927771.ps",horizontal=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/4lo1y1259927771.ps",horizontal=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/www/html/rcomp/tmp/5asjo1259927771.ps",horizontal=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/6gh981259927771.tab") > system("convert tmp/1gknz1259927771.ps tmp/1gknz1259927771.png") > system("convert tmp/2ptww1259927771.ps tmp/2ptww1259927771.png") > system("convert tmp/36uws1259927771.ps tmp/36uws1259927771.png") > system("convert tmp/4lo1y1259927771.ps tmp/4lo1y1259927771.png") > system("convert tmp/5asjo1259927771.ps tmp/5asjo1259927771.png") > > > proc.time() user system elapsed 1.499 0.787 2.857