Monday 18 November 2013

VaR II: Parametric normal and lognormal

Let us see how to calculate VaR in practice. We'll start with the simplest cases (which are used from time to time in practice), and work our way up. First, let's again collect definitions of return
\begin{equation} \label{linret_did}
 \mathrm{r}_t:= \frac{p_{t+1}}{p_t} -1.
\end{equation}
of logreturn
\begin{equation} \label{logret_did}
\ell_t := \log\left(\frac{p_{t+1}}{p_t}\right).
\end{equation}
and what we figured out about calculating VaR based on return,
\begin{equation} \label{VaRcont}VaR_{99\%} = F_{\mathrm{r}_t}^{-1}(1\%) = r_{1\%},\end{equation}
based on logreturn
\begin{equation}\label{VaRlogret}
 VaR_{99\%} = r_{1\%} = e^{F_{\ell_t}^{-1}(1\%)} -1.
\end{equation}
all beautifully explained in the previous post on VaR VaR I: What is it? Basic setup.

Normally distributed asset
If the underlying asset price \(p_{t+1}\) is normally distributed then, because of the definition of return~\eqref{linret_did}, the return is also normally distributed and this makes the math easy. Is this a reasonable assumption? Not really, it says that negative prices are possible! I've never seen a cow that cost \(-\$100\)*. But for short time horizons, such as when \(t\) is counting days, it can be a reasonable approximation.

Using Historical data** (or perhaps implied information about the future***), let's say that we have fit a normal distribution with average \(\mu\) and standard deviation \(\sigma\) to our return, thus we're assuming that \( \mathrm{r}_t \sim \mathcal{N}(\mu, \sigma^2).\) Fortunately, there always exists an \(r_{1\%}\) such that \(r_{1\%}= F_{ \mathrm{r}_t}^{-1}(1\%)\) for the normal c.d.f is a surjective function over real numbers.  Thus we can use~\eqref{VaRcont} to calculate VaR. The problem is that most mathy software systems, like Matlab or Mathematica, only have the inverse cumulative of the standard normal variable \(Z \sim \mathcal{N}(0,1).\) We need to figure out what our inverse is.  Panic not, unknown reader. You can build any normal variable by appropriate summing and multiplying constants to the standard normal variable \(Z \sim \mathcal{N}(0,1).\) In our case, \(\mathrm{r}_t\) can be written as
\[ \mathrm{r}_t = \mu + \sigma Z.\]
Because of this, you can calculate \(F_{ \mathrm{r}_t}(r)\) using the standard normal cumulative function \(\Phi(r) = \mathbb{P}\left(Z \leq z\right).\) Observe
\begin{align*}
F_{ \mathrm{r}_t}(r) &= \mathbb{P}\left( \mathrm{r}_t \leq r\right) \\
&= \mathbb{P}\left( \mu + \sigma Z \leq r\right)\\
&= \mathbb{P}\left( Z \leq \frac{r-\mu}{\sigma}\right) \quad \mbox{(Subtract by \(\mu\), divide by \(\sigma\) inside)}\\
& = \Phi\left(\frac{r-\mu}{\sigma}\right).  \quad \mbox{(Definition of the standard normal cumulative)}
\end{align*}
To find the inverse of \(F_{ \mathrm{r}_t}(r)\), let's name  \(y = F_{ \mathrm{r}_t}(r)\) as is customary in calculus books and apply
  \(\Phi^{-1}\), the inverse of the standard cdf, to both sides of the above equation
\[  \Phi^{-1}(y) = \frac{r-\mu}{\sigma}\]
and isolating \(r\), we find that
\begin{align}\label{norminv}
F_{ \mathrm{r}_t}^{-1}(y) = r = \Phi^{-1}(y)\sigma + \mu.
\end{align}
With this we can plug in \(r_{1\%}\) to find that \(y = F_{ \mathrm{r}_t}(r_{1\%}) = 1\%\) and
\begin{equation}\label{VARnorm1}
VaR_{99\%} = r_{1\%}  = \Phi^{-1}(1\%)\sigma + \mu.
\end{equation}
Where \(\Phi^{-1}(1\%)\) is just some number that can be calculated, and is approximately  \(-2.3263\).

Lognormally distributed asset
This is a bit more reasonable. At least only positive prices are plausible, for allowing negative prices was positively preposterous! You see, lognormal random variables can only assume positive values, and the lognormal distribution sort of fits that of past asset returns. Now it's more convenient to work directly with the lognormal return~\eqref{logret_did}, for if \(p_{t+1}\) is lognormal then, by definition the definition of lognormal random variables, \(\ell_t\) is normal random variable. Say we have fit a normal distribution with mean \(\mu\) and standard deviation \(\sigma\)  for our random variable \(\ell_t\), i.e. \(\ell_t \sim \mathcal{N}(\mu,\sigma).\)  We just saw what is the inverse of a normal variable~\eqref{norminv}, thus we can apply~\eqref{VaRlogret} directly to find
\begin{equation}\label{VARlog1}
VaR_{99\%} = r_{1\%}  = e^{\Phi^{-1}(1\%)\sigma + \mu} -1.
\end{equation}
Interesting fact: The formula for VaR based on normal returns~\eqref{VARnorm1} is equivalent to the first-order Taylor approximation of the VaR formula for normal logreturn~\eqref{VARlog1}. So what? Well, if you assume that lognormal distribution of our asset is the  ``true'' model, then using~\eqref{VARnorm1} as a proxy is ok as long as \(\sigma\) and \(\mu\) are very small.

VaR for general and sample distributions
Calculating VaR for a general distribution poses an extra challenge: Cumulative distribution functions are not invertible, in general. In other words, there simply might not exist a unique value \(r_{1\%}\) that sets it's \(F_{r_t}\) to \(1\%\). This often occurs in practice because.  Why? Because instead of using a known distribution for our return, people often make a nifty change to historical returns to build a sample distribution. Is this ideal? No, but it's also not mere witch-doctery and it's an improvement over our previous normal and lognormal assumptions. For before, not only did we use past data to build our future distribution, but we also imposed a very specific distribution on our returns (normal or lognormal). I will go into detail in a future post on exactly how to do this, but for now assume we have built a sample cdf function such as the one in this figure:


Note that based on the figure, any \(r \in [-0.3694, -0.2294]\) is such that \(F(r) = 1\%\). This is the problem: we can't invert \(F(r).\) So which \(r\) do we choose to be our VaR? People who work in risk are inherently pessimistic, so we choose the worst out of these suitable returns to be our VaR. In other words, VaR of \(99\%\) is the lowest return for which the \(1\%\) lowest returns are still below it. Formally
\[VaR_{99\%} := \min\{r \in \mathbb{R} \, | \,  F(r) \geq 1\% \}.\]
In the above example this would be \(VaR_{99\%} = -0.3694\), ergo, with 99\% chance, we will not lose more then \(36.94\%\) of our assets.

Similarly, for any given confidence level \(\beta \in [0, 1]\) we can define
\[VaR_{\beta} := \min\{r \in \mathbb{R} \, | \,  F(r) \geq 1- \beta\}.\]
Though we have focused on what to do with a sample distribution, this is in fact the general definition of VaR. For the more mathy type, ask yourself, why is it that VaR given as such is always defined? Does this minimum always exist?

Next we'll look at what really matters: Calculating the VaR of a portfolio of assets.

* Ignore possible storage or disposing costs that make negative prices a possibility.
**I would suggest using Exponentially Weighted Moving Average to do this.
***Say what? Interested, ask for it on the blog