I wrote a simulation of a geometric Brownian motion which works like this:
- ${ t }_{ i }-{ t }_{ i-1 } \sim Exp(\lambda )$
- ${ Z }_{ i }\sim N(0,1)$
- ${ Y }_{ i }\sim { e }^{ \sigma \sqrt { { t }_{ i }-{ t }_{ i-1 } } { Z }_{ i }+\left( \mu -\frac { { \sigma }^{ 2 } }{ 2 } \right) \left( { t }_{ i }-{ t }_{ i-1 } \right) }$
- $S({ t }_{ 1 })=S({ t }_{ 0 })\times { Y }_{ 1 }$
- $S({ t }_{ 2 })=S({ t }_{ 1 })\times { Y }_{ 2 }=S({ t }_{ 0 })\times { Y }_{ 1 }\times { Y }_{ 2 }$
- $S({ t }_{ k })=S({ t }_{ k-1 })\times { Y }_{ k }=S({ t }_{ 0 })\times { Y }_{ 1 }\times { Y }_{ 2 }\times\dots \times{ Y }_{ k }$
In order to verify that my code is correct, I tried to estimate the parameters of my simulation from samples taken from it.
My parameter estimation strategy was like this:
I knew $\mathrm{E}[{ t }_{ i }-{ t }_{ i-1 }] = \frac{1}{\lambda}$
Since $\ln { \frac { S({ t }_{ i+1 }) }{ S({ t }_{ i }) } \sim N(\tilde { \mu } ,\tilde { \sigma } ) } $, I just used the parameter estimation techniques for normal distributions to estimate $\tilde { \mu }$ and $\tilde { \sigma }$.
Since $\tilde { \sigma } = \sigma \sqrt{ { t }_{ i }-{ t }_{ i-1 }}$, I reasoned that $\sigma = \frac { \tilde { \sigma } }{ \sqrt{ \mathrm{E}[{ t }_{ i }-{ t }_{ i-1 }]} } $
Since $\tilde { \mu } = \left( \mu -\frac { { \sigma }^{ 2 } }{ 2 } \right) \left( { t }_{ i }-{ t }_{ i-1 } \right) $, I reasoned that $\mu = \frac { \tilde { \mu } }{ \mathrm{E}[{ t }_{ i }-{ t }_{ i-1 }] } + \frac { { \sigma }^{ 2 } }{ 2 }$ where I used the $\sigma$ estimated from above.
Is my logic correct? I did not use any formal reasoning, so I am not confident my method for estimating parameters is correct. Can someone help me?
This is not homework. I am just trying to write program which behaves like the financial markets.