Skip to content
Prev 11471 / 15274 Next

Fitting distributions to financial data using volatility model to estimate VaR

Moving to R-SIG-Finance which seems to be the correct mailing list.

On Sun, Apr 7, 2013 at 8:41 AM, Stat Tistician
<statisticiangermany at gmail.com> wrote:
Let's clean this up:

library(xts)
# Load data into an xts object called "dat" here.

library(TTR)
vola <- runSD(dat, 10) # volatility is a ttr function name, so not using that
# Similarly, quantile is a function name and not a good idea to override

quan <- qnorm(0.975, mean = 0, sd = vola)
Can just do
plot(vola) # if vola is an xts object. Also, the c() is superfluous
(and arguably dangerous) there
library(PerformanceAnalytics)
chart.BarVaR(dat) # is probably easier.
Be careful here -- it certainly has a standard deviation, just not a
parameter called sigma. Keeping those two ideas distinct is important
here. They only coincide for the normal distribution. (Among the major
ones)

You're also using something other than the classical t-distribution
(as defined by the all-hallowed Wikipedia) if it's a three parameter
distribution.
No -- I believe that the t-distribution has sigma^2 = v / (v-2).

But even with that correction, it's not what I would do.

I would first fit beta, nu, and mu by ML and then estimate sigma from there.

Without checking, I'm not positive that sample standard deviation
gives a particularly good estimator for the df of a t-distribution. It
wouldn't surprise me if it did though.

In that same vein, I'm not sure this process gives an estimate that's
much superior to the rolling empirical standard deviation. Though it
might be useful for forward looking predictions...

Bigger question -- have you looked at TTR::volatility or
PerformanceAnalytics::VaR. There's a lot of useful stuff in there.

I'll try to read through the rest of this later -- about to have
dinner with the family,
Michael