Page 1 of 1

About %fractiles

Posted: Wed Jun 20, 2012 2:32 am
by sana
Dear all,
Please can anyone explain how rats calculate quantiles using %fractiles.
I tried to calculate quantiles (1%, 5% and 10%).
For a time series with 100 observations I expect that the quantile (1%) will give minimum value but it didn’t.

compute [vect] pvals=||.01,.05,.10||
compute [vect] VaR=%fractiles(z,pvals)
report(action=define,hlabels=||"P","VaR"||)
do i=1,3
report(atrow=i,atcol=1) pvals(i) VaR(i)
end do i
report(action=show)
*
stats(fractiles,nomoments) z

*****

P VaR
0.010000 -0.078292
0.050000 -0.027834
0.100000 -0.003563


Statistics on Series Z
Observations 100
Minimum -0.203602 Maximum 0.353522
01-%ile -0.078292 99-%ile 0.274005
05-%ile -0.027834 95-%ile 0.248616
10-%ile -0.003563 90-%ile 0.212617
25-%ile 0.041195 75-%ile 0.159917
Median 0.096485



Thank you
Sana

Re: About %fractiles

Posted: Wed Jun 20, 2012 8:23 am
by TomDoan
There are many ways to compute sample quantiles (fractiles), most of which are designed for very large data sets. RATS uses a formula (also used by Excel) which gives values which are consistent with "obvious" calculations for the main quantiles, like the median. For instance, if there are an odd number of data points, the median "should" be the center data point---not all algorithms will give that.

The RATS method is based upon the gaps, not the data points themselves. That is, with five data points

x1 x2 x3 x4 x5

x1 is the minimum (0th-ile), x2 is the 25th-ile, x3 is the median, x4 is the 75th-ile, x5 the maximum (100-th ile). The calculation is to take 1+f x (N-1) where f is the desired quantile. So f=.25 gives 1 + .25 * (4) = 2.

With 100 data points, the f=.01 is computed by taking 1+.01*99=1.99. So it's computed as .01 * x1 + .99 * x2.