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(106370,109375,116476,123297,114813,117925,126466,131235,120546,123791,129813,133463,122987,125418,130199,133016,121454,122044,128313,131556,120027,123001,130111,132524,123742,124931,133646,136557,127509,128945,137191,139716,129083,131604,139413,143125,133948,137116,144864,149277,138796,143258,150034,154708,144888,148762,156500,161088,152772,158011,163318,169969,162269,165765,170600,174681,166364,170240,176150,182056,172218,177856,182253,188090,176863,183273,187969,194650,183036,189516,193805,200499,188142,193732,197126,205140,191751,196700,199784,207360,196101,200824,205743,212489,200810,203683,207286,210910,194915,217920) > par1 = '4' > #'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 655448.3 67048.6 1388580.3 0.0 > m$fitted level slope sea 1 Q1 106370.0 0.00000 0.0000 1 Q2 108922.6 728.11749 452.3639 1 Q3 112678.7 1500.84894 3797.2833 1 Q4 117660.8 2302.65565 5636.1869 2 Q1 120021.8 2313.72370 -5208.8444 2 Q2 121405.8 2120.59312 -3480.7742 2 Q3 123781.0 2176.91281 2685.0277 2 Q4 125777.0 2136.47201 5457.9686 3 Q1 126700.8 1866.19469 -6154.8380 3 Q2 127779.2 1690.53240 -3988.2282 3 Q3 128095.5 1383.32856 1717.5186 3 Q4 128155.0 1086.98611 5308.0483 4 Q1 128596.1 942.37607 -5609.1028 4 Q2 128877.5 794.36914 -3459.5078 4 Q3 128609.4 556.42935 1589.6242 4 Q4 128067.6 310.47317 4948.4038 5 Q1 127295.0 67.90532 -5841.0301 5 Q2 125935.3 -251.85458 -3891.2592 5 Q3 125477.4 -297.98471 2835.5578 5 Q4 125373.0 -254.64525 6183.0407 6 Q1 125119.4 -254.40464 -5092.3883 6 Q2 125741.6 -58.06994 -2740.5740 6 Q3 126628.3 153.54250 3482.6943 6 Q4 126863.1 171.74559 5660.8792 7 Q1 128166.6 425.23608 -4424.6435 7 Q2 128657.5 439.94382 -3726.5462 7 Q3 129716.0 578.48173 3929.9700 7 Q4 130981.5 732.34860 5575.5080 8 Q1 132029.8 803.11441 -4520.7937 8 Q2 133045.1 850.63674 -4100.0845 8 Q3 133856.1 841.77303 3334.8532 8 Q4 134538.4 806.03781 5177.6298 9 Q1 134579.5 634.72061 -5496.5161 9 Q2 135250.2 642.76456 -3646.1511 9 Q3 135871.8 638.02487 3541.2460 9 Q4 136962.9 739.52100 6162.0642 10 Q1 138585.2 937.23373 -4637.1988 10 Q2 140299.5 1111.26743 -3183.4530 10 Q3 141728.8 1182.51237 3135.1873 10 Q4 143362.1 1283.46755 5914.9332 11 Q1 144419.0 1232.73928 -5623.0443 11 Q2 146080.7 1328.81395 -2822.7349 11 Q3 147360.7 1317.87335 2673.2984 11 Q4 148703.6 1323.48497 6004.3705 12 Q1 150351.8 1396.21781 -5463.8499 12 Q2 151732.5 1392.72085 -2970.4546 12 Q3 153473.5 1470.72863 3026.5377 12 Q4 155158.7 1518.76905 5929.3196 13 Q1 157450.1 1691.81827 -4678.0744 13 Q2 160234.9 1936.61737 -2223.8645 13 Q3 161681.3 1826.83700 1636.6623 13 Q4 163940.3 1923.61808 6028.7200 14 Q1 166666.2 2103.32244 -4397.2368 14 Q2 168504.4 2043.93969 -2739.4289 14 Q3 169965.4 1913.36252 634.6285 14 Q4 170485.2 1601.24600 4195.7946 15 Q1 171081.3 1376.11181 -4717.2790 15 Q2 172206.2 1319.85161 -1966.2019 15 Q3 173924.2 1409.02986 2225.7861 15 Q4 176275.4 1620.04327 5780.6298 16 Q1 177635.2 1561.77241 -5417.2475 16 Q2 179611.4 1654.57386 -1755.3571 16 Q3 181006.8 1596.54480 1246.1555 16 Q4 182391.7 1549.12934 5698.3099 17 Q1 183230.8 1390.09921 -6367.7864 17 Q2 184571.6 1379.05627 -1298.5815 17 Q3 186167.3 1427.57515 1801.7366 17 Q4 188066.9 1533.29778 6583.1342 18 Q1 189618.2 1537.34668 -6582.2410 18 Q2 191104.8 1525.96671 -1588.7788 18 Q3 192458.1 1487.30072 1346.8893 18 Q4 193896.0 1476.23488 6602.9950 19 Q1 195042.3 1402.34382 -6900.3332 19 Q2 195824.2 1263.36134 -2092.1522 19 Q3 196328.2 1093.28601 797.8338 19 Q4 197623.5 1138.53308 7516.5300 20 Q1 198528.1 1086.15289 -6777.1376 20 Q2 199026.4 954.47979 -2326.4003 20 Q3 199440.8 833.51605 343.1952 20 Q4 199855.1 739.62939 7504.8615 21 Q1 201334.6 905.34429 -5233.6469 21 Q2 202628.1 992.26910 -1804.0904 21 Q3 204464.4 1181.31272 1278.6041 21 Q4 205745.4 1203.63825 6743.6130 22 Q1 206739.7 1156.76057 -5929.7272 22 Q2 206991.9 954.15892 -3308.9179 22 Q3 206893.4 718.39501 392.5549 22 Q4 205710.0 292.41846 5200.0474 23 Q1 202968.4 -387.11280 -8053.4200 23 Q2 209875.6 1246.63555 8044.3815 > m$resid Qtr1 Qtr2 Qtr3 Qtr4 1 0.0000000000 0.5397618034 1.8486338724 3.2237151189 2 0.0542558686 -0.8361493632 0.2202129565 -0.1562031198 3 -1.0523116084 -0.6830421977 -1.1898092054 -1.1452725011 4 -0.5586989977 -0.5717970865 -0.9191084832 -0.9499552723 5 -0.9368170306 -1.2349197353 -0.1781541609 0.1673755199 6 0.0009291986 0.7582334684 0.8172346303 0.0702991826 7 0.9789644681 0.0568003552 0.5350246606 0.5942241133 8 0.2732930540 0.1835282483 -0.0342310881 -0.1380071492 9 -0.6616161596 0.0310652281 -0.0183043821 0.3919716049 10 0.7635540298 0.6721070761 0.2751434535 0.3898824825 11 -0.1959093596 0.3710342810 -0.0422518962 0.0216717224 12 0.2808896006 -0.0135050349 0.3012610680 0.1855290619 13 0.6683051042 0.9453985578 -0.4239647983 0.3737623952 14 0.6940068307 -0.2293324280 -0.5042807310 -1.2053741775 15 -0.8694539499 -0.2172733036 0.3444007370 0.8149203797 16 -0.2250383853 0.3583933312 -0.2241045585 -0.1831154843 17 -0.6141642848 -0.0426471320 0.1873768569 0.4082940904 18 0.0156365960 -0.0439487288 -0.1493256013 -0.0427355940 19 -0.2853625777 -0.5367414806 -0.6568201484 0.1747413275 20 -0.2022889845 -0.5085131390 -0.4671542681 -0.3625843273 21 0.6399804252 0.3356980773 0.7300744444 0.0862198099 22 -0.1810386478 -0.7824346963 -0.9105052504 -1.6450943691 23 -2.6243065754 6.3094323478 > 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/1d7u01259938389.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/2zo061259938389.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/3udl41259938389.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/4ylea1259938389.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/5metg1259938389.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/665zj1259938389.tab") > > system("convert tmp/1d7u01259938389.ps tmp/1d7u01259938389.png") > system("convert tmp/2zo061259938389.ps tmp/2zo061259938389.png") > system("convert tmp/3udl41259938389.ps tmp/3udl41259938389.png") > system("convert tmp/4ylea1259938389.ps tmp/4ylea1259938389.png") > system("convert tmp/5metg1259938389.ps tmp/5metg1259938389.png") > > > proc.time() user system elapsed 1.353 0.831 2.942