# Cont model – Part II

**R snippets**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

In my last post I have investigated properties of Cont model (you can download the paper here). Today I would like to show how we can use simulations to further simplify its analysis.

First let us start with the observation that the model does not really require two parameters d and l as they are directly linked. If we multiply d by 2 and divide l by 2 we obtain exactly the same simulated returns path (scaled by 2). Let me motivate this result using simulation. The code that performs verification is simple (for explanation of the code logic look at my previous post):

**<-**

**function**

**(**burn.in, reps, n, d, l ,s

**)**

**{**

**<-**rep

**(**0, n

**)**

**<-**rnorm

**(**reps, 0, d

**)**

**<-**rep

**(**0, reps

**)**

**for**

**(**i

**in**1

**:**reps

**)**

**{**

**[**i

**]**

**<-**

**(**sum

**(**sig

**[**i

**]**

**>**tr

**)**

**–**sum

**(**sig

**[**i

**]**

**<**

**(-**tr

**)))**

**/**

**(**l

*****n

**)**

**[**runif

**(**n

**)**

**<**s

**]**

**<-**abs

**(**r

**[**i

**])**

**}**

**(**r

**[**burn.in

**:**reps

**])**

**}**

**(**1

**)**

**<-**100

**<-**runif

**(**sim.points, 0.002, 0.01

**)**

**<-**runif

**(**sim.points, 5, 10

**)**

**<-**runif

**(**sim.points, 0.01, 0.1

**)**

**<-**runif

**(**sim.points, 1, 2

**)**# comparison multiplier

**<-**runif

**(**sim.points

**)**# common random numbers seeds

**(**mapply

**(**

**function**

**(**d, l, s, m, seed

**)**

**{**

**(**seed

**)**

**<-**cont.run

**(**1000, 10000, 1000, d, l ,s

**)**

**(**seed

**)**

**<-**cont.run

**(**1000, 10000, 1000, d

**/**m, l

*****m ,s

**)**

**(**r1

**/**m

**–**r2

**)**

**}**, d, l, s, m, seeds

**))**# -2.775558e-17 1.387779e-17

We can see that r1/m and r2 vectors are almost identical in all 100 simulations.

This finding means that we can limit ourselves to analysis of d*l product in simulation output analysis. So we go back to sim_output.txt file and modify the visualization as follows:

**(**lattice

**)**

**<-**read.table

**(**“sim_output.txt”, head

**=**T,

**=**rep

**(**“numeric”, 4

**))**

**$**dl

**<-**data.set

**$**d

*****data.set

**$**l

**$**cs

**<-**cut

**(**data.set

**$**s, seq

**(**0.01, 0.1, len

**=**10

**))**

**$**cdl

**<-**cut

**(**data.set

**$**dl, seq

**(**0, 0.2, len

**=**11

**))**

**<-**aggregate

**(**k

**~**cdl

**+**cs, data

**=**data.set, mean

**)**

**(**regions

**=**list

**(**col

**=**topo.colors

**(**100

**)))**

**(**k

**~**cdl

**+**cs, data

**=**sum.data,scales

**=**list

**(**x

**=**list

**(**rot

**=**90

**))**,

xlab **=** “d * l”, ylab **=** “s”**)**

Here is the final plot showing average k as a function of d*l and s:

We can see that the model produces excess kurtosis when d*l is small. What does it mean? In this case we have low d and low l. So new incoming information has low standard deviation but daily returns are allowed to be large. The conclusion is that kurtosis will be present if there is low level of trading on the market (the sum sum**(**sig**[**i**]** **>** tr**)** **+** sum**(**sig**[**i**]** **<** **(-**tr**))** is relatively low).

We will use simulation again to verify this hypothesis. Here is the code with added trading volume variable (t):

**<-**

**function**

**(**burn.in, reps, n, d, l ,s

**)**

**{**

**<-**rep

**(**0, n

**)**

**<-**rnorm

**(**reps, 0, d

**)**

**<-**rep

**(**0, reps

**)**

**<-**rep

**(**0, reps

**)**

**for**

**(**i

**in**1

**:**reps

**)**

**{**

**[**i

**]**

**<-**

**(**sum

**(**sig

**[**i

**]**

**>**tr

**)**

**–**sum

**(**sig

**[**i

**]**

**<**

**(-**tr

**)))**

**/**

**(**l

*****n

**)**

**[**i

**]**

**<-**

**(**sum

**(**sig

**[**i

**]**

**>**tr

**)**

**+**sum

**(**sig

**[**i

**]**

**<**

**(-**tr

**)))**

**/**n

**[**runif

**(**n

**)**

**<**s

**]**

**<-**abs

**(**r

**[**i

**])**

**}**

**(**kurtosis

**(**r

**[**burn.in

**:**reps

**])**, mean

**(**t

**[**burn.in

**:**reps

**]))**

**}**

**<-**100

**<-**runif

**(**sim.points,0.001,0.01

**)**

**<-**runif

**(**sim.points,5,20

**)**

**<-**runif

**(**sim.points,0.01,0.1

**)**

**<-**mapply

**(**

**function**

**(**d, l, s

**)**

**{**

**(**1000, 10000, 1000, d, l ,s

**)**

**}**, d, l, s

**)**

**<-**t

**(**data.set

**)**

**(**data.set

**)**

**<-**c

**(**“kurtosis”, “volume”

**)**

**<-**data.set

**[**, 2

**:**1

**]**

**(**mar

**=**c

**(**4, 4, 1, 1

**))**

**(**data.set

**)**

The resulting plot confirms our reasoning:

The final question, that I will leave open here, is whether the observed relationship is an artifact of the model or the relationship that currently I am working on to verify empirically.

**leave a comment**for the author, please follow the link and comment on their blog:

**R snippets**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.