R version 2.13.0 (2011-04-13) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-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(579,572,560,551,537,541,588,607,599,578,563,566,561,554,540,526,512,505,554,584,569,540,522,526,527,516,503,489,479,475,524,552,532,511,492,492,493,481,462,457,442,439,488,521,501,485,464,460,467,460,448,443,436,431,484,510,513,503,471,471) > 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.00000 113.01356 24.79198 0.00000 > m$fitted level slope sea Jan 1 579.0000 0.000000 0.0000000 Feb 1 573.7823 -5.365024 -1.7822712 Mar 1 561.0209 -10.469035 -1.0208915 Apr 1 550.4077 -10.574621 0.5922850 May 1 537.6244 -12.160142 -0.6244417 Jun 1 537.4360 -3.619433 3.5639989 Jul 1 576.8214 27.162754 11.1786043 Aug 1 609.3116 30.978721 -2.3115646 Sep 1 608.6014 8.282666 -9.6014185 Oct 1 584.5468 -14.873225 -6.5467943 Nov 1 562.3437 -20.121496 0.6562675 Dec 1 560.2781 -7.193072 5.7219401 Jan 2 560.3215 -2.025125 0.6785295 Feb 2 555.3588 -4.131002 -1.3587936 Mar 2 542.1197 -10.430746 -2.1196986 Apr 2 523.3492 -16.180597 2.6508230 May 2 512.3093 -12.611551 -0.3093019 Jun 2 512.3788 -3.877876 -7.3788262 Jul 2 539.3090 17.328111 14.6909594 Aug 2 575.2341 30.150338 8.7658982 Sep 2 578.0713 11.310624 -9.0712787 Oct 2 552.9592 -13.811614 -12.9591845 Nov 2 527.8620 -21.592808 -5.8619576 Dec 2 518.6351 -13.075686 7.3648752 Jan 3 521.5921 -2.031831 5.4078659 Feb 3 515.6499 -4.728844 0.3500705 Mar 3 502.5466 -10.446325 0.4533986 Apr 3 486.3881 -14.334289 2.6118673 May 3 479.9516 -8.931402 -0.9515926 Jun 3 489.6575 3.784166 -14.6575367 Jul 3 513.3093 17.308663 10.6906654 Aug 3 535.2411 20.458753 16.7588979 Sep 3 535.0877 6.403107 -3.0877009 Oct 3 523.8900 -5.599542 -12.8899748 Nov 3 505.4083 -14.379933 -13.4082681 Dec 3 490.1594 -14.971836 1.8406122 Jan 4 483.7280 -9.150075 9.2720172 Feb 4 476.2778 -7.991670 4.7221845 Mar 4 459.8577 -13.707003 2.1422693 Apr 4 452.9306 -9.116923 4.0694484 May 4 448.3389 -6.044370 -6.3388881 Jun 4 457.6361 4.367022 -18.6361158 Jul 4 476.8223 14.405086 11.1776872 Aug 4 497.3698 18.566200 23.6302352 Sep 4 502.5387 9.484067 -1.5387118 Oct 4 497.2343 -0.542457 -12.2343156 Nov 4 481.4595 -10.866395 -17.4594928 Dec 4 462.9853 -16.022064 -2.9852790 Jan 5 454.9732 -10.590544 12.0267518 Feb 5 450.0900 -6.723174 9.9100478 Mar 5 445.6612 -5.172933 2.3388120 Apr 5 439.4583 -5.868235 3.5417417 May 5 444.2647 1.350441 -8.2646958 Jun 5 454.0079 7.027093 -23.0078670 Jul 5 473.1578 15.216355 10.8422054 Aug 5 484.7534 12.771354 25.2465532 Sep 5 507.0218 19.186917 5.9781845 Oct 5 513.9001 10.870755 -10.9001302 Nov 5 494.0675 -9.871129 -23.0674922 Dec 5 477.2962 -14.533227 -6.2962270 > m$resid Jan Feb Mar Apr May Jun 1 0.00000000 -0.58040368 -0.50711123 -0.01024708 -0.14783849 0.80438807 2 0.48763097 -0.20121598 -0.58927435 -0.54944481 0.33576708 0.81948847 3 1.04201008 -0.25407206 -0.53652991 -0.36769678 0.50939254 1.19380346 4 0.54861345 0.10895413 -0.53698903 0.43281796 0.28957427 0.97846694 5 0.51140013 0.36364611 0.14572853 -0.06549255 0.67999172 0.53380793 Jul Aug Sep Oct Nov Dec 1 2.89717648 0.35892830 -2.13498528 -2.17820156 -0.49368576 1.21613130 2 1.99626014 1.20641327 -1.77205437 -2.36332264 -0.73195800 0.80144490 3 1.27189894 0.29641599 -1.32213559 -1.12907812 -0.82595741 -0.05571508 4 0.94363689 0.39146133 -0.85435968 -0.94316439 -0.97124353 -0.48529869 5 0.76983842 -0.22996611 0.60351703 -0.78231811 -1.95153714 -0.43879550 > 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/1a8uw1322493779.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/23v7f1322493779.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/30icv1322493779.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/4g5ug1322493779.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/5ufjm1322493779.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/6vosd1322493779.tab") > > try(system("convert tmp/1a8uw1322493779.ps tmp/1a8uw1322493779.png",intern=TRUE)) character(0) > try(system("convert tmp/23v7f1322493779.ps tmp/23v7f1322493779.png",intern=TRUE)) character(0) > try(system("convert tmp/30icv1322493779.ps tmp/30icv1322493779.png",intern=TRUE)) character(0) > try(system("convert tmp/4g5ug1322493779.ps tmp/4g5ug1322493779.png",intern=TRUE)) character(0) > try(system("convert tmp/5ufjm1322493779.ps tmp/5ufjm1322493779.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.653 0.274 1.998