ISSN 8-80 (prt) ISSN 8-8038 (ole) INTELEKTINĖ EKONOMIKA INTELLECTUAL ECONOMICS 0, Vol. 5, No. (0), p. 44 56 MODELLING OF STOCK PRICES BY THE MARKOV CHAIN MONTE CARLO METHOD Matas LANDAUSKAS Kauas Uversty of Techology, Faculty of Fudametal Sceces Studetų 50, LT - 5368 Kauas, Lthuaa matas.ladauskas@ktu.lt Emuts VALAKEVIČIUS Kauas Uversty of Techology, Faculty of Fudametal Sceces Studetų 50, LT - 5368 Kauas, Lthuaa emval@ktu.lt Abstract. Ths paper presets a uversal approach to modellg stock prces. The techque volves Markov Cha Mote Carlo (MCMC) samplg from pecewse-uform dstrbuto. Today s facal models are based o assumptos whch make them adequate may cases. Oe of the most mportat ssues s determg the dstrbuto of a stock prce, ts retur or other facal mea. The approach proposed ths paper removes almost all presumptos from a dstrbuto of a stock prce. The probablty desty must be evaluated usg some oparametrc estmates. The kerel desty estmate (KDE) suts well for that purpose. It gves a smooth ad presetable estmate. MCMC was chose due to ts versatlty ad s appled to KDE usg pecewse-lear dstrbuto as proposal desty. The proposal desty s costructed accordg to the KDE. Such lk betwee the pecewse-lear dstrbuto s smplcty ad relatve massveess of KDE balaces together. Ivolvg the kerel desty estmate ad the methodology to sample from t makes the techque uversal for modellg ay real stochastc system whle havg emprcal data oly ad barely ay assumptos about the dstrbuto of t. JEL classfcato: C0, C5, C46, C65. Keywords: Stock prces, Markov cha, Mote Carlo method, MCMC, kerel desty, pecewse-lear dstrbuto. Rekšma žodža: Akcjų kaos, Markovo gradė, Mote Karlo metodas, braduols taks, dalms tolyguss skrstys.
Modellg of Stock Prces by the Markov Cha Mote Carlo Method 45 Itroducto Classcal model of stock prces has some assumptos about facal data. It caot be appled to model the stock prce havg returs whch are ot log ormally dstrbuted. There are several approaches to model dffcult quattes, but they specalze dfferet areas. The purpose of ths paper s to preset a uversal techque for modellg stock prces. Ths techque cossts of specal umercal methods ad s sutable for ay emprcal data. The Markov cha Mote Carlo method s used to sample from emprcal probablty desty of a stock prce. The techque s flexble ad requres just the ablty to calculate probablty at ay gve pot. Furthermore, MCMC was successfully appled to oe-factor models for the terest rate (B. Eraker, 00). Ths also acts as the reasog for choosg t for ths approach of modellg stock prces. It s also eeded to approxmately evaluate emprcal probablty desty. Ths s performed usg kerel desty estmato. The lk betwee these two methods s cosdered ad ths leads to apply t o every facal data.. Mote Carlo Modellg of Stock Prces The process of a stock prce s treated as a Browa moto. Thus ts value satsfes the equato: (.) Cosder a facal mea wth log ormally dstrbuted returs. The radom walk of prce of such a facal mea s modeled accordg ths formula (P. Wlmott, 007): S ( t + Δt) = S() t e δ σ Δt+ σ ΔtZ. (.) Z follows stadard ormal dstrbuto, δ s aual rsk free retur ad σ s aual stadard devato of the logarthm of a stock prce. Here radom value ~ N( 0,). Markov cha Mote Carlo (MCMC) Suppose t s eeded to geerate x ~ π() x. Whe x ~ π() x s dffcult to sample from, MCMC samplg techque could be performed. I fact MCMC s a set of techques used for ths purpose. The ma dea of t s to costruct a Markov cha { X } =0, such that ( X = x) = π( x) lm P. (.)
46 Matas LANDAUSKAS, Emuts VALAKEVIČIUS A Markov cha s predefed by a tal state P ( X 0 = x0 ) = g( x0 ) ad the tra- P y x = P X + = y X x. Statoary dstrbuto π () x = lm f ( x ) sto kerel ( ) ( ) = s uque f the cha s ergodc. The: () y = π()( x P y x) x Ω π, y Ω. (.) Latter equalty could be rewrtte as a set of ( ) lear equatos: π... π ( x ) = π( x ) P( x x ) + π( x ) P( x x ) +... + π( x ) P( x x ); ( x ) = π( x ) P( x x ) + π( x ) P( x x ) +... + π( x ) P( x x ); (.3) ) equatos ad ( ) here := Ω. There are a total umber of ( trasto probabltes P ( x j x k ), k =,, j =,. Thus there exst a fte umber of trasto kerels P ( y x), such that the statoary dstrbuto of the Markov cha s π () x. Oe of the techques used for costructg such a trasto kerel s Metropols- Hastgs algorthm (J.S. Dagpuar, 007). The dea of t s to choose ay other tras- y x y x P y x. to kerel Q ( ). The there exsts a probablty that Q ( ) s equal to ( ) (.4) Cosderg the detaled balace codto of a tme-homogeeous Markov cha yelds: (.5) The geeral soluto for (.5) s. It s ecessary to have a hgher acceptace rato whe samplg radom umbers, therefore by adjustg r ( x, y) ad cosderg hgher acceptace rato whle samplg radom umbers (V. Prokaj, 009) t s show that: ()( y Q x y) ()( x Q y x) π α ( y x) = m,. (.6) π 3. Noparametrc probablty desty estmato Cosder a sample cosstg of radom depedet ad detcally dstrbuted values X. Kerel desty estmate s chose for evaluate the probablty desty of X. fˆ x () x = K h( x X ), K h () x = K, (3.) = h h K s the kerel fucto, h s ts wdth. here ()
Modellg of Stock Prces by the Markov Cha Mote Carlo Method 47 (3.) Below are some kerel fuctos that are frequetly used. The tragular kerel fucto s useful f the data has sharp edged dstrbuto. Gaussa kerel makes the estmate s PDF plot very smooth. x, x, K () x = (tragular), (3.3) 0, x >. (Yapachkov), (3.4) K x () x = e π (Gauss). (3.5) Bascally, such probablty desty estmato s about assgg kerel desty to each X ad cludg weghted sum of all other assgatos. The cotrbuto of ay other X to the probablty value at X s smaller f X X s bgger. j j Fg.. Kerel desty estmato. Fgure shows the probablty desty estmato from 5 gve pots whle applyg Gaussa kerel. The estmate s absolutely smooth. The oly drawback of such
48 Matas LANDAUSKAS, Emuts VALAKEVIČIUS estmato s the ecessty of usg all the pots from the sample whle evaluatg the probablty at a partcular pot. 4. A New Approach to Modellg Stock Prces 4.. Evaluato of Dstrbuto Fucto Ths chapter presets the approach to model stock prces or ay other statstcal data (the method s uversal eough) wthout kowg aalytcal probablty desty fucto. Frst of all kerel desty estmato must be performed ad costruct a estmate to the retur of a stock prce. At ths pot there could be a dscusso f ths estmate s accurate, but t s assumed to be exact. Ad there s o eed to look for aalytcal fuctos whch best ft a partcular case. It s ot ecessary to thk about the shape at all, t forms tself accordg the data. The oly questo s the wdth of the kerel fucto. 4.. Specal techque for costructg a proposal desty The target probablty desty s ow costructed. I order to model t a specal techque s requred, because there are o verse cumulatve desty fucto or oe caot represet the estmate usg kow aalytcal PDF s. MCMC s a soluto but t could ot be appled drectly to the PDF estmate metoed before. Probably the bggest advatage of MCMC s the ablty to geerate requred desty usg the proposal desty, whch should be smlar shape to target desty. No other requremets to proposal desty. Thus the complexty of proposal desty s as smple as t s eeded. Cosder a hstogram, whch s relatvely fast ad smple o-parametrc estmate for target desty. It s possble to use t as proposal desty therefore. But the assumpto about target desty ot beg dscrete must be take md, there are o set of values to costruct a hstogram from. The dea of the techque preseted ths paper s to costruct a pecewse-uform dstrbuto accordg to the kerel desty estmate. A pecewse-uform dstrbuto s defed eq. (4..). Fg.. Proposal desty as a pecewse-lear probablty dstrbuto.
Modellg of Stock Prces by the Markov Cha Mote Carlo Method 49 (4..) The area below the probablty desty fucto must be equal to, thus: q = x x 0. (4..) Ths dstrbuto s treated as a proposal desty. Geeratg radom umbers from ths dstrbuto s fast ad smple. Fg. 3. Geeratg radom umbers usg verse CDF. Samplg from q () x requres applcato of a search procedure. Frstly a u ~ U( 0;) s draw. The t s requred to fd the terval ( x ], =,, to whch u belogs, x to. Sce the umber of tervals s gog to be small, ths step does ot requre may calculato steps. The u s mapped to x accordg to the CDF of q () x lke fgure 3. CDF of q () x s obtaed by calculatg the area below target desty each of the tervals. Usg q () x as the proposal desty ad kerel desty estmate as a target dstrbuto mples radom values x havg dstrbuto equal to fˆ () x. It must be oted that acceptace rato for x s ow ()() y q x ()() x q y ( ) fˆ α y x = m,. (4..3) fˆ
50 Matas LANDAUSKAS, Emuts VALAKEVIČIUS The samplg techque s called the depedece Metropols-Hastgs whe q ( x y) = q() x. The depedece sampler has oe sgfcat advatage compared to tradtoal Metropols-Hastgs: the sequece { x } has o memory effect. Each radom value accepted smulato process does ot deped o prevous value. Thus there s o mportace what was x 0 geerated. A bref descrpto of Metropols- Hastgs techques could be foud (M. Johaes, 006). 5. Calbrato of the model Every model should gve adequate results ad compare to other kow models or techques. Makg the model hold ths s called a calbrato. I ths case, the ew techque for modellg stock prces must gve smlar results as tradtoal Mote Carlo f stock returs are log ormally dstrbuted. Aga the hypotheses about the ormalty of the logarthms of the stock returs are gog to be tested. Fg. 4. Yahoo! Ic. hstorcal share prces. Yahoo! Ic. (YHOO) share prces from 00 0 04 to 00 09 7 were chose for performg the calbrato. Hstorcal share prces are depcted fgure 4. By performg the Kolmogorov-Smrov test o the logarthms of the prces returs p = 0. 99 ad D = 0. 074 were obtaed. D < p shows that the logarthms are ormally dstrbuted ad leads data to be sutable for classcal stock prce model.
Modellg of Stock Prces by the Markov Cha Mote Carlo Method 5 Fg. 5. Classcal Mote Carlo modellg versus MCMC approach. 00 trajectores (fgure 5) were modeled for each techque. Accordg the classcal Mote Carlo approach the mea value of a prce after 50 days wll be 8.08 $. The ewly proposed techque gave t 8.0 $ per share. Ths s actually expected, because the tred was cosdered. Fg. 6. Comparg Mote Carlo ad MCMC results. I fgure 6 the hstograms of classcal Mote Carlo ad MCMC are compared. They represet the dstrbuto of stock prces at the ed of the modellg process. The modellg process cotaed 000 paths of a stock prce ad smulated 00 days. Thus t requred 00000 radom stock returs to be performed.
5 Matas LANDAUSKAS, Emuts VALAKEVIČIUS Fg. 7. Dffereces betwee the Mote Carlo ad MCMC results. The bggest dfferece betwee the two hstograms exsts at about mea value. The tals match better. Classcal Mote Carlo coverges to stock prce dstrbuto whe the umber of paths s creasg; the method proposed ths paper should also. Checkg f the ew method matches Mote Carlo s equvalet to checkg f t coverges to the dstrbuto of a stock prce. Whle evaluatg the dfferece betwee two probablty destes ofte a tegral of a absolute value of ther dfferece s used. Now cosder a estmate: (5.) ad umber of bars ad s the hstograms of a stock prce at the ed of the modellg, m s X represets the ceter pot of the j -th bar. j Table. Dffereces betwee the hstograms of the stock prces modeled by Mote Carlo ad MCMC No. of bars g() x 3 No. of trajectores No. of radom values 50 5000 0.45 00 0000 0.3 00 0000 0.6 500 50000 0.07 000 00000 0.064 Table shows how chages f the umber of a stock prce paths N creases. The bgger N the more Mote Carlo ad MCMC results are alke. MCMC proved to be sutable for modellg stock prces. The umber of bars g () x s equal to a questo of peaks ad dstace betwee them target dstrbuto. Sce the returs of stock prces have a dstrbuto smlar
Modellg of Stock Prces by the Markov Cha Mote Carlo Method 53 shape to ormal dstrbuto, g () x should have a small odd umber of bars order to best match the target dstrbuto. Table. Dffereces betwee the hstograms of the stock prces modeled by Mote Carlo ad MCMC No. of bars g() x 5 No. of trajectores No. of radom values 50 5000 0.65 00 0000 0.3 00 0000 0.09 500 50000 0.060 000 00000 0.050 As the table shows choosg 5 bars proposal desty results more precse dstrbuto of stock prces. Accuracy creases but the calculato tme s hgher also. Ths s due to more calculato steps requred to fd the terval of g () x to whch a partcular radom umber belogs to. 6. Modellg stock prces Here s a example whe classcal Mote Carlo method caot be appled to model stock prces. Fg. 8. Dstrbuto of ormalzed logarthms of cotuous day returs. The hstogram of ormalzed logarthms of cotuous day returs R of Tesco Corporato (TESO) s depcted fgure 8. Although the hypothess of ormalty s accepted, there exst two peaks. If oe s cofdet about the shape of hstogram, the assumpto of ormalty should be rejected ad stadard Mote Carlo caot be appled.
54 Matas LANDAUSKAS, Emuts VALAKEVIČIUS Fg. 9. Forecastg the stock prces. S S Costructg kerel desty estmate for r = usg Gaussa kerel S fucto also gves PDF wth peaks (fgure 9). MCMC wth pecewse-lear dstrbuto as a proposal desty was appled to ths PDF. Fg. 0. Forecastg TSO stock prces. Average share prce after 50 days resulted $4.75. All the prces geerated are dstrbuted accordg kerel desty estmate. Samplg s based etrely o emprcal data ad has o assumptos about PDF. 7. Coclusos. Whle estmatg the probablty desty of a custom stock retur wth kerel desty, each retur the sample s cosdered.. Proposed techque for modellg stock prces leads for average path of the stock prce havg small dsperso. The same holds for the Mote Carlo method.
Modellg of Stock Prces by the Markov Cha Mote Carlo Method 55 3. The hgher umber of tervals used for costructg pecewse-uform probablty desty leads to better accuracy of dstrbuto modeled, but requres more tme to perform the method. 4. Combg MCMC wth kerel desty estmate leads the techque for beg able to model ay real system. Thus emprcal probablty desty s costructed usg partcular statstcal formato. Ths could be value of a facal mea, product qualty measures ad so o. Thus the techque s uversal. Refereces. B. Eraker. MCMC Aalyss of dffuso models wth applcatos to face. Joural of Busess ad Ecoomc Statstcs, vol. 9, pp. 77-9, 00.. J. S. Dagpuar. Smulato ad Mote Carlo. Joh Wlley & Sos Ltd., Great Brta, Chppeham, Wlltshre, 007. 3. M. Johaes, N. Polso. MCMC Methods for Cotuous-Tme Facal Ecoometrcs, 006. <http://www0.gsb.columba.edu/faculty/mjohaes/pdfpapers/jp_006.pdf>. 4. P. Wlmott. ItroducesQuattatve Face, ed. JohWlley& Sos Ltd., 007. 5. V. Prokaj. Proposal selecto for mcmc smulato. Appled Stochastc Models ad Data Aalyss, pp. 6 65, 009. AKCIJŲ KAINŲ MODELIAVIMAS MARKOVO GRANDINĖS MONTEKARLO METODU Matas Ladauskas Emuts Valakevčus Satrauka. Strapsyje prstatoma uversal akcjų kaų modelavmo techka. Š techka paremta Markovo gradų Mote Karlo (MCMC) metodo takymu modeluojat dalms tolygųjį skrstį. Dabarta fasų rkų modela paremt preladoms, kuros daža juos verča eadekvačas. Vea ddžausų problemų yra akcjos kaos, jos grąžos ar bet kokos ktos fasės premoės passkrstymo dėso ustatymas. Šame strapsyje pasūlytas požūrs pašala praktška vsas preladas ape akcjos kaos passkrstymą. Toku atveju passkrstymo dėss tur būt įverttas eparametru būdu. Braduols tkmybo tako įvertmas šam tkslu puka tka. Js sudaro glotų r reprezetatyvų tako įvertį. MCMC buvo pasrktas dėl ddelo prtakomumo r yra takomas braduolam tako įverču su dalms tolyguoju skrstu kap alteratyvu (aproksmuojaču) taku. Alteratyvus taks kostruojamas pagal braduolį įvertį. Toks dalms tolygojo skrsto paprastumo r satyka aukšto braduolo tako įverčo sudėtgumo skačavmo prasme apjugmas sukura balasą tarp šų metodų. Naudojat braduolį akcjos kaos passkrstymo įvertmą r šame strapsyje sūlomą jo modelavmą padaro patektą techką uversalą. J tampa tkama bet koka reala stochaste sstema turt tk jos emprus duomes r bevek jokų preladų ape jų passkrstymą.
56 Matas LANDAUSKAS, Emuts VALAKEVIČIUS Matas Ladauskas s a postgraduate studet appled mathematcs at Faculty of Fudametal Sceces, Kauas Uversty of Techology. Master s degree research area: modellg of stochastc systems by MCMC method. Matas Ladauskas - Kauo techologjos uversteto Fudametalųjų mokslų fakulteto takomosos matematkos magstratas. Magstro darbo tyrmų tematka: stochastų sstemų modelavmas takat MCMC metodą. Emuts Valakevčus Doctor, Assocated professor. Faculty of Fudametal Sceces, Kauas Uversty of Techology. Dploma Appled mathematcs, VU (978), PhD (989), Assocated Professor (99), Head of Departmet of Mathematcal Research Systems (997-00). Author of more tha 70 publcatos (moograph, textbooks, research results, study gudes ad projects). Research terests: modelg of stochastc systems, umercal modelg of facal markets. Emuts Valakevčus Kauo techologjos uversteto Fudametalųjų mokslų fakulteto Matematės sstemotyros katedros docetas, daktaras. 978 m. bagė VU takomosos matematkos specalybę, 989 m. įgjo daktaro lapsį, 997-00 m. vadovavo matematės sstemotyros katedra. Paskelbė vrš 75 publkacjų. Mokslų teresų srts stochastų sstemų be fasų rkų modelavmas.