R version 2.12.0 (2010-10-15) Copyright (C) 2010 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(1.21,1.22,1.22,1.22,1.21,1.23,1.22,1.22,1.22,1.22,1.23,1.22,1.21,1.22,1.21,1.22,1.21,1.20,1.18,1.19,1.20,1.19,1.19,1.20,1.21,1.20,1.20,1.20,1.21,1.21,1.21,1.20,1.21,1.21,1.21,1.20,1.19,1.20,1.20,1.20,1.22,1.22,1.21,1.25,1.25,1.27,1.28,1.27,1.28,1.29,1.26,1.27,1.25,1.27,1.27,1.27,1.29,1.26,1.27,1.27,1.28,1.28,1.28,1.27,1.24,1.25,1.25,1.24,1.24,1.23,1.24,1.23,1.24,1.24,1.24,1.25,1.26,1.26,1.27,1.26,1.28,1.29,1.28,1.27,1.30,1.30,1.28,1.29,1.27,1.26,1.27,1.27,1.27,1.28,1.29,1.28,1.30,1.30,1.30,1.29,1.30,1.29,1.28,1.30,1.30,1.31,1.32,1.33,1.32,1.30,1.31,1.30,1.30,1.30,1.29,1.29,1.30,1.30,1.29,1.27,1.26,1.25,1.26,1.27,1.26,1.25,1.25,1.25,1.26,1.26,1.26,1.27,1.28,1.29,1.30,1.26,1.25,1.26,1.25,1.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 8.680380e-05 0.000000e+00 0.000000e+00 2.954387e-05 > m$fitted level slope sea Jan 1 1.210000 0.000000e+00 0.000000e+00 Feb 1 1.218518 5.074449e-04 5.074449e-04 Mar 1 1.219392 5.143003e-04 5.143003e-04 Apr 1 1.219577 5.111568e-04 5.111568e-04 May 1 1.211776 4.481549e-04 4.481549e-04 Jun 1 1.225815 5.450447e-04 5.450447e-04 Jul 1 1.220944 5.071507e-04 5.071507e-04 Aug 1 1.219915 4.965073e-04 4.965073e-04 Sep 1 1.219699 4.916084e-04 4.916084e-04 Oct 1 1.219655 4.879517e-04 4.879517e-04 Nov 1 1.227493 5.378152e-04 5.378152e-04 Dec 1 1.221308 4.925135e-04 4.925135e-04 Jan 2 1.218452 6.854312e-04 -7.539743e-03 Feb 2 1.219282 6.894685e-04 6.894685e-04 Mar 2 1.211588 6.169738e-04 6.169738e-04 Apr 2 1.217848 6.420758e-04 6.420758e-04 May 2 1.211308 6.165377e-04 6.165377e-04 Jun 2 1.202061 5.834046e-04 5.834046e-04 Jul 2 1.184375 5.229523e-04 5.229523e-04 Aug 2 1.188500 5.348010e-04 5.348010e-04 Sep 2 1.197239 5.616892e-04 5.616892e-04 Oct 2 1.191223 5.402064e-04 5.402064e-04 Nov 2 1.189951 5.343076e-04 5.343076e-04 Dec 2 1.197549 5.572277e-04 5.572277e-04 Jan 3 1.209558 2.412326e-04 -2.653559e-03 Feb 3 1.201695 9.309610e-05 9.309610e-05 Mar 3 1.200307 8.476025e-05 8.476025e-05 Apr 3 1.200017 8.367091e-05 8.367091e-05 May 3 1.207827 1.016200e-04 1.016200e-04 Jun 3 1.209479 1.050273e-04 1.050273e-04 Jul 3 1.209829 1.055575e-04 1.055575e-04 Aug 3 1.202031 8.851059e-05 8.851059e-05 Sep 3 1.208253 1.017052e-04 1.017052e-04 Oct 3 1.209570 1.043126e-04 1.043126e-04 Nov 3 1.209849 1.046861e-04 1.046861e-04 Dec 3 1.202036 8.776570e-05 8.776570e-05 Jan 4 1.194529 2.255435e-04 -2.480978e-03 Feb 4 1.198782 2.802692e-04 2.802692e-04 Mar 4 1.199580 2.824306e-04 2.824306e-04 Apr 4 1.199748 2.821850e-04 2.821850e-04 May 4 1.215534 3.089292e-04 3.089292e-04 Jun 4 1.218873 3.138771e-04 3.138771e-04 Jul 4 1.211705 3.018235e-04 3.018235e-04 Aug 4 1.241689 3.494460e-04 3.494460e-04 Sep 4 1.248033 3.590433e-04 3.590433e-04 Oct 4 1.265126 3.857882e-04 3.857882e-04 Nov 4 1.276618 4.035097e-04 4.035097e-04 Dec 4 1.271174 3.941948e-04 3.941948e-04 Jan 5 1.280573 2.725205e-04 -2.997726e-03 Feb 5 1.287946 3.493003e-04 3.493003e-04 Mar 5 1.265734 2.744815e-04 2.744815e-04 Apr 5 1.268936 2.794931e-04 2.794931e-04 May 5 1.253860 2.584266e-04 2.584266e-04 Jun 5 1.266425 2.744098e-04 2.744098e-04 Jul 5 1.269083 2.774663e-04 2.774663e-04 Aug 5 1.269646 2.778305e-04 2.778305e-04 Sep 5 1.285519 2.977136e-04 2.977136e-04 Oct 5 1.265246 2.715243e-04 2.715243e-04 Nov 5 1.268835 2.757415e-04 2.757415e-04 Dec 5 1.269594 2.763556e-04 2.763556e-04 Jan 6 1.279362 1.741731e-04 -1.915904e-03 Feb 6 1.279767 1.762502e-04 1.762502e-04 Mar 6 1.279849 1.759910e-04 1.759910e-04 Apr 6 1.271990 1.645751e-04 1.645751e-04 May 6 1.246694 1.355810e-04 1.355810e-04 Jun 6 1.249220 1.381594e-04 1.381594e-04 Jul 6 1.249755 1.385815e-04 1.385815e-04 Aug 6 1.241990 1.301966e-04 1.301966e-04 Sep 6 1.240347 1.283187e-04 1.283187e-04 Oct 6 1.232122 1.194803e-04 1.194803e-04 Nov 6 1.238260 1.258408e-04 1.258408e-04 Dec 6 1.231680 1.187619e-04 1.187619e-04 Jan 7 1.238752 5.655293e-05 -6.220822e-04 Feb 7 1.239712 6.349139e-05 6.349138e-05 Mar 7 1.239902 6.378934e-05 6.378934e-05 Apr 7 1.247821 7.332550e-05 7.332550e-05 May 7 1.257374 8.255345e-05 8.255345e-05 Jun 7 1.259396 8.434063e-05 8.434063e-05 Jul 7 1.267702 9.182563e-05 9.182563e-05 Aug 7 1.261581 8.618864e-05 8.618864e-05 Sep 7 1.276044 9.921311e-05 9.921311e-05 Oct 7 1.286983 1.090233e-04 1.090233e-04 Nov 7 1.281418 1.038934e-04 1.038934e-04 Dec 7 1.272362 9.561845e-05 9.561845e-05 Jan 8 1.293590 -6.613103e-05 7.274413e-04 Feb 8 1.298726 -3.124817e-05 -3.124818e-05 Mar 8 1.283989 -6.141737e-05 -6.141737e-05 Apr 8 1.288760 -5.629501e-05 -5.629501e-05 May 8 1.274011 -6.878354e-05 -6.878354e-05 Jun 8 1.263010 -7.758379e-05 -7.758379e-05 Jul 8 1.268563 -7.310766e-05 -7.310766e-05 Aug 8 1.269737 -7.211885e-05 -7.211885e-05 Sep 8 1.269986 -7.186512e-05 -7.186512e-05 Oct 8 1.277918 -6.553632e-05 -6.553632e-05 Nov 8 1.287476 -5.793331e-05 -5.793331e-05 Dec 8 1.281618 -6.251167e-05 -6.251167e-05 Jan 9 1.294783 -1.509706e-04 1.660677e-03 Feb 9 1.299017 -1.248784e-04 -1.248785e-04 Mar 9 1.299863 -1.231097e-04 -1.231097e-04 Apr 9 1.292162 -1.302372e-04 -1.302372e-04 May 9 1.298413 -1.254239e-04 -1.254239e-04 Jun 9 1.291856 -1.300198e-04 -1.300198e-04 Jul 9 1.282588 -1.364683e-04 -1.364683e-04 Aug 9 1.296388 -1.266649e-04 -1.266649e-04 Sep 9 1.299307 -1.245247e-04 -1.245247e-04 Oct 9 1.307805 -1.184717e-04 -1.184717e-04 Nov 9 1.317483 -1.115993e-04 -1.115993e-04 Dec 9 1.327411 -1.045616e-04 -1.045616e-04 Jan 10 1.320968 -6.692280e-05 7.361508e-04 Feb 10 1.304362 -1.554060e-04 -1.554060e-04 Mar 10 1.308895 -1.477387e-04 -1.477387e-04 Apr 10 1.301971 -1.534667e-04 -1.534667e-04 May 10 1.300506 -1.543556e-04 -1.543556e-04 Jun 10 1.300196 -1.544555e-04 -1.544555e-04 Jul 10 1.292250 -1.593986e-04 -1.593986e-04 Aug 10 1.290569 -1.603611e-04 -1.603611e-04 Sep 10 1.298094 -1.555064e-04 -1.555064e-04 Oct 10 1.299686 -1.544034e-04 -1.544034e-04 Nov 10 1.292142 -1.590647e-04 -1.590647e-04 Dec 10 1.274784 -1.699066e-04 -1.699066e-04 Jan 11 1.262197 -1.036098e-04 1.139708e-03 Feb 11 1.252582 -1.498302e-04 -1.498302e-04 Mar 11 1.258514 -1.407971e-04 -1.407971e-04 Apr 11 1.267647 -1.336789e-04 -1.336789e-04 May 11 1.261697 -1.372594e-04 -1.372594e-04 Jun 11 1.252558 -1.425104e-04 -1.425104e-04 Jul 11 1.250624 -1.435424e-04 -1.435424e-04 Aug 11 1.250215 -1.436950e-04 -1.436950e-04 Sep 11 1.258009 -1.391402e-04 -1.391402e-04 Oct 11 1.259658 -1.381149e-04 -1.381149e-04 Nov 11 1.260007 -1.378358e-04 -1.378358e-04 Dec 11 1.267962 -1.332010e-04 -1.332010e-04 Jan 12 1.275927 -1.724781e-04 1.897260e-03 Feb 12 1.287187 -1.215958e-04 -1.215958e-04 Mar 12 1.297355 -1.076019e-04 -1.076019e-04 Apr 12 1.267978 -1.281772e-04 -1.281772e-04 May 12 1.253883 -1.360528e-04 -1.360528e-04 Jun 12 1.258782 -1.333628e-04 -1.333628e-04 Jul 12 1.251938 -1.369048e-04 -1.369048e-04 Aug 12 1.242608 -1.417416e-04 -1.417416e-04 > m$resid Jan Feb Mar Apr May Jun 1 0.00000000 0.57420776 0.03853304 -0.03534144 -0.89329683 1.46103762 2 -0.44400963 0.01301105 -0.89210667 0.60559673 -0.77135978 -1.05949443 3 1.37424154 -0.77950364 -0.15802450 -0.04028485 0.82962103 0.16651989 4 -0.87944998 0.39920044 0.05534858 -0.01223581 1.66447827 0.32541670 5 1.02372532 0.71594783 -2.41362733 0.31418719 -1.64852443 1.32121757 6 1.06706061 0.02358326 -0.01008508 -0.86244173 -2.73327519 0.25669886 7 0.77580504 0.09285171 0.01357534 0.84302253 1.01771881 0.20812351 8 2.34516809 0.53755390 -1.57522687 0.51868153 -1.57733861 -1.17350612 9 1.46189874 0.45499776 0.10411316 -0.81333618 0.68501488 -0.69050561 10 -0.69833735 -1.72239485 0.50232144 -0.72727567 -0.14074512 -0.01669904 11 -1.36444471 -0.99342979 0.65188073 0.99529967 -0.62425391 -0.96636869 12 0.88797507 1.19679628 1.10295855 -3.14143767 -1.49926392 0.54050300 Jul Aug Sep Oct Nov Dec 1 -0.58232289 -0.16511589 -0.07656594 -0.05754884 0.79013300 -0.72271352 2 -1.96236913 0.38685803 0.88125190 -0.70647705 -0.19462341 0.75868425 3 0.02627503 -0.84870391 0.65867451 0.13045947 0.01872435 -0.85023328 4 -0.80336100 3.18703052 0.64365316 1.79672960 1.19247275 -0.62779602 5 0.25595995 0.03061883 1.67437550 -2.20848583 0.35608362 0.05192152 6 0.04256581 -0.84851620 -0.19034249 -0.89687401 0.64613626 -0.71987828 7 0.88271200 -0.66703763 1.54342612 1.16371291 -0.60909508 -0.98339600 8 0.60438696 0.13395288 0.03441858 0.85926100 1.03310020 -0.62260487 9 -0.98092762 1.49604054 0.32701032 0.92561437 1.05166056 1.07772845 10 -0.83643520 -0.16336787 0.82499708 0.18759009 -0.79324775 -1.84621236 11 -0.19227900 -0.02851343 0.85212482 0.19195212 0.05227258 0.86871175 12 -0.72044036 -0.98677834 > 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/rcomp/tmp/1rpfa1324297628.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/rcomp/tmp/250l71324297628.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/rcomp/tmp/384qt1324297628.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/rcomp/tmp/4bvoc1324297628.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/rcomp/tmp/59pfw1324297628.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/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/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/rcomp/tmp/62ktr1324297628.tab") > > try(system("convert tmp/1rpfa1324297628.ps tmp/1rpfa1324297628.png",intern=TRUE)) character(0) > try(system("convert tmp/250l71324297628.ps tmp/250l71324297628.png",intern=TRUE)) character(0) > try(system("convert tmp/384qt1324297628.ps tmp/384qt1324297628.png",intern=TRUE)) character(0) > try(system("convert tmp/4bvoc1324297628.ps tmp/4bvoc1324297628.png",intern=TRUE)) character(0) > try(system("convert tmp/59pfw1324297628.ps tmp/59pfw1324297628.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.270 0.190 2.441