Home » date » 2009 » Dec » 02 »

WS09 - Local level model, local trend model, and basic structural 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: Wed, 02 Dec 2009 13:43:12 -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/02/t1259786700bp7p0e38nts7ltz.htm/, Retrieved Wed, 02 Dec 2009 21:45:41 +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/02/t1259786700bp7p0e38nts7ltz.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 «
423.4 404.1 500 472.6 496.1 562 434.8 538.2 577.6 518.1 625.2 561.2 523.3 536.1 607.3 637.3 606.9 652.9 617.2 670.4 729.9 677.2 710 844.3 748.2 653.9 742.6 854.2 808.4 1819 1936.5 1966.1 2083.1 1620.1 1527.6 1795 1685.1 1851.8 2164.4 1981.8 1726.5 2144.6 1758.2 1672.9 1837.3 1596.1 1446 1898.4 1964.1 1755.9 2255.3 1881.2 2117.9 1656.5 1544.1 2098.9 2133.3 1963.5 1801.2 2365.4 1936.5 1667.6 1983.5 2058.6 2448.3 1858.1 1625.4 2130.6 2515.7 2230.2 2086.9 2235 2100.2 2288.6 2490 2573.7 2543.8 2004.7 2390 2338.4 2724.5 2292.5 2386 2477.9 2337 2605.1 2560.8 2839.3 2407.2 2085.2 2735.6 2798.7 3053.2 2405 2471.9 2727.3 2790.7 2385.4 3206.6 2705.6 3518.4 1954.9 2584.3 2535.8 2685.9 2866 2236.6 2934.9 2668.6 2371.2 3165.9 2887.2 3112.2 2671.2 2432.6 2812.3 3095.7 2862.9 2607.3 2862.5
 
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
1423.4423.4000
2404.1414.681615828779-0.79705651882702-1.93728484637907-0.0748849046629789
3500451.4603690991.9630156274561110.70487911796090.33105286135969
4472.6461.920354053612.427240409737751.198949049262200.080670994278407
5496.1476.5851108756842.953403930805225.108425240212290.120787400133489
6562511.9185837694674.1215295807515810.87969972879590.326151303350756
7434.8483.361013614283.07995286631461-8.38288153604376-0.332851874718943
8538.2504.4045155598413.6047444831336511.51281580556710.184140383918859
9577.6534.8797362240044.341983994414639.210289250416080.276498908524525
10518.1530.2786818083334.10796450356718-0.987949681849582-0.0922457911814492
11625.2568.2572205771684.9614111264328814.46215269869200.349928097632418
12561.2567.9381709423894.83253310576678-0.104420004486369-0.0546163700688248
13523.3572.1050134765624.89491405168368-47.8183911310501-0.00919973127486513
14536.1562.1876992285114.43310186613281-10.9255770722826-0.133816320615445
15607.3577.3994061682134.7997455397737318.63890511123830.100182128668110
16637.3603.6722992475855.387063389918119.452232878969970.211532665589422
17606.9608.5028273071865.37483467316522-0.950844547061103-0.00564945171623517
18652.9622.1190888003495.5280732688541520.94102224134100.084853066246064
19617.2627.5473058047065.52641884647024-10.2269552614216-0.00103529745057395
20670.4643.5668304454315.6874345837492314.12387502538020.109187500165899
21729.9675.8026988413566.0745935896095821.85333975462930.276810524347979
22677.2683.5209053048436.09772562141712-8.320399067871820.0171578244000113
23710691.2735919094636.1200866126537716.71039119671060.0172911155801777
24844.3752.3655485722716.6793328238476524.61771264296850.57569474685432
25748.2777.596478398656.03121236921146-53.92595892689450.219212382849823
26653.9741.1384676988155.34676458649737-39.9442839008349-0.417958907922997
27742.6736.5035944752345.119392534784316.9095226695473-0.096937755290350
28854.2779.5468562260335.8736631670362431.95685683674880.380285134192497
29808.4797.3890289236526.06923663547251-2.847622123195040.122649098111375
3018191170.1565106970811.1366676903444217.8728360084043.80015891535140
311936.51488.2801258761114.898751690533884.69093382401463.19929130714277
321966.11691.3692272827117.029851127781151.00213001946061.96694818968353
332083.11849.5099820199218.548615666229465.4715074128871.47721516434563
341620.11788.477736998517.7261832801294-73.436811757611-0.833887993254807
351527.61694.6572853500216.6717882644994-33.7550595192486-1.16984570448234
3617951726.1920159996516.748378813958350.93015930164580.156422452801543
371685.11760.3407696024116.4555387359094-97.12654530877560.194589179903709
381851.81824.1991862229116.9218919230483-26.59779185474810.481696763552767
392164.41960.5376482152418.933215088095971.86448623126951.18763942944971
401981.81979.4747965284618.93327798789662.320770250527913.98189781001649e-05
411726.51939.3788613665618.1296235182491-144.950031058440-0.607563724682302
422144.61974.792313034818.3302201976358149.6649618889090.179625438413395
431758.21899.1304730893917.3659908728787-30.6418282790216-0.981839150931345
441672.91816.2255967576716.4204909906713-25.2428046842766-1.05024568558892
451837.31792.8064546756016.065900476136091.5049021046926-0.417898103098114
461596.11743.5280011537315.5183945315555-70.210851657177-0.6860556357527
4714461654.7641778471514.7711028954023-85.284521873523-1.0958684107077
481898.41727.4159042013814.9487957275431102.0202639689290.610623584245753
491964.11861.0497641948613.9421765732852-42.15919380612621.29270357376042
501755.91862.4841121744413.8559090901685-92.132150889158-0.128962171458361
512255.31990.1703400461515.3475786676892137.5123834216241.14950415400863
521881.21963.1000639137114.7804943081271-33.9229053299088-0.432388162885295
532117.92080.5097858268115.9961106998368-80.46612678429941.05936803220661
541656.51880.2029096053313.777313005138727.390221987977-2.25165643708501
551544.11753.9077153361612.5059259070236-46.1741826399388-1.46513487296703
562098.91877.4700031356513.426658663024991.23473522448161.16468294381579
572133.31942.4991051102613.8252903893520130.1808087657170.541963513517947
581963.51978.9309868650013.9851713195094-42.02926128804070.237644193091478
591801.21966.1031984237213.8324159034571-133.289056058794-0.282124432613277
602365.42092.7340712623214.0860404407878138.9587606025481.19117757119819
611936.52071.7820766581814.2272948601356-93.1080792983525-0.376278806217526
621667.61978.7884462261713.6464144891560-186.733152716078-1.11345639529800
631983.51927.7830637610912.962650485947128.942833260640-0.659701973307434
642058.61995.5739239849713.58835052363950.7436902601518160.561960294236888
652448.32173.0114950369815.309515155297687.11909563135981.69524300723591
661858.12058.6866458327014.1068456028677-50.3475590490785-1.3510507818597
671625.41934.8465286346112.9690761620916-148.635292413847-1.44417392948922
682130.61976.3928769562213.1830798622253120.7772037581860.299952412488763
692515.72133.9452110102014.1748973589787212.5095848836981.51756260181880
702230.22202.1782623683714.5054764459158-35.45425677006310.568748783384594
712086.92234.0558981496314.5876076591898-167.5960932213830.182939477133200
7222352189.9057288120214.4708947643872114.502439429009-0.620417966237304
732100.22184.4253728525514.5004052859691-60.4498538718683-0.212552185859943
742288.62292.5035668345114.9332628256618-112.7579211273960.975540535709335
7524902342.7187254896815.2437089661143107.0249445956660.362650697387888
762573.72451.9692441340916.173263935056414.48972445290400.967849557947195
772543.82452.7656991214916.0285108241447108.712075400525-0.159421684123625
782004.72306.6213023449114.6526230558671-114.059869700991-1.69184310816180
7923902394.6418737307115.2097974650261-90.08767578915020.768604048349434
802338.42361.4347574245114.877550968972833.544469182577-0.508501667836641
812724.52426.8041552871915.1907342646091238.5632350076580.531074532330278
822292.52404.3378608554414.9876386803755-67.6638149641772-0.396423861622161
8323862458.4279328498415.1473524141049-118.3832748529900.411992538473963
842477.92438.0904513579815.077596091086281.6509690256624-0.374746211625817
8523372443.8768456158615.0771170248228-95.874214394794-0.0985211033689705
862605.12557.2252509961115.4870396322428-66.56627360838891.02681499152840
872560.82545.1630189957215.280029239049747.2389521579837-0.284660650886326
882839.32649.0548919820316.048825566076688.77432034222240.915686935787295
892407.22523.5769970345614.846412366123246.5665049617651-1.47004283581418
902085.22415.5917137794613.8878115060695-188.083360113410-1.28258112417302
912735.62557.6345633671314.790026300308128.76965153935191.34329543921780
922798.72652.6771700083815.298964986416152.28838292774950.843243234925903
933053.22722.6404247377115.6085402854971266.5732360766170.575208881577013
9424052651.8567869791015.1902118076113-145.567970819499-0.909841148191891
952471.92631.6012430944915.0606449165907-118.074090159692-0.373589867922924
962727.32645.2980348951315.057865889482483.6075755735832-0.0143987327864590
972790.72750.2584029807815.1475446389026-65.58975755903140.950619622651217
982385.42656.9705676101914.7259312209612-145.212663696169-1.13470415528651
993206.62845.0259985076715.8633057511006161.9631459751051.79791858199428
1002705.62766.2273915917815.134593425681648.1254107678746-0.981206003165279
1013518.43014.6660718971316.9337009181384234.6972910236872.42745148945704
1021954.92745.4514849104714.8720388970241-458.877676294272-2.99044186614255
1032584.32679.9127513641614.3452339659046-2.00502499422826-0.843259468453997
1042535.82615.6959959755713.882204304984711.8428830372442-0.82577610359993
1052685.92538.237870868913.4055770850045254.549053113237-0.961436959811166
10628662704.2889801360614.0798540770138-17.19450592191461.60804825770784
1072236.62599.8967135001813.6810622381244-224.239518588987-1.24891539579506
1082934.92698.6090678636913.8626526041147136.3106739942450.897397860258287
1092668.62717.6511033634913.8709089387702-55.14342373600010.0546727393183424
1102371.22673.0594204559713.6549473201582-233.705256149577-0.6124209648126
1113165.92790.3597438338214.2601597808862255.827614927461.07823695045743
1122887.22839.5747591653814.50134245917777.356492266745830.363242017332657
1133112.22831.3667950659314.3415894715205307.061721915677-0.236645570305387
1142671.22934.627384780714.9346663846294-366.5576613062860.930013829035987
1152432.62761.9964458460013.7881684114683-111.019332674058-1.96785534708222
1162812.32766.6174120359113.737741566016556.3865451288016-0.0963861001898183
1173095.72813.7911808557313.8997538714006242.7881941448450.3520256798499
1182862.92837.3253585629813.939115171557514.28553282652360.101514311857133
1192607.32854.0099355154013.9478119417654-249.9310277170170.0289453637617892
1202862.52817.961143815513.8363005281297103.267604395130-0.527483258536329
 
Charts produced by software:
http://www.freestatistics.org/blog/date/2009/Dec/02/t1259786700bp7p0e38nts7ltz/1b5ly1259786589.png (open in new window)
http://www.freestatistics.org/blog/date/2009/Dec/02/t1259786700bp7p0e38nts7ltz/1b5ly1259786589.ps (open in new window)


http://www.freestatistics.org/blog/date/2009/Dec/02/t1259786700bp7p0e38nts7ltz/2i6471259786589.png (open in new window)
http://www.freestatistics.org/blog/date/2009/Dec/02/t1259786700bp7p0e38nts7ltz/2i6471259786589.ps (open in new window)


http://www.freestatistics.org/blog/date/2009/Dec/02/t1259786700bp7p0e38nts7ltz/3qcb21259786589.png (open in new window)
http://www.freestatistics.org/blog/date/2009/Dec/02/t1259786700bp7p0e38nts7ltz/3qcb21259786589.ps (open in new window)


http://www.freestatistics.org/blog/date/2009/Dec/02/t1259786700bp7p0e38nts7ltz/4tcgt1259786589.png (open in new window)
http://www.freestatistics.org/blog/date/2009/Dec/02/t1259786700bp7p0e38nts7ltz/4tcgt1259786589.ps (open in new window)


http://www.freestatistics.org/blog/date/2009/Dec/02/t1259786700bp7p0e38nts7ltz/57tla1259786589.png (open in new window)
http://www.freestatistics.org/blog/date/2009/Dec/02/t1259786700bp7p0e38nts7ltz/57tla1259786589.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