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(25.6,23.7,22,21.3,20.7,20.4,20.3,20.4,19.8,19.5,23.1,23.5,23.5,22.9,21.9,21.5,20.5,20.2,19.4,19.2,18.8,18.8,22.6,23.3,23,21.4,19.9,18.8,18.6,18.4,18.6,19.9,19.2,18.4,21.1,20.5,19.1,18.1,17,17.1,17.4,16.8,15.3,14.3,13.4,15.3,22.1,23.7,22.2,19.5,16.6,17.3,19.8,21.2,21.5,20.6,19.1,19.6,23.5,24) > 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.00000000 1.66211280 0.04538702 0.00000000 > m$fitted level slope sea Jan 1 25.60000 0.00000000 0.000000000 Feb 1 23.77483 -1.83135418 -0.074830133 Mar 1 21.94654 -1.82858782 0.053462799 Apr 1 21.21478 -0.84154378 0.085216303 May 1 20.69602 -0.55166561 0.003983011 Jun 1 20.38645 -0.33403950 0.013550389 Jul 1 20.28548 -0.12452624 0.014524826 Aug 1 20.38591 0.07769222 0.014087216 Sep 1 19.85008 -0.47379594 -0.050081049 Oct 1 19.47802 -0.38235053 0.021983579 Nov 1 22.81508 2.96100191 0.284921352 Dec 1 23.73150 1.12314014 -0.231495058 Jan 2 23.56224 -0.03776020 -0.062242560 Feb 2 22.95220 -0.55264297 -0.052195525 Mar 2 21.97070 -0.92250994 -0.070696995 Apr 2 21.39001 -0.62534426 0.109988182 May 2 20.53079 -0.82768352 -0.030792747 Jun 2 20.15890 -0.43302202 0.041100529 Jul 2 19.48880 -0.63836024 -0.088795470 Aug 2 19.06576 -0.45186958 0.134236522 Sep 2 18.68051 -0.39417753 0.119489774 Oct 2 19.16574 0.36742721 -0.365740694 Nov 2 21.94500 2.45623756 0.655004993 Dec 2 23.56284 1.73025116 -0.262837195 Jan 3 23.22443 -0.06020661 -0.224427642 Feb 3 21.52270 -1.48276851 -0.122704000 Mar 3 19.98500 -1.52962625 -0.085004200 Apr 3 18.60685 -1.39975381 0.193146908 May 3 18.56381 -0.23992177 0.036187814 Jun 3 18.34563 -0.22133518 0.054366903 Jul 3 18.66350 0.23979916 -0.063499977 Aug 3 19.61319 0.84692371 0.286812971 Sep 3 19.20943 -0.22267291 -0.009426478 Oct 3 19.12906 -0.10096761 -0.729063401 Nov 3 20.32601 1.00901148 0.773991175 Dec 3 20.65566 0.42819304 -0.155655645 Jan 4 19.29642 -1.09994836 -0.196416181 Feb 4 18.17098 -1.12174324 -0.070975982 Mar 4 17.03529 -1.13358184 -0.035285408 Apr 4 16.96660 -0.22712674 0.133403852 May 4 17.27576 0.22880932 0.124235283 Jun 4 16.89446 -0.28956042 -0.094463586 Jul 4 15.62145 -1.12550081 -0.321450621 Aug 4 13.84434 -1.67943220 0.455663510 Sep 4 13.25433 -0.75332375 0.145665510 Oct 4 15.93589 2.16659309 -0.635891529 Nov 4 21.04003 4.66352660 1.059969672 Dec 4 23.83027 3.07172723 -0.130267180 Jan 5 22.80685 -0.40898808 -0.606854071 Feb 5 19.76121 -2.64881609 -0.261205510 Mar 5 16.78389 -2.92676322 -0.183892307 Apr 5 16.96305 -0.29435784 0.336945655 May 5 19.38608 2.00791195 0.413920460 Jun 5 21.19058 1.83571274 0.009418815 Jul 5 21.71836 0.72811105 -0.218364389 Aug 5 20.28214 -1.10503089 0.317863563 Sep 5 19.34449 -0.96325943 -0.244488827 Oct 5 20.62826 0.93990691 -1.028264802 Nov 5 22.34596 1.59857481 1.154037356 Dec 5 23.68239 1.37663438 0.317609240 > m$resid Jan Feb Mar Apr May Jun 1 0.00000000 -1.44810168 0.00223916 0.76249970 0.22494204 0.16880316 2 -0.90134729 -0.40294975 -0.29027438 0.23047893 -0.15688674 0.30617068 3 -1.39058360 -1.10542355 -0.03646650 0.10089423 0.89886472 0.01441946 4 -1.18680540 -0.01690638 -0.00919402 0.70421780 0.35337994 -0.40210088 5 -2.70245694 -1.73680562 -0.21571908 2.04447234 1.78481278 -0.13355854 Jul Aug Sep Oct Nov Dec 1 0.16251091 0.15685219 -0.42776570 0.07093028 2.59329494 -1.42555047 2 -0.15926996 0.14465329 0.04474924 0.59074425 1.62020863 -0.56312255 3 0.35768210 0.47091929 -0.82964081 0.09440184 0.86096764 -0.45054746 4 -0.64842930 -0.42965604 0.71834434 2.26487758 1.93675299 -1.23489682 5 -0.85917671 -1.42187340 0.10996645 1.47622698 0.51089548 -0.17219061 > 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/1u5ry1261432287.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/2mktb1261432287.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/3l2zx1261432287.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/42ndh1261432287.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/5lnty1261432287.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/6ctqb1261432287.tab") > > try(system("convert tmp/1u5ry1261432287.ps tmp/1u5ry1261432287.png",intern=TRUE)) character(0) > try(system("convert tmp/2mktb1261432287.ps tmp/2mktb1261432287.png",intern=TRUE)) character(0) > try(system("convert tmp/3l2zx1261432287.ps tmp/3l2zx1261432287.png",intern=TRUE)) character(0) > try(system("convert tmp/42ndh1261432287.ps tmp/42ndh1261432287.png",intern=TRUE)) character(0) > try(system("convert tmp/5lnty1261432287.ps tmp/5lnty1261432287.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.339 0.809 2.373