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(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.489623 0.000000 12.250761 73.216781 > m$fitted level slope sea Jan 1 46.00000 0.00000000 0.0000000 Feb 1 47.91110 0.45772774 3.2728992 Mar 1 52.21817 1.23550591 3.1103622 Apr 1 54.80854 1.45916988 0.8854168 May 1 56.45329 1.48495530 1.0975036 Jun 1 58.30254 1.52861645 1.7877311 Jul 1 55.50975 1.07340738 -3.2047731 Aug 1 49.86599 0.44240303 -4.3679084 Sep 1 51.13490 0.51245433 4.4694316 Oct 1 55.14970 0.78286218 4.1917274 Nov 1 54.83126 0.70477976 -2.3247464 Dec 1 55.92697 0.73040798 1.7757825 Jan 2 56.33223 0.73655637 -10.1265350 Feb 2 53.31608 0.55136724 -4.8504277 Mar 2 56.14621 0.67845980 9.1816502 Apr 2 55.05810 0.58285290 -4.7435633 May 2 55.42482 0.57181224 1.2602109 Jun 2 55.12171 0.52978714 1.7912299 Jul 2 55.20652 0.50964976 -0.6614112 Aug 2 53.29286 0.40599349 -9.5755807 Sep 2 54.04460 0.42001829 5.6738466 Oct 2 53.51616 0.38345122 2.0913375 Nov 2 53.18379 0.35733049 -3.3930482 Dec 2 52.75763 0.33182184 1.4235176 Jan 3 53.39368 0.33446738 -2.9124872 Feb 3 55.75063 0.38638384 -1.0805109 Mar 3 57.49726 0.42979570 11.3354133 Apr 3 57.00922 0.39955601 -8.5553927 May 3 56.16349 0.35939465 -0.4099360 Jun 3 57.00853 0.37447977 5.1008379 Jul 3 54.46464 0.28752192 -6.8831585 Aug 3 52.37779 0.21965590 -12.7910124 Sep 3 51.68265 0.19456122 7.0681661 Oct 3 52.89497 0.22128126 6.8712554 Nov 3 51.85388 0.19013482 -7.5133531 Dec 3 50.31699 0.15340046 -2.7810946 Jan 4 52.13365 0.17285121 2.9915811 Feb 4 51.87767 0.16516387 -4.9898354 Mar 4 51.30818 0.14894076 10.7700439 Apr 4 52.71549 0.17850652 -2.9123614 May 4 51.46080 0.14474080 -5.5262406 Jun 4 51.91139 0.15179698 10.8107149 Jul 4 49.56960 0.09598656 -12.0403514 Aug 4 48.13980 0.06298049 -13.6290585 Sep 4 46.77352 0.03319273 4.3873276 Oct 4 46.77647 0.03259047 10.3552406 Nov 4 47.29312 0.04157393 -4.4294729 Dec 4 50.41295 0.09094612 4.7042363 Jan 5 51.59055 0.10364582 3.3273883 Feb 5 52.92270 0.12120210 -2.4892490 Mar 5 52.66962 0.11488003 6.9760937 Apr 5 52.58735 0.11130445 -1.7314820 May 5 53.05287 0.11784182 -3.5885942 Jun 5 51.55487 0.08828438 8.4802820 Jul 5 50.88448 0.07470631 -10.5600972 Aug 5 48.87960 0.03855374 -17.7021878 Sep 5 48.85518 0.03749733 6.4247982 Oct 5 50.27519 0.05962295 13.5275892 Nov 5 52.78821 0.09614077 -1.8992411 Dec 5 53.47355 0.10387333 1.8186406 Jan 6 51.83046 0.08474296 -4.6598585 Feb 6 51.56944 0.08054869 -0.9766491 Mar 6 51.45750 0.07790196 7.4129941 Apr 6 51.12403 0.07184393 -2.2821339 May 6 50.23678 0.05736256 -3.9530457 Jun 6 50.36813 0.05847886 11.3007721 Jul 6 50.11048 0.05378309 -9.6901028 Aug 6 51.05558 0.06669280 -15.0806555 Sep 6 53.13715 0.09489662 9.7118494 Oct 6 54.17715 0.10752061 11.5025415 Nov 6 54.63673 0.11191012 -2.2588107 Dec 6 55.54993 0.12092732 5.7212374 > m$resid Jan Feb Mar Apr May Jun 1 0.00000000 1.53740430 1.66337970 0.52466880 0.07120066 0.14326807 2 -0.32952070 -1.97251277 1.08291332 -0.86276066 -0.11064364 -0.46807367 3 0.23801380 1.33111479 0.83618004 -0.56070959 -0.77134112 0.30632290 4 1.25745815 -0.30370952 -0.49869783 0.84438130 -0.96476198 0.20765309 5 0.81794039 0.89872986 -0.26678207 -0.13905038 0.24969104 -1.14380738 6 -1.31979281 -0.25765282 -0.14115123 -0.29914614 -0.69622419 0.05381903 Jul Aug Sep Oct Nov Dec 1 -1.76638937 -2.86761633 0.36867659 1.62955537 -0.53300719 0.19619283 2 -0.24720156 -1.38969566 0.20369835 -0.57194659 -0.44129478 -0.50030873 3 -1.87338887 -1.54839305 -0.60497582 0.68192725 -0.85854076 -1.20701410 4 -1.70966842 -1.05627505 -0.99861920 -0.02132687 0.34539598 2.23926448 5 -0.54028832 -1.49073086 -0.04544851 1.00512827 1.80000378 0.43800216 6 -0.23083754 0.65390437 1.48588666 0.70103488 0.26297749 0.60390864 > 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/1amlj1324557983.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/27znu1324557983.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/3gzg81324557983.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/42mfs1324557983.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/59mpb1324557983.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/6h9s11324557983.tab") > > try(system("convert tmp/1amlj1324557983.ps tmp/1amlj1324557983.png",intern=TRUE)) character(0) > try(system("convert tmp/27znu1324557983.ps tmp/27znu1324557983.png",intern=TRUE)) character(0) > try(system("convert tmp/3gzg81324557983.ps tmp/3gzg81324557983.png",intern=TRUE)) character(0) > try(system("convert tmp/42mfs1324557983.ps tmp/42mfs1324557983.png",intern=TRUE)) character(0) > try(system("convert tmp/59mpb1324557983.ps tmp/59mpb1324557983.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.188 0.317 2.509