Home » date » 2009 » Dec » 04 »

WS 9: Structural Time Series Models

*The author of this computation has been verified*
R Software Module: /rwasp_structuraltimeseries.wasp (opens new window with default values)
Title produced by software: Structural Time Series Models
Date of computation: Fri, 04 Dec 2009 10:20:25 -0700
 
Cite this page as follows:
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL http://www.freestatistics.org/blog/date/2009/Dec/04/t1259947284gsa2gz0yu1ojto8.htm/, Retrieved Fri, 04 Dec 2009 18:21:30 +0100
 
BibTeX entries for LaTeX users:
@Manual{KEY,
    author = {{YOUR NAME}},
    publisher = {Office for Research Development and Education},
    title = {Statistical Computations at FreeStatistics.org, URL http://www.freestatistics.org/blog/date/2009/Dec/04/t1259947284gsa2gz0yu1ojto8.htm/},
    year = {2009},
}
@Manual{R,
    title = {R: A Language and Environment for Statistical Computing},
    author = {{R Development Core Team}},
    organization = {R Foundation for Statistical Computing},
    address = {Vienna, Austria},
    year = {2009},
    note = {{ISBN} 3-900051-07-0},
    url = {http://www.R-project.org},
}
 
Original text written by user:
 
IsPrivate?
No (this computation is public)
 
User-defined keywords:
 
Dataseries X:
» Textbox « » Textfile « » CSV «
114 116 153 162 161 149 139 135 130 127 122 117 112 113 149 157 157 147 137 132 125 123 117 114 111 112 144 150 149 134 123 116 117 111 105 102 95 93 124 130 124 115 106 105 105 101 95 93 84 87 116 120 117 109 105 107 109 109 108 107
 
Output produced by software:


Summary of computational transaction
Raw Inputview raw input (R code)
Raw Outputview raw output of R engine
Computing time2 seconds
R Server'Gwilym Jenkins' @ 72.249.127.135


Structural Time Series Model
tObservedLevelSlopeSeasonalStand. Residuals
1114114000
2116115.7026437408451.668960468880630.2973562591550590.294876726859141
3153146.49497785324623.65046647833826.505022146753493.77191065445581
4162164.65714760300919.3405364523551-2.6571476030092-0.69617385229692
5161164.2714171600314.13027010648658-3.27141716003076-2.4403014219544
6149151.006279203135-9.3017669835315-2.00627920313463-2.16432047714572
7139138.323670309618-11.91612786712010.676329690382264-0.420844255351675
8135133.119291410535-6.725889410026041.880708589465050.835509735540786
9130129.442698120416-4.368222447098080.5573018795841540.379530882275775
10127126.544976299828-3.231335842887380.4550237001718930.183011992933156
11122122.008616712248-4.24029804266581-0.0086167122483617-0.162419293972219
12117116.782540539251-5.002452152830870.217459460748732-0.122688952034130
13112112.417809433571-4.51082158791396-0.4178094335711760.0797002276452974
14113118.4835167813243.61573463897883-5.483516781324221.32125872853874
15149139.91774085360516.78628739346679.082259146394852.12504634107215
16157157.0343970509917.0329433309658-0.03439705099007630.0401053876743118
17157159.5560409496446.22144182377092-2.55604094964360-1.73463267004782
18147150.467136773757-5.139067873983-3.46713677375708-1.82834303326795
19137138.280202614551-10.3766718097926-1.28020261455135-0.843443575154147
20132129.811872949628-8.957616860013012.188127050372480.228425326005112
21125124.153732206407-6.504085938529140.8462677935927290.394959976351661
22123121.586522854044-3.576715612585891.413477145956070.471252261252070
23117116.666836395995-4.575084363622750.333163604005065-0.160713623635738
24114112.455631237544-4.304823073105491.544368762455570.0435266137913398
25111112.398667599700-1.14896725404076-1.398667599700200.509762418788215
26112120.9758312566616.07006972133675-8.97583125666071.16243049710649
27144135.12861592344411.99740077394068.871384076555560.954012623437767
28150147.55849249607612.3153389168662.441507503924300.0514565998105306
29149150.0418808995745.07198310554524-1.04188089957386-1.16503410900246
30134138.676504476299-6.99633976396462-4.67650447629897-1.94055268562018
31123125.333643000286-11.6566246577464-2.33364300028565-0.750425480833146
32116114.236926366921-11.24510111325961.763073633079300.0662493528025322
33117114.576090563726-2.729018461281212.42390943627441.37086005291596
34111109.638847384399-4.352225478965441.36115261560106-0.261311896628606
35105104.071272001815-5.245138250111380.928727998185038-0.143739878147149
36102100.340981746844-4.132906239371571.659018253156180.179184125883452
379598.3374693017223-2.56826323028658-3.337469301722270.252346669507806
3893103.3607339535003.00199029217631-10.36073395350020.896112984635853
39124114.9892230326869.295292119960989.010776967313691.01286248787740
40130125.74730918408410.36345826397524.252690815915650.172462513077168
41124123.4715441862861.113876713222380.528455813714395-1.48917829627881
42115118.488865605073-3.33897121051313-3.48886560507335-0.716038457862916
43106109.459149885785-7.49292439364667-3.45914988578483-0.668697041568339
44105105.487422199554-4.92067445616287-0.4874221995540880.414114902367592
45105101.738001347294-4.064761747235963.261998652705970.137779693616591
4610198.6953085037839-3.317949823248522.304691496216140.120221876332748
479594.026392137282-4.304585888139390.973607862717959-0.158838137405740
489390.8887679874983-3.452539231056052.111232012501690.137265939991958
498489.0008258798454-2.30945510230920-5.000825879845360.184197483755488
508798.04956702532445.97745504760098-11.04956702532441.33313803269666
51116107.6658411848608.623456873617888.334158815139670.425883314652667
52120113.4476400742666.556110484824966.55235992573387-0.333400597719954
53117115.6881114002413.411044377424431.31188859975868-0.50649753193152
54109112.283608379213-1.55095811849093-3.28360837921311-0.798135745454033
55105109.550869706606-2.41067338075168-4.55086970660589-0.138366145542324
56107107.751506809735-1.96576160857763-0.7515068097350460.0716254325462566
57109105.873779996985-1.901665249720713.126220003015350.0103180083492711
58109105.538888642367-0.761019145923123.461111357633410.183618737321425
59108106.2737760021880.3276421450075291.726223997812440.17527493814258
60107105.196236799355-0.6950109657707061.80376320064542-0.164730001410012
 
Charts produced by software:
http://www.freestatistics.org/blog/date/2009/Dec/04/t1259947284gsa2gz0yu1ojto8/1cyb31259947223.png (open in new window)
http://www.freestatistics.org/blog/date/2009/Dec/04/t1259947284gsa2gz0yu1ojto8/1cyb31259947223.ps (open in new window)


http://www.freestatistics.org/blog/date/2009/Dec/04/t1259947284gsa2gz0yu1ojto8/2t70a1259947223.png (open in new window)
http://www.freestatistics.org/blog/date/2009/Dec/04/t1259947284gsa2gz0yu1ojto8/2t70a1259947223.ps (open in new window)


http://www.freestatistics.org/blog/date/2009/Dec/04/t1259947284gsa2gz0yu1ojto8/3yfwy1259947223.png (open in new window)
http://www.freestatistics.org/blog/date/2009/Dec/04/t1259947284gsa2gz0yu1ojto8/3yfwy1259947223.ps (open in new window)


http://www.freestatistics.org/blog/date/2009/Dec/04/t1259947284gsa2gz0yu1ojto8/4n9xd1259947223.png (open in new window)
http://www.freestatistics.org/blog/date/2009/Dec/04/t1259947284gsa2gz0yu1ojto8/4n9xd1259947223.ps (open in new window)


http://www.freestatistics.org/blog/date/2009/Dec/04/t1259947284gsa2gz0yu1ojto8/5yuef1259947223.png (open in new window)
http://www.freestatistics.org/blog/date/2009/Dec/04/t1259947284gsa2gz0yu1ojto8/5yuef1259947223.ps (open in new window)


 
Parameters (Session):
par1 = FALSE ; par2 = 0.5 ; par3 = 1 ; par4 = 1 ; par5 = 12 ; par6 = 3 ; par7 = 1 ; par8 = 2 ; par9 = 1 ;
 
Parameters (R input):
par1 = 12 ; par2 = 0.5 ; par3 = 1 ; par4 = 1 ; par5 = 12 ; par6 = 3 ; par7 = 1 ; par8 = 2 ; par9 = 1 ;
 
R code (references can be found in the software module):
par1 <- as.numeric(par1)
nx <- length(x)
x <- ts(x,frequency=par1)
m <- StructTS(x,type='BSM')
m$coef
m$fitted
m$resid
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
bitmap(file='test2.png')
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()
bitmap(file='test3.png')
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()
bitmap(file='test4.png')
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()
bitmap(file='test1.png')
plot(as.numeric(m$resid),main='Standardized Residuals',ylab='Residuals',xlab='time',type='b')
grid()
dev.off()
bitmap(file='test5.png')
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()
load(file='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='mytable.tab')
 





Copyright

Creative Commons License

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 License.

Software written by Ed van Stee & Patrick Wessa


Disclaimer

Information provided on this web site is provided "AS IS" without warranty of any kind, either express or implied, including, without limitation, warranties of merchantability, fitness for a particular purpose, and noninfringement. We use reasonable efforts to include accurate and timely information and periodically update the information, and software without notice. However, we make no warranties or representations as to the accuracy or completeness of such information (or software), and we assume no liability or responsibility for errors or omissions in the content of this web site, or any software bugs in online applications. Your use of this web site is AT YOUR OWN RISK. Under no circumstances and under no legal theory shall we be liable to you or any other person for any direct, indirect, special, incidental, exemplary, or consequential damages arising from your access to, or use of, this web site.


Privacy Policy

We may request personal information to be submitted to our servers in order to be able to:

  • personalize online software applications according to your needs
  • enforce strict security rules with respect to the data that you upload (e.g. statistical data)
  • manage user sessions of online applications
  • alert you about important changes or upgrades in resources or applications

We NEVER allow other companies to directly offer registered users information about their products and services. Banner references and hyperlinks of third parties NEVER contain any personal data of the visitor.

We do NOT sell, nor transmit by any means, personal information, nor statistical data series uploaded by you to third parties.

We carefully protect your data from loss, misuse, alteration, and destruction. However, at any time, and under any circumstance you are solely responsible for managing your passwords, and keeping them secret.

We store a unique ANONYMOUS USER ID in the form of a small 'Cookie' on your computer. This allows us to track your progress when using this website which is necessary to create state-dependent features. The cookie is used for NO OTHER PURPOSE. At any time you may opt to disallow cookies from this website - this will not affect other features of this website.

We examine cookies that are used by third-parties (banner and online ads) very closely: abuse from third-parties automatically results in termination of the advertising contract without refund. We have very good reason to believe that the cookies that are produced by third parties (banner ads) do NOT cause any privacy or security risk.

FreeStatistics.org is safe. There is no need to download any software to use the applications and services contained in this website. Hence, your system's security is not compromised by their use, and your personal data - other than data you submit in the account application form, and the user-agent information that is transmitted by your browser - is never transmitted to our servers.

As a general rule, we do not log on-line behavior of individuals (other than normal logging of webserver 'hits'). However, in cases of abuse, hacking, unauthorized access, Denial of Service attacks, illegal copying, hotlinking, non-compliance with international webstandards (such as robots.txt), or any other harmful behavior, our system engineers are empowered to log, track, identify, publish, and ban misbehaving individuals - even if this leads to ban entire blocks of IP addresses, or disclosing user's identity.


FreeStatistics.org is powered by