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(5594,5585,5710,5511,5403,5826,5884,5965,5960,6064,6046,5954,5952,5960,5983,5996,6021,6094,6202,6276,6306,6342,6345,6328,6191,6261,6253,6198,6247,6293,6381,6448,6470,6516,6532,6526,6533,6498,6507,6464,6453,6468,6497,6808,6793,6907,6792,6757,6734,6654,6589,6469,6521,6448,6410,6528,6445,6458,6215,6167) > 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 9.071189e+03 -7.799719e-15 5.397731e+01 0.000000e+00 > m$fitted level slope sea Jan 1 5594.000 0.0000000 0.00000000 Feb 1 5585.493 -0.4657538 -0.49267698 Mar 1 5707.596 0.2055423 2.40370552 Apr 1 5515.605 -0.5358052 -4.60454454 May 1 5404.784 -0.9851507 -1.78353774 Jun 1 5817.444 0.6992995 8.55616078 Jul 1 5884.298 0.9675380 -0.29817441 Aug 1 5962.755 1.2804583 2.24458280 Sep 1 5959.275 1.2613097 0.72511976 Oct 1 6060.566 1.6620165 3.43384635 Nov 1 6045.286 1.5944191 0.71403368 Dec 1 5954.289 1.2264572 -0.28874461 Jan 2 5961.236 0.9861947 -9.23622505 Feb 2 5962.639 0.9960391 -2.63914710 Mar 2 5976.487 1.0443018 6.51326708 Apr 2 5994.441 1.0733210 1.55925633 May 2 6026.553 1.1331178 -5.55317114 Jun 2 6084.100 1.2439522 9.90033522 Jul 2 6199.965 1.4686168 2.03475663 Aug 2 6271.747 1.6061170 4.25268436 Sep 2 6306.390 1.6705804 -0.39034684 Oct 2 6338.083 1.7292349 3.91711682 Nov 2 6342.719 1.7351937 2.28110515 Dec 2 6328.633 1.7136994 -0.63342302 Jan 3 6230.442 3.5936948 -39.44176700 Feb 3 6260.534 3.9806250 0.46633096 Mar 3 6244.578 3.9110732 8.42233649 Apr 3 6196.117 3.8496217 1.88312088 May 3 6247.538 3.9113598 -0.53782626 Jun 3 6282.599 3.9540690 10.40060693 Jul 3 6374.751 4.0751818 6.24915800 Aug 3 6440.447 4.1595655 7.55266614 Sep 3 6468.667 4.1924496 1.33293054 Oct 3 6508.636 4.2421756 7.36429168 Nov 3 6527.246 4.2639961 4.75362890 Dec 3 6522.284 4.2609512 3.71629778 Jan 4 6572.701 3.7263567 -39.70053961 Feb 4 6501.308 2.9575296 -3.30752993 Mar 4 6496.311 2.9302867 10.68939421 Apr 4 6466.230 2.8969442 -2.22985319 May 4 6455.048 2.8828646 -2.04799084 Jun 4 6461.306 2.8865703 6.69407535 Jul 4 6492.719 2.9182720 4.28110036 Aug 4 6786.515 3.2403666 21.48546421 Sep 4 6798.260 3.2497885 -5.26041556 Oct 4 6896.636 3.3598321 10.36374462 Nov 4 6794.941 3.2285792 -2.94137495 Dec 4 6756.944 3.2391116 0.05607178 Jan 5 6764.614 3.2037619 -30.61414884 Feb 5 6662.829 2.4008884 -8.82892911 Mar 5 6581.283 2.1180031 7.71655902 Apr 5 6476.261 2.0114692 -7.26061029 May 5 6518.344 2.0449257 2.65623910 Jun 5 6445.217 1.9743202 2.78309819 Jul 5 6421.841 1.9498106 -11.84061408 Aug 5 6501.979 2.0252400 26.02148603 Sep 5 6461.630 1.9840433 -16.63030801 Oct 5 6444.848 1.9644835 13.15151361 Nov 5 6230.700 1.7370011 -15.69974683 Dec 5 6168.161 1.7762711 -1.16061801 > m$resid Jan Feb Mar Apr May Jun 1 0.000000000 -0.053719970 1.289642522 -2.022027424 -1.160245850 4.351689840 2 0.072383046 0.003749729 0.135025993 0.177714474 0.326200354 0.592866473 3 -1.147834731 0.254986690 -0.209267911 -0.550264578 0.499796953 0.327271255 4 0.512308066 -0.744530543 -0.083417941 -0.346814813 -0.147897197 0.035454581 5 0.048305069 -1.058084276 -0.879588107 -1.125601335 0.420925640 -0.789611983 Jul Aug Sep Oct Nov Dec 1 0.695967805 0.815204912 -0.050086086 1.052315718 -0.178230683 -0.974049435 2 1.204594475 0.738944706 0.347193814 0.315510014 0.030551417 -0.166196051 3 0.926622704 0.647407539 0.252781183 0.375880638 0.150986059 -0.096883414 4 0.299665872 3.055623323 0.089349205 0.999335938 -1.103813199 -0.432862674 5 -0.266285246 0.821294854 -0.445097907 -0.197135551 -2.270493740 -0.674976603 > 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/1g6oi1259932923.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/2j0bv1259932923.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/3844d1259932923.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/46nnx1259932923.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/56to61259932923.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/6m23e1259932923.tab") > > system("convert tmp/1g6oi1259932923.ps tmp/1g6oi1259932923.png") > system("convert tmp/2j0bv1259932923.ps tmp/2j0bv1259932923.png") > system("convert tmp/3844d1259932923.ps tmp/3844d1259932923.png") > system("convert tmp/46nnx1259932923.ps tmp/46nnx1259932923.png") > system("convert tmp/56to61259932923.ps tmp/56to61259932923.png") > > > proc.time() user system elapsed 1.543 0.819 2.021