bashtage / arch

ARCH models in Python
Other
1.32k stars 246 forks source link

Mathematical meaning of stat functions #598

Closed antoscha closed 2 years ago

antoscha commented 2 years ago

Hello,

Could you please explain why results of functions obtained from arch.univariate.Distribution differ from ones of scipy.stats?
Let's take, for example, t-Student:

>>> stats.t.ppf(0.95, df=3)
2.3533634348018264
>>> t = StudentsT()
>>> t.ppf(0.95, [3])
1.358715012583857

Maybe I do something wrong? How to make results matching? I tried to figure out it from code, but underlying math is quite not obvious there.

bashtage commented 2 years ago

The students's t in arch is standardized so that Var(X) = 1 for any value of nu. The usual Student's T has a variance of nu / (nu - 2). In your example, the variance is 3/1 so that that standard deviation is about 1.73. Rescaling the quantiles you have

In [2]: 2.3533634348018264/1.358715012583857
Out[2]: 1.732050807568877

The only requirement for the Standardized Student's t in arch is that nu > 2.