R version 2.8.0 (2008-10-20) Copyright (C) 2008 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. Natural language support but running in an English locale 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(6.4,7.7,9.2,8.6,7.4,8.6,6.2,6,6.6,5.1,4.7,5,3.6,1.9,-0.1,-5.7,-5.6,-6.4,-7.7,-8,-11.9,-15.4,-15.5,-13.4,-10.9,-10.8,-7.3,-6.5,-5.1,-5.3,-6.8,-8.4,-8.4,-9.7,-8.8,-9.6,-11.5,-11,-14.9,-16.2,-14.4,-17.3,-15.7,-12.6,-9.4,-8.1,-5.4,-4.6,-4.9,-4,-3.1,-1.3,0,-0.4,3,0.4,1.2,0.6,-1.3,-3.2,-1.8,-3.6,-4.2,-6.9,-8,-7.5,-8.2,-7.6,-3.7,-1.7,-0.7,0.2,0.6,2.2,3.3,5.3,5.5,6.3,7.7,6.5,5.5,6.9,5.7,6.9,6.1,4.8,3.7,5.8,6.8,8.5,7.2,5,4.7,2.3,2.4,0.1,1.9,1.7,2,-1.9,0.5,-1.3,-3.3,-2.8,-8,-13.9,-21.9,-28.8,-27.6,-31.4,-31.8,-29.4,-27.6,-23.6,-22.8,-18.2,-17.8,-14.2,-8.8,-7.9,-7,-7,-3.6,-2.4,-4.9,-7.7,-6.5,-5.1,-3.4,-2.8,0.8) > 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 2.184832e+00 7.665767e-01 -6.713582e-18 2.134371e-01 > m$fitted level slope sea Jan 1 6.40000000 0.000000000 0.0000000000 Feb 1 7.60380276 0.188796934 0.0604662722 Mar 1 9.07312203 0.662406616 0.0561872798 Apr 1 8.59632044 0.193158021 0.0613129984 May 1 7.40350210 -0.394641488 0.0650883023 Jun 1 8.46547351 0.228867477 0.0628637482 Jul 1 6.25491170 -0.818608546 0.0649266988 Aug 1 5.91193628 -0.614145309 0.0647045035 Sep 1 6.47765405 -0.106729543 0.0644001999 Oct 1 5.09794107 -0.654293974 0.0645814307 Nov 1 4.62645398 -0.575654275 0.0645670658 Dec 1 4.89405022 -0.212890439 0.0645304932 Jan 2 4.41941639 -0.321731945 -0.8069968227 Feb 2 1.94423573 -1.166950006 0.0252698382 Mar 2 -0.08426403 -1.538701628 0.0264650528 Apr 2 -5.54233804 -3.227355523 0.0339688449 May 2 -5.77719360 -1.939964503 0.0305148566 Jun 2 -6.48994661 -1.412154207 0.0297227273 Jul 2 -7.73773419 -1.341458637 0.0296640449 Aug 2 -8.07860518 -0.911059861 0.0294667977 Sep 2 -11.79212916 -2.116607893 0.0297717431 Oct 2 -15.35864302 -2.740346296 0.0298588227 Nov 2 -15.65006617 -1.686812233 0.0297776454 Dec 2 -13.61264286 -0.084612179 0.0297095099 Jan 3 -11.14478799 0.996119280 0.1214257645 Feb 3 -10.75691756 0.749326187 -0.0198529805 Mar 3 -7.40538703 1.870996345 -0.0222013878 Apr 3 -6.43482493 1.483244236 -0.0210785320 May 3 -5.07305426 1.430985134 -0.0209872060 Jun 3 -5.20304078 0.759558706 -0.0203309688 Jul 3 -6.67081130 -0.198519469 -0.0198130800 Aug 3 -8.30963367 -0.818095594 -0.0196281758 Sep 3 -8.41531299 -0.511621850 -0.0196786583 Oct 3 -9.64507536 -0.820566534 -0.0196505714 Nov 3 -8.85922137 -0.129471846 -0.0196852476 Dec 3 -9.55262131 -0.372080372 -0.0196785292 Jan 4 -11.46453052 -1.027672832 0.0393711462 Feb 4 -11.07002749 -0.441588479 0.0116737741 Mar 4 -14.75475360 -1.838834180 0.0138428778 Apr 4 -16.23126555 -1.682846618 0.0135078482 May 4 -14.57547303 -0.246525566 0.0116465931 Jun 4 -17.19583594 -1.267643940 0.0123865772 Jul 4 -15.84073707 -0.139432325 0.0119344109 Aug 4 -12.76932999 1.241815061 0.0116287838 Sep 4 -9.51058980 2.109488807 0.0115228166 Oct 4 -8.07828001 1.818163001 0.0115424534 Nov 4 -5.45126039 2.166141339 0.0115295080 Dec 4 -4.54943715 1.622215110 0.0115406759 Jan 5 -4.55459618 0.927487517 -0.2660921895 Feb 5 -4.00484529 0.770409395 0.0209746349 Mar 5 -3.12622673 0.817015632 0.0209171449 Apr 5 -1.36645114 1.222835185 0.0202244543 May 5 -0.02594753 1.273457630 0.0201723287 Jun 5 -0.34249283 0.589489517 0.0205661624 Jul 5 2.85186032 1.710038002 0.0202093319 Aug 5 0.57529652 -0.004956924 0.0205108441 Sep 5 1.15099265 0.244840325 0.0204866046 Oct 5 0.61771613 -0.089911334 0.0205045327 Nov 5 -1.23398773 -0.847854808 0.0205269364 Dec 5 -3.16722050 -1.314799479 0.0205345540 Jan 6 -1.87838110 -0.201540844 -0.0487142006 Feb 6 -3.53065181 -0.808379389 -0.0058092299 Mar 6 -4.20090853 -0.748900758 -0.0058700947 Apr 6 -6.80430079 -1.547106872 -0.0047396933 May 6 -8.01180559 -1.401005531 -0.0048644987 Jun 6 -7.58453843 -0.614526156 -0.0052401816 Jul 6 -8.19496090 -0.612760822 -0.0052406479 Aug 6 -7.65147812 -0.115351409 -0.0053131928 Sep 6 -3.88521266 1.554533028 -0.0054476156 Oct 6 -1.72432473 1.815392396 -0.0054592051 Nov 6 -0.65776592 1.493234864 -0.0054513056 Dec 6 0.23494571 1.234881126 -0.0054478092 Jan 7 0.62870677 0.874860370 0.0123957377 Feb 7 2.16752930 1.153750519 0.0028744429 Mar 7 3.29824739 1.143833613 0.0028831140 Apr 7 5.25753634 1.494796236 0.0024584218 May 7 5.55590112 0.980074842 0.0028341027 Jun 7 6.30830630 0.882135426 0.0028740741 Jul 7 7.67345007 1.089919595 0.0028271765 Aug 7 6.60316127 0.160603151 0.0029429769 Sep 7 5.55632936 -0.358841798 0.0029787024 Oct 7 6.81747436 0.338093025 0.0029522475 Nov 7 5.76532419 -0.260007792 0.0029647778 Dec 7 6.83188050 0.310699654 0.0029581789 Jan 8 6.22203475 -0.083609625 -0.0770170873 Feb 8 4.85757011 -0.623280086 0.0002661480 Mar 8 3.72458667 -0.842716956 0.0004336230 Apr 8 5.66430653 0.354751223 -0.0008313181 May 8 6.76444058 0.675425527 -0.0010356250 Jun 8 8.45150938 1.110620831 -0.0011906636 Jul 8 7.31153852 0.142435952 -0.0009999166 Aug 8 5.11573987 -0.863472667 -0.0008905044 Sep 8 4.67989671 -0.679503564 -0.0009015489 Oct 8 2.38044988 -1.376421030 -0.0008784572 Nov 8 2.33548739 -0.803609500 -0.0008889323 Dec 8 0.16788299 -1.390420597 -0.0008830096 Jan 9 1.63030921 -0.167746499 0.1300987964 Feb 9 1.69989711 -0.067510730 -0.0107201924 Mar 9 1.99311651 0.087778081 -0.0108253432 Apr 9 -1.70492142 -1.541447132 -0.0092983155 May 9 0.33436082 -0.000965314 -0.0101691162 Jun 9 -1.21404532 -0.666658798 -0.0099587058 Jul 9 -3.22415734 -1.244604513 -0.0098576824 Aug 9 -2.86866966 -0.556241755 -0.0099241117 Sep 9 -7.77643154 -2.428300073 -0.0098243982 Oct 9 -13.71766486 -3.939605026 -0.0097799697 Nov 9 -21.69205832 -5.675427251 -0.0097518063 Dec 9 -28.72363860 -6.258864939 -0.0097465818 Jan 10 -28.28585637 -3.387581873 0.3580413814 Feb 10 -31.38206337 -3.264289592 -0.0313281963 Mar 10 -31.90265386 -2.083243563 -0.0320468874 Apr 10 -29.58246662 -0.188287265 -0.0336430537 May 10 -27.66909077 0.715879250 -0.0341023689 Jun 10 -23.72409081 2.105023320 -0.0344969494 Jul 10 -22.71190084 1.634890291 -0.0344230995 Aug 10 -18.30178817 2.828800530 -0.0345266393 Sep 10 -17.65818262 1.888710407 -0.0344816408 Oct 10 -14.24059927 2.546450222 -0.0344990171 Nov 10 -8.90260496 3.747412230 -0.0345165278 Dec 10 -7.73859457 2.635992992 -0.0345075840 Jan 11 -7.20577546 1.733918510 0.3087660630 Feb 11 -6.90042273 1.128503597 -0.0335042710 Mar 11 -3.66923126 2.033574900 -0.0340043515 Apr 11 -2.33204503 1.733901202 -0.0337751483 May 11 -4.66722987 -0.016680499 -0.0329676766 Jun 11 -7.52768289 -1.240056925 -0.0326521566 Jul 11 -6.57491771 -0.296708522 -0.0327867049 Aug 11 -5.15163860 0.443238211 -0.0328449706 Sep 11 -3.42992915 0.993248743 -0.0328688749 Oct 11 -2.75166243 0.857739495 -0.0328656244 Nov 11 0.70521015 1.975924177 -0.0328804279 > m$resid Jan Feb Mar Apr May 1 0.000000000 0.466507989 0.667912037 -0.567268452 -0.682808894 2 -0.146992399 -0.859979171 -0.422438483 -1.919441386 1.467971297 3 1.343741565 -0.263981666 1.276875577 -0.441486069 -0.059623645 4 -0.792636157 0.639489607 -1.591947032 0.177747858 1.639187033 5 -0.828188780 -0.173226027 0.053127470 0.462652016 0.057781794 6 1.315889695 -0.673673905 0.067823553 -0.910275863 0.166781878 7 -0.423138824 0.311009825 -0.011310926 0.400327640 -0.587624661 8 -0.461557479 -0.603802782 -0.250327106 1.366126229 0.366114278 9 1.426831133 0.112427028 0.177173006 -1.858933429 1.758847631 10 3.342755370 0.138558281 1.347632066 2.162352316 1.032369864 11 -1.048198610 -0.681448878 1.032822655 -0.341989071 -1.998857037 Jun Jul Aug Sep Oct 1 0.715807502 -1.198245345 0.233638492 0.579627785 -0.625427000 2 0.602529673 0.080732186 0.491555540 -1.376893748 -0.712398116 3 -0.766613257 -1.094155554 -0.707625438 0.350034922 -0.352859384 4 -1.165980528 1.288487128 1.577552076 0.991004476 -0.332736332 5 -0.781039579 1.279755142 -1.958741480 0.285303719 -0.382335123 6 0.898129607 0.002016172 0.568106331 1.907245551 0.297939457 7 -0.111845742 0.237310114 -1.061402747 -0.593280414 0.796001409 8 0.496997041 -1.105769041 -1.148883063 0.210119129 -0.795981707 9 -0.760238464 -0.660077593 0.786203940 -2.138160209 -1.726131568 10 1.586454244 -0.536945429 1.363609338 -1.073718641 0.751235257 11 -1.397153837 1.077414170 0.845121414 0.628191590 -0.154771431 Nov Dec 1 0.089819345 0.414331507 2 1.203289678 1.829948033 3 0.789331377 -0.277094646 4 0.397442330 -0.621243858 5 -0.865682796 -0.533319603 6 -0.367951262 -0.295078037 7 -0.683119102 0.651832008 8 0.654235047 -0.670224761 9 -1.982564449 -0.666371837 10 1.371675403 -1.269404603 11 1.277131542 > 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/freestat/rcomp/tmp/153hk1293189026.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/html/freestat/rcomp/tmp/2fuhn1293189026.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/html/freestat/rcomp/tmp/3fuhn1293189026.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/html/freestat/rcomp/tmp/48myq1293189026.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/html/freestat/rcomp/tmp/58myq1293189026.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/html/freestat/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/freestat/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/freestat/rcomp/tmp/6mdeh1293189026.tab") > > try(system("convert tmp/153hk1293189026.ps tmp/153hk1293189026.png",intern=TRUE)) character(0) > try(system("convert tmp/2fuhn1293189026.ps tmp/2fuhn1293189026.png",intern=TRUE)) character(0) > try(system("convert tmp/3fuhn1293189026.ps tmp/3fuhn1293189026.png",intern=TRUE)) character(0) > try(system("convert tmp/48myq1293189026.ps tmp/48myq1293189026.png",intern=TRUE)) character(0) > try(system("convert tmp/58myq1293189026.ps tmp/58myq1293189026.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.521 1.216 2.680