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(0.95,0.96,0.95,0.95,0.95,0.97,0.96,0.96,0.95,0.98,0.98,0.99,0.98,1.00,0.98,0.97,0.98,0.98,0.98,0.98,0.98,0.97,0.98,0.98,0.96,0.95,0.96,0.97,0.97,0.97,0.97,0.97,0.98,0.99,1.00,1.00,0.98,0.98,0.98,1.00,1.00,1.00,1.00,0.99,0.99,1.00,1.00,0.97,1.00,1.01,1.01,1.00,1.00,1.01,1.01,1.02,1.00,1.00,1.01,1.02,0.99,1.00,1.01,1.01,1.01,1.01,1.01,1.01,1.02,1.02,1.01,1.02,1.02,1.03,1.03,1.05,1.01,1.02,1.02,1.03,1.03,1.04,1.03,1.02,1.02,1.03,1.04,1.04,1.03,0.99,1.03,1.04,1.03,1.04,1.03,1.03,1.03,1.01,1.00,1.01,1.01,1.03,1.02,1.03,1.03,1.02,1.02,1.03,1.02,1.02,1.03,1.02,1.00,1.00,1.01,1.01,1.03,1.01,1.02,1.02,1.04,1.04,1.05,1.05,1.06,1.05,1.05,1.04,1.02,1.02,1.02,1.05,1.05,1.05,1.06,1.02,1.02,1.05,1.05,1.04) > 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 3.385872e-05 0.000000e+00 0.000000e+00 7.881024e-05 > m$fitted level slope sea Jan 1 0.9500000 0.0000000000 0.0000000000 Feb 1 0.9555684 0.0004689251 0.0004689251 Mar 1 0.9527519 0.0002895049 0.0002895049 Apr 1 0.9514156 0.0002270027 0.0002270027 May 1 0.9507423 0.0002001197 0.0002001197 Jun 1 0.9599687 0.0004279923 0.0004279923 Jul 1 0.9600031 0.0004190654 0.0004190654 Aug 1 0.9600212 0.0004105772 0.0004105772 Sep 1 0.9552678 0.0003061968 0.0003061968 Oct 1 0.9670572 0.0005306398 0.0005306398 Nov 1 0.9732433 0.0006382787 0.0006382787 Dec 1 0.9812489 0.0007753581 0.0007753581 Jan 2 0.9840038 0.0005842477 -0.0064267245 Feb 2 0.9925329 0.0008754358 0.0008754358 Mar 2 0.9863359 0.0007034740 0.0007034740 Apr 2 0.9784735 0.0005541970 0.0005541970 May 2 0.9792277 0.0005569467 0.0005569467 Jun 2 0.9796218 0.0005550283 0.0005550283 Jul 2 0.9798284 0.0005512967 0.0005512967 Aug 2 0.9799368 0.0005468182 0.0005468182 Sep 2 0.9799935 0.0005420364 0.0005420364 Oct 2 0.9752681 0.0004918263 0.0004918263 Nov 2 0.9775421 0.0005085316 0.0005085316 Dec 2 0.9787356 0.0005148689 0.0005148689 Jan 3 0.9741462 0.0007471138 -0.0082182522 Feb 3 0.9617453 0.0004340972 0.0004340972 Mar 3 0.9609045 0.0004140726 0.0004140726 Apr 3 0.9652868 0.0004588437 0.0004588437 May 3 0.9675570 0.0004750205 0.0004750205 Jun 3 0.9687429 0.0004804813 0.0004804813 Jul 3 0.9693643 0.0004814688 0.0004814688 Aug 3 0.9696902 0.0004804354 0.0004804354 Sep 3 0.9746148 0.0005090183 0.0005090183 Oct 3 0.9819528 0.0005520624 0.0005520624 Nov 3 0.9905576 0.0006021367 0.0006021367 Dec 3 0.9950751 0.0006262395 0.0006262395 Jan 4 0.9921326 0.0007324559 -0.0080570153 Feb 4 0.9860337 0.0006120239 0.0006120239 Mar 4 0.9831303 0.0005712423 0.0005712423 Apr 4 0.9912296 0.0006340367 0.0006340367 May 4 0.9954396 0.0006576896 0.0006576896 Jun 4 0.9976414 0.0006664910 0.0006664910 Jul 4 0.9987956 0.0006690324 0.0006690324 Aug 4 0.9946477 0.0006452098 0.0006452098 Sep 4 0.9924707 0.0006316736 0.0006316736 Oct 4 0.9960801 0.0006456935 0.0006456935 Nov 4 0.9979749 0.0006515044 0.0006515044 Dec 4 0.9847138 0.0005873290 0.0005873290 Jan 5 0.9942070 0.0003903796 -0.0042941754 Feb 5 1.0020508 0.0004947046 0.0004947046 Mar 5 1.0059028 0.0005255798 0.0005255798 Apr 5 1.0031052 0.0005035913 0.0005035913 May 5 1.0016501 0.0004933040 0.0004933040 Jun 5 1.0056458 0.0005091731 0.0005091731 Jul 5 1.0077408 0.0005157491 0.0005157491 Aug 5 1.0135927 0.0005367695 0.0005367695 Sep 5 1.0071601 0.0005101172 0.0005101172 Oct 5 1.0037832 0.0004955116 0.0004955116 Nov 5 1.0067617 0.0005047390 0.0005047390 Dec 5 1.0130769 0.0005261688 0.0005261688 Jan 6 1.0059261 0.0006612320 -0.0072735518 Feb 6 1.0030162 0.0006197856 0.0006197856 Mar 6 1.0063995 0.0006408368 0.0006408368 Apr 6 1.0081473 0.0006469061 0.0006469061 May 6 1.0090603 0.0006480649 0.0006480649 Jun 6 1.0095389 0.0006474277 0.0006474277 Jul 6 1.0097900 0.0006460631 0.0006460631 Aug 6 1.0099218 0.0006443799 0.0006443799 Sep 6 1.0147426 0.0006576594 0.0006576594 Oct 6 1.0172732 0.0006635149 0.0006635149 Nov 6 1.0138506 0.0006508734 0.0006508734 Dec 6 1.0168046 0.0006579494 0.0006579494 Jan 7 1.0217421 0.0005954381 -0.0065498189 Feb 7 1.0258004 0.0006297635 0.0006297635 Mar 7 1.0278419 0.0006389420 0.0006389420 Apr 7 1.0384413 0.0006855649 0.0006855649 May 7 1.0249391 0.0006327870 0.0006327870 Jun 7 1.0226218 0.0006233087 0.0006233087 Jul 7 1.0214066 0.0006178960 0.0006178960 Aug 7 1.0255206 0.0006276848 0.0006276848 Sep 7 1.0276801 0.0006318530 0.0006318530 Oct 7 1.0335648 0.0006459125 0.0006459125 Nov 7 1.0319034 0.0006397982 0.0006397982 Dec 7 1.0262801 0.0006233092 0.0006233092 Jan 8 1.0268826 0.0006235694 -0.0068592631 Feb 8 1.0284189 0.0006314649 0.0006314649 Mar 8 1.0339980 0.0006595207 0.0006595207 Apr 8 1.0368902 0.0006686376 0.0006686376 May 8 1.0336444 0.0006559296 0.0006559296 Jun 8 1.0129285 0.0005959819 0.0005959819 Jul 8 1.0210708 0.0006153847 0.0006153847 Aug 8 1.0300955 0.0006359551 0.0006359551 Sep 8 1.0300818 0.0006344101 0.0006344101 Oct 8 1.0348254 0.0006440255 0.0006440255 Nov 8 1.0325651 0.0006372948 0.0006372948 Dec 8 1.0313783 0.0006330936 0.0006330936 Jan 9 1.0342235 0.0006089698 -0.0066986677 Feb 9 1.0224548 0.0005139921 0.0005139920 Mar 9 1.0117208 0.0004574376 0.0004574376 Apr 9 1.0109222 0.0004528890 0.0004528890 May 9 1.0105056 0.0004503848 0.0004503848 Jun 9 1.0197943 0.0004723832 0.0004723832 Jul 9 1.0199155 0.0004715817 0.0004715817 Aug 9 1.0247303 0.0004810142 0.0004810142 Sep 9 1.0272578 0.0004853363 0.0004853363 Oct 9 1.0238341 0.0004772109 0.0004772109 Nov 9 1.0220365 0.0004725267 0.0004725267 Dec 9 1.0258432 0.0004793517 0.0004793517 Jan 10 1.0258505 0.0004839199 -0.0053231185 Feb 10 1.0230254 0.0004611053 0.0004611053 Mar 10 1.0263830 0.0004741867 0.0004741867 Apr 10 1.0233646 0.0004628246 0.0004628246 May 10 1.0122747 0.0004329306 0.0004329306 Jun 10 1.0064619 0.0004189592 0.0004189592 Jul 10 1.0081639 0.0004215914 0.0004215914 Aug 10 1.0090572 0.0004225125 0.0004225125 Sep 10 1.0190276 0.0004406469 0.0004406469 Oct 10 1.0147610 0.0004318456 0.0004318456 Nov 10 1.0172713 0.0004356962 0.0004356962 Dec 10 1.0185893 0.0004373215 0.0004373215 Jan 11 1.0306837 0.0003359041 -0.0036949448 Feb 11 1.0352065 0.0003621114 0.0003621114 Mar 11 1.0422970 0.0003896914 0.0003896914 Apr 11 1.0459841 0.0003994285 0.0003994285 May 11 1.0526689 0.0004141944 0.0004141944 Jun 11 1.0514209 0.0004108181 0.0004108181 Jul 11 1.0507662 0.0004088328 0.0004088328 Aug 11 1.0456717 0.0003990709 0.0003990709 Sep 11 1.0334960 0.0003773719 0.0003773719 Oct 11 1.0271036 0.0003658701 0.0003658701 Nov 11 1.0237474 0.0003596030 0.0003596030 Dec 11 1.0362362 0.0003799125 0.0003799125 Jan 12 1.0445916 0.0003168958 -0.0034858541 Feb 12 1.0472172 0.0003301275 0.0003301275 Mar 12 1.0533414 0.0003518689 0.0003518689 Apr 12 1.0374828 0.0003080442 0.0003080442 May 12 1.0291849 0.0002895318 0.0002895318 Jun 12 1.0390914 0.0003074216 0.0003074216 Jul 12 1.0442897 0.0003157683 0.0003157683 Aug 12 1.0422675 0.0003119693 0.0003119693 > m$resid Jan Feb Mar Apr May 1 0.000000000 0.709095224 -0.501080838 -0.263484623 -0.149525515 2 0.447188651 1.113635714 -1.129524391 -1.425633008 0.033797990 3 -1.010927862 -1.990600230 -0.209112361 0.668046020 0.307856218 4 -0.675084727 -1.070803410 -0.583847570 1.274238641 0.609525250 5 1.645677503 1.191629711 0.561617418 -0.564290562 -0.334426366 6 -1.398544615 -0.578291459 0.464456569 0.188355023 0.045478282 7 0.772205345 0.565785090 0.238059296 1.697282105 -2.427042020 8 -0.003733402 0.150117617 0.836334518 0.380862376 -0.670023911 9 0.394392496 -2.046110453 -1.904916961 -0.214449434 -0.148905535 10 -0.083809740 -0.549213658 0.491284387 -0.596697331 -1.979052500 11 2.063208870 0.697188615 1.142617635 0.563657666 1.077039204 12 1.407862949 0.385473559 0.984937107 -2.772263542 -1.475062751 Jun Jul Aug Sep Oct 1 1.515863899 -0.066463088 -0.067887468 -0.875700038 1.949032860 2 -0.027686033 -0.059379099 -0.075581651 -0.083679898 -0.899789997 3 0.121288506 0.024074165 -0.026613770 0.760553204 1.168920284 4 0.263955096 0.083469341 -0.824968638 -0.483482154 0.510216128 5 0.599367621 0.271650632 0.914520527 -1.194732291 -0.666421595 6 -0.029024770 -0.067919554 -0.088173537 0.716237915 0.321254952 7 -0.505456048 -0.315236208 0.599656433 0.262782584 0.901205371 8 -3.663224566 1.294279937 1.442723072 -0.111471308 0.705147053 9 1.515382176 -0.060246500 0.745284217 0.351219819 -0.670922111 10 -1.071119558 0.220143473 0.080960377 1.638823485 -0.808022513 11 -0.285107189 -0.182855642 -0.944618261 -2.158612374 -1.162175498 12 1.649865380 0.839406030 -0.401338784 Nov Dec 1 0.960430794 1.251646250 2 0.304488600 0.117058683 3 1.378595374 0.670329939 4 0.214041570 -2.384190050 5 0.425742512 0.996294243 6 -0.700879502 0.395064260 7 -0.395879861 -1.074603375 8 -0.498409952 -0.313040389 9 -0.390442524 0.572277377 10 0.356792033 0.151456610 11 -0.638996711 2.082349218 12 > 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/1u4cw1324298195.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/28yvf1324298195.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/37aae1324298195.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/4gwbq1324298195.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/50zc91324298195.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/6ijzz1324298195.tab") > > try(system("convert tmp/1u4cw1324298195.ps tmp/1u4cw1324298195.png",intern=TRUE)) character(0) > try(system("convert tmp/28yvf1324298195.ps tmp/28yvf1324298195.png",intern=TRUE)) character(0) > try(system("convert tmp/37aae1324298195.ps tmp/37aae1324298195.png",intern=TRUE)) character(0) > try(system("convert tmp/4gwbq1324298195.ps tmp/4gwbq1324298195.png",intern=TRUE)) character(0) > try(system("convert tmp/50zc91324298195.ps tmp/50zc91324298195.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.230 0.325 2.575