Home » date » 2009 » Dec » 04 »

Workshop 9: Structural time series model

*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 09:57:36 -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/t1259945985evxh8y9k85cdr8g.htm/, Retrieved Fri, 04 Dec 2009 17:59:52 +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/t1259945985evxh8y9k85cdr8g.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 «
267413 267366 264777 258863 254844 254868 277267 285351 286602 283042 276687 277915 277128 277103 275037 270150 267140 264993 287259 291186 292300 288186 281477 282656 280190 280408 276836 275216 274352 271311 289802 290726 292300 278506 269826 265861 269034 264176 255198 253353 246057 235372 258556 260993 254663 250643 243422 247105 248541 245039 237080 237085 225554 226839 247934 248333 246969 245098 246263 255765 264319 268347 273046 273963 267430 271993 292710 295881 293299
 
Output produced by software:


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


Structural Time Series Model
tObservedLevelSlopeSeasonalStand. Residuals
1267413267413000
2267366267384.357654688-30.1595068318717-18.3576546875851-0.0120573306031779
3264777265475.763074761-1230.64730462337-698.763074761267-0.387207780916152
4258863260376.173861343-3814.08699359233-1513.17386134343-0.872939958251469
5254844254967.296867130-4876.39017440018-123.296867129658-0.332923013120594
6254868253450.915489083-2679.709509652431417.084510916890.693250988131664
7277267270270.99146744710102.88450484356996.008532553124.05104096080793
8285351285788.00352167813660.7770413176-437.0035216783141.12545651843299
9286602290736.2763746377934.00112730939-4134.27637463657-1.81127216020215
10283042286687.50076563959.2377145686369-3645.50076563855-2.49085226920937
11276687278491.420276328-5364.70454217156-1804.42027632774-1.71558560645971
12277915275926.488391431-3525.347509766141988.511608568970.581783458681778
13277128275888.618919733-1242.353913331001239.381080267340.724897532317247
14277103276119.640050427-273.442006580221983.3599495725230.311502990853579
15275037274310.546622751-1256.50466219448726.453377248726-0.308218470510597
16270150270425.803219630-2914.36198059900-275.803219630438-0.531896063830159
17267140267870.660803246-2684.87710598065-730.6608032457810.073090659271585
18264993269620.758930962131.330768791653-4627.7589309620.886951137946173
19287259279812.7234712866487.89198089447446.2765287142.00973341430148
20291186289067.0859777568238.786706765812118.914022243630.554283770795183
21292300293757.1653613275989.62411900662-1457.16536132667-0.711398811597042
22288186291683.116036667878.090627124425-3497.11603666658-1.61678482966945
23281477286133.284538209-3194.37722816267-4656.28453820917-1.28817389796142
24282656281944.939650254-3823.35446379716711.060349745754-0.199045423403195
25280190279026.569949849-3250.517923530971163.430050150730.181769936433091
26280408277630.461624367-2075.112102747652777.538375632980.372419943967702
27276836274670.010576067-2631.760328782412165.98942393288-0.175527054931249
28275216273993.861055428-1409.302150858151222.138944572480.388059482722576
29274352275843.892322561638.320053464804-1491.892322560890.650790183526992
30271311279467.5535938812514.41172645266-8156.553593881060.592726949539441
31289802283709.1462796413595.881421130606092.853720358820.341553139415206
32290726287633.876589383801.700849683633092.12341061980.0651105199350271
33292300290947.5296940553495.882923609391352.47030594478-0.0967453124667064
34278506283703.845381414-3236.44053030738-5197.8453814141-2.12942823619126
35269826275263.654781419-6497.21044619752-5437.65478141853-1.03149128100706
36265861266174.582475066-8120.73639557832-313.58247506571-0.513937878309871
37269034265211.732959609-3633.506841428213822.26704039091.42162440072165
38264176261286.649501754-3816.256187899962889.35049824554-0.057799338075365
39255198254427.318593741-5715.73511057414770.681406259409-0.59991216601527
40253353251794.842969670-3796.222819009011558.157030329660.608055454268744
41246057248859.105094192-3259.28166814887-2802.105094192000.170316022397996
42235372245091.625017296-3576.77771057387-9719.62501729559-0.100435874232346
43258556250185.4333219111830.321698257038370.566678088981.70823975157416
44260993256661.4737560674724.160348943144331.526243932920.914941079265525
45254663252630.03949029-731.5612023612682032.96050971022-1.72577205456562
46250643252529.07339128-338.486833767182-1886.073391280140.124346023835854
47243422249524.259015868-2000.44577866795-6102.25901586832-0.525848546663348
48247105249320.305104821-880.464671722156-2215.305104820840.354524958695860
49248541245548.325514164-2684.147853189962992.67448583648-0.570929765356757
50245039241221.400684498-3708.244072420443817.5993155022-0.323773745385182
51237080237068.307936376-3984.8620986799511.6920636239260-0.0874174362504562
52237085234614.621625068-3034.091093589492470.378374932340.300987728283051
53225554229476.274529091-4342.42688382378-3922.27452909119-0.414592290697748
54226839236099.6374835972483.23188002607-9260.637483597212.16002895079982
55247934240991.1856218123980.98269792656942.814378187790.47338301735257
56248333242009.1403779452140.454089949916323.85962205526-0.581806500273487
57246969244702.5223032962483.811885865492266.477696704260.108596769884744
58245098246686.3577524782173.28267813475-1588.35775247784-0.0982459658341283
59246263251949.6085416434092.8627024764-5686.608541642950.607477935434488
60255765256802.8263408554565.41443157929-1037.826340854820.149570211298826
61264319260744.5128461864177.647279257643574.48715381359-0.122688892520152
62268347264204.2049600623731.629711250954142.79503993849-0.140999503967521
63273046271478.8996529595928.851749972481567.100347040790.694566262438454
64273963273042.3584569853224.03588936383920.641543015415-0.856043335704996
65267430275607.5010215472815.42548075274-8177.50102154707-0.129417363409643
66271993281017.3006589914425.81672752953-9024.300658990910.509664428701021
67292710284951.6844451514120.903374296937758.31555484861-0.096399711316369
68295881289357.087379764297.232248283576523.912620239770.0557380803996539
69293299291689.9137150153080.480998435331609.08628498541-0.384794295264137
 
Charts produced by software:
http://www.freestatistics.org/blog/date/2009/Dec/04/t1259945985evxh8y9k85cdr8g/1v3491259945854.png (open in new window)
http://www.freestatistics.org/blog/date/2009/Dec/04/t1259945985evxh8y9k85cdr8g/1v3491259945854.ps (open in new window)


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


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


http://www.freestatistics.org/blog/date/2009/Dec/04/t1259945985evxh8y9k85cdr8g/4945l1259945854.png (open in new window)
http://www.freestatistics.org/blog/date/2009/Dec/04/t1259945985evxh8y9k85cdr8g/4945l1259945854.ps (open in new window)


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


 
Parameters (Session):
par1 = FALSE ; par2 = 1 ; par3 = 1 ; par4 = 1 ; par5 = 12 ; par6 = 3 ; par7 = 1 ; par8 = 2 ; par9 = 1 ;
 
Parameters (R input):
par1 = 12 ; par2 = 1 ; 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