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(92.9,107.7,103.5,91.1,79.8,71.9,82.9,90.1,100.7,90.7,108.8,44.1,93.6,107.4,96.5,93.6,76.5,76.7,84,103.3,88.5,99,105.9,44.7,94,107.1,104.8,102.5,77.7,85.2,91.3,106.5,92.4,97.5,107,51.1,98.6,102.2,114.3,99.4,72.5,92.3,99.4,85.9,109.4,97.6,104.7,56.9,86.7,108.5,103.4,86.2,71,75.9,87.1,102,88.5,87.8,100.8,50.6,85.9) > 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.371257 0.000000 45.515297 21.250427 > m$fitted level slope sea Jan 1 92.90000 0.00000000 0.0000000 Feb 1 92.68966 -0.25540822 11.4862058 Mar 1 95.95711 0.33873407 3.9332848 Apr 1 96.83495 0.42348506 -6.0532752 May 1 93.28383 -0.12263728 -11.0959301 Jun 1 87.73848 -0.77110467 -12.0145289 Jul 1 84.82669 -0.99491587 -0.1601157 Aug 1 84.42844 -0.93993382 5.1128030 Sep 1 86.59774 -0.68490145 10.8939113 Oct 1 87.79908 -0.54572162 0.8052316 Nov 1 91.15916 -0.28375899 13.0483756 Dec 1 85.65221 -0.60527893 -35.1350798 Jan 2 84.63508 -0.61596044 9.5819190 Feb 2 85.50082 -0.57064264 19.8085168 Mar 2 86.18592 -0.51935143 8.7424553 Apr 2 87.30658 -0.44250656 4.3861041 May 2 86.89484 -0.44099858 -10.4298707 Jun 2 86.67898 -0.43002662 -10.2380129 Jul 2 86.39399 -0.42319581 -2.5651022 Aug 2 88.16542 -0.32499088 12.4686132 Sep 2 87.65825 -0.33265025 1.0694932 Oct 2 88.81999 -0.27422542 8.2617675 Nov 2 88.95651 -0.25952214 16.4029679 Dec 2 87.95095 -0.28320293 -42.2434226 Jan 3 87.48046 -0.28807732 6.7812965 Feb 3 87.48545 -0.28077651 19.2046131 Mar 3 88.63868 -0.24294830 14.1961119 Apr 3 90.18721 -0.19235481 9.9092379 May 3 90.59454 -0.17464939 -13.6894063 Jun 3 91.47804 -0.14288644 -7.6774045 Jul 3 92.38390 -0.11162545 -2.4777272 Aug 3 92.96639 -0.09145932 12.6026452 Sep 3 93.18212 -0.08289009 -1.1987362 Oct 3 92.81542 -0.09039312 5.0740491 Nov 3 92.36361 -0.09933710 15.1382139 Dec 3 92.40243 -0.09617076 -41.4964541 Jan 4 92.59123 -0.09012671 5.6045946 Feb 4 91.95426 -0.10130550 11.0234046 Mar 4 92.98075 -0.07818241 19.7211351 Apr 4 93.15350 -0.07292857 5.8929354 May 4 92.65045 -0.08211914 -19.5470088 Jun 4 93.46837 -0.06268845 -2.4292883 Jul 4 94.80122 -0.03264269 2.6408246 Aug 4 92.84970 -0.07331479 -4.2476950 Sep 4 94.07735 -0.04647918 13.4815357 Oct 4 94.30469 -0.04103538 2.9056102 Nov 4 93.89864 -0.04798075 11.3238851 Dec 4 94.29890 -0.03984040 -38.0440392 Jan 5 92.98798 -0.06197749 -4.4508403 Feb 5 93.17033 -0.05783393 14.9758184 Mar 5 92.20215 -0.07312334 12.5160834 Apr 5 90.51495 -0.10026748 -1.9805150 May 5 90.00677 -0.10715879 -18.4174689 Jun 5 88.53467 -0.13025921 -10.6634088 Jul 5 87.27524 -0.14928585 1.4568257 Aug 5 88.98198 -0.11837973 10.3305414 Sep 5 87.94471 -0.13339116 1.8891955 Oct 5 87.04540 -0.14559261 1.8697451 Nov 5 86.80239 -0.14709998 14.1398757 Dec 5 86.55608 -0.14858995 -35.8107748 Jan 6 86.64560 -0.14510850 -1.0951169 > m$resid Jan Feb Mar Apr May Jun 1 0.00000000 1.56665481 1.79029325 0.18139750 -1.39024174 -2.17351412 2 -0.32363543 1.10129764 0.84266349 1.03887150 0.01923744 0.14254755 3 -0.14092860 0.22055737 1.06015371 1.30167389 0.43182305 0.76152637 4 0.21834069 -0.41986947 0.86317990 0.19115923 -0.32659527 0.68293085 5 -0.99191234 0.19098610 -0.71150013 -1.26028062 -0.31824288 -1.06482595 6 0.18850027 Jul Aug Sep Oct Nov Dec 1 -0.97718851 0.30246701 1.70913723 1.10332944 2.39676118 -3.32701502 2 0.09403171 1.46077393 -0.12435519 1.04369166 0.29301177 -0.54412392 3 0.75879617 0.50652815 0.22641457 -0.21134791 -0.27188460 0.10495650 4 1.06073296 -1.46360158 0.99680733 0.21085086 -0.28250340 0.34853743 5 -0.88168887 1.45174519 -0.72040103 -0.60205648 -0.07677940 -0.07838859 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/www/html/rcomp/tmp/1jznr1259948413.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/27t9r1259948413.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/325j81259948413.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/40izq1259948413.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/5mbo21259948413.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/6sh091259948413.tab") > > system("convert tmp/1jznr1259948413.ps tmp/1jznr1259948413.png") > system("convert tmp/27t9r1259948413.ps tmp/27t9r1259948413.png") > system("convert tmp/325j81259948413.ps tmp/325j81259948413.png") > system("convert tmp/40izq1259948413.ps tmp/40izq1259948413.png") > system("convert tmp/5mbo21259948413.ps tmp/5mbo21259948413.png") > > > proc.time() user system elapsed 1.342 0.790 2.207