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(43.9,51,51.9,54.3,50.3,57.2,48.8,41.1,58,63,53.8,54.7,55.5,56.1,69.6,69.4,57.2,68,53.3,47.9,60.8,61.7,57.8,51.4,50.5,48.1,58.7,54,56.1,60.4,51.2,50.7,56.4,53.3,52.6,47.7,49.5,48.5,55.3,49.8,57.4,64.6,53,41.5,55.9,58.4,53.5,50.6,58.5,49.1,61.1,52.3,58.4,65.5,61.7,45.1,52.1,59.3,57.9,45,64.9,63.8,69.4,71.1,62.9,73.5,62.7,51.9,73.3,66.7,62.5,70.3) > 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 4.423182 0.000000 3.212728 11.572685 > m$fitted level slope sea Jan 1 43.90000 0.0000000 0.0000000 Feb 1 47.04794 0.2424668 1.3612775 Mar 1 49.53420 0.4129880 0.7649556 Apr 1 51.74514 0.5162125 1.0698219 May 1 51.44395 0.4805743 -0.4119278 Jun 1 53.71367 0.5438903 1.8235378 Jul 1 52.11435 0.4780581 -1.2872624 Aug 1 47.76053 0.3428116 -2.0499453 Sep 1 51.28736 0.4265338 3.6599122 Oct 1 56.21455 0.5396885 2.4583029 Nov 1 55.87338 0.5183014 -1.2249666 Dec 1 55.45247 0.4961558 0.1533058 Jan 2 57.21379 0.4035443 -3.0993448 Feb 2 57.07713 0.3929923 -0.5250750 Mar 2 62.07357 0.5523145 3.9823787 Apr 2 65.21302 0.6340582 2.0775816 May 2 63.31562 0.5689441 -3.9439896 Jun 2 64.05693 0.5725798 3.7911041 Jul 2 60.46092 0.4968716 -3.4363936 Aug 2 56.89532 0.4299890 -5.3421301 Sep 2 57.23000 0.4285124 3.6559793 Oct 2 58.07880 0.4347331 3.2413205 Nov 2 58.66548 0.4367902 -1.0031200 Dec 2 56.52059 0.4157033 -2.7644259 Jan 3 55.66029 0.4416155 -3.9306484 Feb 3 54.01740 0.4233378 -4.0989311 Mar 3 54.59182 0.4265585 3.9848983 Apr 3 53.56273 0.3937061 1.6388370 May 3 55.87234 0.4319783 -1.3993809 Jun 3 55.90375 0.4251807 4.8435405 Jul 3 55.12562 0.4075346 -2.8698706 Aug 3 55.59168 0.4083041 -4.9433494 Sep 3 54.94601 0.3955130 2.3877776 Oct 3 53.32548 0.3730808 1.7648147 Nov 3 52.96281 0.3663320 0.2923848 Dec 3 51.91759 0.3603006 -2.9517530 Jan 4 52.05011 0.3616593 -2.3409821 Feb 4 52.36823 0.3613911 -3.8300391 Mar 4 52.06222 0.3515207 3.7986615 Apr 4 51.11984 0.3292668 -0.2354679 May 4 53.80169 0.3677566 1.5967110 Jun 4 56.20077 0.3972616 6.6447616 Jul 4 56.56446 0.3968331 -3.5351556 Aug 4 53.11733 0.3531283 -8.2418980 Sep 4 52.69789 0.3452298 3.8830524 Oct 4 53.96971 0.3535169 3.6114796 Nov 4 53.78343 0.3497831 0.1948959 Dec 4 53.80993 0.3486639 -2.9220179 Jan 5 56.32949 0.3476536 0.2198589 Feb 5 55.50768 0.3412456 -5.3817941 Mar 5 56.19791 0.3451606 4.6041167 Apr 5 55.64083 0.3328379 -2.5753767 May 5 56.44103 0.3392390 1.5594243 Jun 5 57.36108 0.3465822 7.6371264 Jul 5 59.75076 0.3697226 0.1688610 Aug 5 57.93933 0.3477454 -10.9275217 Sep 5 54.73017 0.3161438 0.4992940 Oct 5 54.77865 0.3141255 4.7574706 Nov 5 55.94423 0.3190240 1.2028621 Dec 5 53.75038 0.3102963 -6.5212285 Jan 6 57.20241 0.3164175 4.9037508 Feb 6 61.90440 0.3394828 -1.9491241 Mar 6 63.57576 0.3516158 4.6768101 Apr 6 67.67761 0.3937046 0.2121715 May 6 66.33132 0.3734327 -1.9364718 Jun 6 66.42341 0.3703133 7.3200798 Jul 6 64.77182 0.3498679 -0.3098721 Aug 6 63.52437 0.3354556 -10.2251338 Sep 6 66.67086 0.3576131 4.1578763 Oct 6 65.63391 0.3483886 2.2951331 Nov 6 64.07929 0.3386037 0.1011853 Dec 6 69.20235 0.3560670 -3.1351956 > m$resid Jan Feb Mar Apr May Jun 1 0.00000000 1.26074627 0.83880416 0.75006564 -0.36143922 0.81224567 2 0.74245876 -0.23457308 1.90134065 1.12295732 -1.14258145 0.07938745 3 -0.64727612 -0.95745141 0.06618585 -0.64686972 0.87166503 -0.18518030 4 -0.11058934 -0.02026172 -0.30086737 -0.58425976 1.07693451 0.94127609 5 1.03626506 -0.54643106 0.15976702 -0.41205170 0.21510733 0.26973211 6 1.48885659 2.05277377 0.61521203 1.72659235 -0.80457923 -0.13094742 Jul Aug Sep Oct Nov Dec 1 -0.98507083 -2.23456080 1.47734413 2.09221944 -0.40997547 -0.43750157 2 -1.93847418 -1.89781596 -0.04462563 0.19703745 0.07130874 -1.21607329 3 -0.56122120 0.02741883 -0.49500030 -0.94810110 -0.34639627 -0.66756496 4 -0.01568164 -1.80360054 -0.36340397 0.43645034 -0.25455578 -0.15298077 5 0.95529927 -1.02427063 -1.67450448 -0.12618307 0.40183095 -1.18842427 6 -0.94634425 -0.75054193 1.32396538 -0.65769449 -0.89831422 2.26093229 > 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/1hoow1261386508.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/2844e1261386508.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/3s0xt1261386508.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/4mt4c1261386508.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/5vy3q1261386508.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/6gc171261386508.tab") > try(system("convert tmp/1hoow1261386508.ps tmp/1hoow1261386508.png",intern=TRUE)) character(0) > try(system("convert tmp/2844e1261386508.ps tmp/2844e1261386508.png",intern=TRUE)) character(0) > try(system("convert tmp/3s0xt1261386508.ps tmp/3s0xt1261386508.png",intern=TRUE)) character(0) > try(system("convert tmp/4mt4c1261386508.ps tmp/4mt4c1261386508.png",intern=TRUE)) character(0) > try(system("convert tmp/5vy3q1261386508.ps tmp/5vy3q1261386508.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.611 0.794 1.923