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(46,62,66,59,58,61,41,27,58,70,49,59,44,36,72,45,56,54,53,35,61,52,47,51,52,63,74,45,51,64,36,30,55,64,39,40,63,45,59,55,40,64,27,28,45,57,45,69,60,56,58,50,51,53,37,22,55,70,62,58,39,49,58,47,42,62,39,40,72,70,54,65) > 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 1.489569 0.000000 12.252429 73.214659 > m$fitted level slope sea Jan 1 46.00000 0.00000000 0.0000000 Feb 1 47.91099 0.45769799 3.2732664 Mar 1 52.21811 1.23549467 3.1105982 Apr 1 54.80854 1.45917282 0.8853652 May 1 56.45332 1.48496121 1.0974479 Jun 1 58.30257 1.52862181 1.7877549 Jul 1 55.50982 1.07341424 -3.2052797 Aug 1 49.86607 0.44240765 -4.3685330 Sep 1 51.13487 0.51244970 4.4698443 Oct 1 55.14963 0.78285553 4.1921840 Nov 1 54.83125 0.70477806 -2.3250619 Dec 1 55.92695 0.73040553 1.7758709 Jan 2 56.33222 0.73655177 -10.1266939 Feb 2 53.31618 0.55137085 -4.8509687 Mar 2 56.14614 0.67845403 9.1823289 Apr 2 55.05809 0.58285030 -4.7438986 May 2 55.42480 0.57180902 1.2602458 Jun 2 55.12166 0.52978192 1.7913244 Jul 2 55.20648 0.50964565 -0.6615141 Aug 2 53.29297 0.40599506 -9.5764605 Sep 2 54.04464 0.42001680 5.6741337 Oct 2 53.51613 0.38344712 2.0915119 Nov 2 53.18380 0.35732766 -3.3932696 Dec 2 52.75761 0.33181840 1.4235310 Jan 3 53.39367 0.33446471 -2.9124345 Feb 3 55.75063 0.38638105 -1.0804373 Mar 3 57.49715 0.42978924 11.3360004 Apr 3 57.00919 0.39955238 -8.5557518 May 3 56.16347 0.35939133 -0.4100745 Jun 3 57.00846 0.37447520 5.1011151 Jul 3 54.46465 0.28751904 -6.8837384 Aug 3 52.37791 0.21965601 -12.7918472 Sep 3 51.68270 0.19455920 7.0683220 Oct 3 52.89493 0.22127717 6.8717322 Nov 3 51.85390 0.19013198 -7.5137155 Dec 3 50.31705 0.15339818 -2.7814701 Jan 4 52.13367 0.17285092 2.9919423 Feb 4 51.87770 0.16516367 -4.9899288 Mar 4 51.30814 0.14893914 10.7703335 Apr 4 52.71542 0.17850435 -2.9121334 May 4 51.46078 0.14473989 -5.5265659 Jun 4 51.91131 0.15179442 10.8111286 Jul 4 49.56964 0.09598639 -12.0411062 Aug 4 48.13993 0.06298222 -13.6297316 Sep 4 46.77363 0.03319386 4.3871822 Oct 4 46.77648 0.03258956 10.3556758 Nov 4 47.29313 0.04157316 -4.4294712 Dec 4 50.41294 0.09094567 4.7046095 Jan 5 51.59052 0.10364605 3.3276627 Feb 5 52.92266 0.12120240 -2.4890447 Mar 5 52.66958 0.11488033 6.9761209 Apr 5 52.58728 0.11130420 -1.7312877 May 5 53.05281 0.11784191 -3.5885919 Jun 5 51.55481 0.08828433 8.4802376 Jul 5 50.88450 0.07470780 -10.5605721 Aug 5 48.87974 0.03855708 -17.7030046 Sep 5 48.85532 0.03750045 6.4247157 Oct 5 50.27524 0.05962481 13.5280251 Nov 5 52.78823 0.09614232 -1.8989003 Dec 5 53.47355 0.10387469 1.8188076 Jan 6 51.83047 0.08474341 -4.6601157 Feb 6 51.56941 0.08054854 -0.9764522 Mar 6 51.45746 0.07790163 7.4130861 Apr 6 51.12397 0.07184339 -2.2820316 May 6 50.23673 0.05736220 -3.9531025 Jun 6 50.36808 0.05847852 11.3008277 Jul 6 50.11050 0.05378379 -9.6904616 Aug 6 51.05568 0.06669466 -15.0810396 Sep 6 53.13723 0.09489828 9.7120205 Oct 6 54.17719 0.10752172 11.5027849 Nov 6 54.63672 0.11191065 -2.2585468 Dec 6 55.54987 0.12092746 5.7216013 > m$resid Jan Feb Mar Apr May Jun 1 0.00000000 1.53740801 1.66340889 0.52469564 0.07120821 0.14326567 2 -0.32950702 -1.97250971 1.08285304 -0.86273743 -0.11065026 -0.46809716 3 0.23801670 1.33115093 0.83613254 -0.56066659 -0.77134351 0.30630001 4 1.25744345 -0.30370966 -0.49875524 0.84438431 -0.96474154 0.20760704 5 0.81793046 0.89873534 -0.26678869 -0.13907470 0.24970854 -1.14383035 6 -1.31980014 -0.25768883 -0.14116390 -0.29916330 -0.69623057 0.05382044 Jul Aug Sep Oct Nov Dec 1 -1.76638135 -2.86763015 0.36862910 1.62955097 -0.53297665 0.19618858 2 -0.24718871 -1.38962527 0.20365490 -0.57199108 -0.44127708 -0.50032714 3 -1.87336479 -1.54833519 -0.60503178 0.68188069 -0.85851668 -1.20700650 4 -1.70961224 -1.05622452 -0.99864912 -0.02139950 0.34540580 2.23928536 5 -0.54023445 -1.49067365 -0.04545820 1.00508440 1.80000855 0.43799086 6 -0.23079009 0.65397375 1.48589765 0.70101367 0.26294541 0.60388042 > 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/13n8w1292072969.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/2ew7z1292072969.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/3ew7z1292072969.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/4oooj1292072969.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/www/html/rcomp/tmp/5oooj1292072969.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/63f4s1292072969.tab") > > try(system("convert tmp/13n8w1292072969.ps tmp/13n8w1292072969.png",intern=TRUE)) character(0) > try(system("convert tmp/2ew7z1292072969.ps tmp/2ew7z1292072969.png",intern=TRUE)) character(0) > try(system("convert tmp/3ew7z1292072969.ps tmp/3ew7z1292072969.png",intern=TRUE)) character(0) > try(system("convert tmp/4oooj1292072969.ps tmp/4oooj1292072969.png",intern=TRUE)) character(0) > try(system("convert tmp/5oooj1292072969.ps tmp/5oooj1292072969.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.072 0.850 4.623