【神经网络异常检测】A Test for the Presence of Jumps in Financial Markets using Neural Networks in R

A Test for the Presence of Jumps in Financial Markets using Neural Networks in R

Wall Street Bull

Modelling of financial markets is usually undertaken using stochastic processes. Stochastic processes are collection of random variables indexed, for our purposes, by time. Examples of stochastic processes used in finance includeGBM,OU,Heston Model andJump Diffusion processes.  For a more mathematically detailed explanation of stochastic processes, diffusion and jump diffusion models, readthisarticle. To get an intuitive feeling of how these different stochastic processes behave, visit the interactiveweb applicationthat I worked on in conjunction withTuring FinanceandSouthern Ark.

As was witnessed during the recent financial crisis, stock markets exhibit jumps. That is, they exhibit large falls in value. Over the past couple of decades, the has been increasing interest in the modelling of these jumps. The classic model for modelling jumps in stochastic processes is theMerton Jump diffusionmodel.  This model says that the returns from an asset are driven by “normal” price vibrations (representing the continuous diffusion component) and “abnormal” price vibrations (representing the discontinuous jump component).  The SDE of the Merton Jump diffusion model  is given as:

In practice, before we can proceed with fitting a jump diffusion model to data, we first have to establish if the data that we are fitting the model to has jumps. This requires us to statistically test for the presence of jumps in return data.

There are various tests that have been developed for testing for jumps in return data. Examples of  such tests include the bi-power variations test of Barndorff-Nielsen and Shepard (2006). This jump test compares the estimate of variance that is not robust to the presence of jumps, called realized variance, with an estimate of variance that is robust to the presence of jumps, called bi-power variation. This test was improved by Ait Sahalia and Jacod (2009). In their test, they compare the bi-power variations for returns sampled at different frequencies. Lee and Mykland (2008) also used insights from the test of Barndorff-Nielsen and Shepard (2006) by testing for the presence of jumps at each observed value of the process, while taking into account the volatility of the process at the time the observation was made. The test of Lee and Mykland (2008) has the added advantage that it not only indicates whether or not jumps have occurred, but also gives information as to what time the jumps occurred and their size.

In this blog post, I propose a test for the presence of jumps using Neural Networks. This test is then assessed using simulation compared to the Lee and Mykland (2008) test, then we look at how the Neural Network test fares on stocks on the JSE.

The Neural Network Test

An example of biological neural networks

Neural Networks are a group of learning models which fall under machine learning. They were inspired by the biological neural networks.  For a detailed analysis of neural networks and the algorithm used to train neural networks, please refer to this article by Turing Finance.

As mentioned above, the test I am  proposing uses neural networks to test for jumps. This test establishes whether or not the whole series of returns has jumps. That is, the test has a binary outcome. This means that we can treat the testing for the presence of jumps as a classification problem. We want to classify a set of returns as belonging to on one of two categories, having jumps or not having jumps.

Given that neural networks can perform well in classification problems, such as in credit rating, it seems natural to try see how neural networks perform when trained to distinguish between a set of returns that has jumps and one that does not have jumps.

Architecture of Neural Network

As the test uses neural networks, we need to carefully think about the architecture of the neural network. That is, we need to think of: what the inputs to the network are, what number of hidden layers (and associated number of neurons) we should have, and what the output layer should look like.

I have chosen the inputs into the neural network are: The first and second centered moments, skewness, kurtosis, the fifth, sixth, seventh and eighth centered moments. All of the moments used are sample moments. These particular variables were chosen as inputs to the neural network as the tests of Barndorff-Nielsen and Shepard (2006), Ait Sahalia and Jacod (2009) and Lee and Mykland (2008) use versions of these moments as their test statistics. So we believe that these moments should have strong predictive power.However, it should be noted that the moments are not necessarily independent and this could affect the performance of the neural network. Thus the inputs into the neural network still need further work. Let 

 be a series of 
 log returns. The moments inputs would then be given as:

It is important note that this particular architecture was chosen just for illustrating how one would think about testing for jumps using neural networks. It is by no means necessarily the “best’ architecture. This is definitely an area for future work. We hope to cover this in later posts.

Having decided on the architecture of the neural network, we still needed to  train it. The neural network was trained on 3000 observations from a processes that has jumps (generated using the Merton Jump model) and a process which does not have jumps (generated using GBM).  The neural network was trained using the neuralnet package in R.

Simulation study

Simulations were undertaken to assess how the neural network test performs against the Lee & Mykland Test (2008).  The underlying model being assumed is the basic Merton model discussed above.   Using simulations, we worked out the Probability of ACTUAL detection (the test being able to detect jumps in  a series that has jumps) and the probability of FALSE detection (the test incorrectly detecting jumps in a series of returns that doesn't have jumps) of each of the tests. The simulation was conducted at a daily frequency, using different combinations of the parameters. A more rigorous comparison would have to compare the two tests at different frequencies, and for large and small jumps.

We have summarized the results of the simulations conducted in the table below:

Based on the simulation results in the table above, the neural network test to perform better than the Lee & Mykland (2008) test. This is because the probability of actual detection for the neural network test is higher than for the Lee & Mykland (2008) test, and the probability of false detection is lower than that of the Lee & Mykland (2008) test.

Given that we have seen how the test performs on simulated data, we are now in a position to apply the test on data from the Johannesburg Stock Exchange.

Applying the Test to JSE Data

The Johannesburg Stock Exchange (JSE) building in Sandton. It has operated as a market place for the trading of financial products for nearly 125 years.

After seeing how the neural network test for jumps performs in simulations, we applied the test to 217 stocks which are listed on the Johannesburg Stock Exchange (JSE). The various stocks used in this post, categorized by industry, are shown in the table below.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 212,542评论 6 493
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,596评论 3 385
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 158,021评论 0 348
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,682评论 1 284
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 65,792评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 49,985评论 1 291
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,107评论 3 410
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,845评论 0 268
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,299评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,612评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,747评论 1 341
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,441评论 4 333
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,072评论 3 317
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,828评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,069评论 1 267
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,545评论 2 362
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,658评论 2 350

推荐阅读更多精彩内容

  • 十年光阴,何处安寻。只是在梦里,偶尔忆起。朴素为衣,素笺写不尽。贫弱的几笔,是我在想您。十年,十年,我想告诉您。 ...
    白笺阅读 140评论 0 5
  • 各种无人理会,这种感觉够差,够坏。 心里有话却无人可以诉说。 只有亲人靠谱。 早些睡吧,自我抛弃的人。
    肉头鬼阅读 297评论 0 0
  • 美人卷珠帘, 深坐蹙蛾眉。 但见泪痕湿, 不知心恨谁。
    5562d88ec370阅读 305评论 0 0
  • 若问情为何物,谁也说不太清楚。人类对自然、人文、社会、科技的研究可谓情有独钟,满世界都有这些研究机构,唯独没有情为...
    熊玲心理咨询阅读 528评论 0 1
  • C和他在心理诊所相遇,C的抑郁症症状有所缓解,只是来做定期检查。两人一起坐在诊室外面的椅子上,因为无聊而交谈起来。...
    Sharine火火阅读 218评论 0 1