Navigator
Generalized Hyperbolic
This toolbox contains necessary tools related to the skewed generalized t(
SGT
) and the generalized hyperbolic (GH) distributions. Distribution fitting is also included.
Toolbox
实现函数如下
函数文件 | 函数接口 | 附注 |
---|---|---|
ghcdf.m | p=ghcdf(x, Param, m, sigma) | Generalized Hyperbolic cumulative density function (cdf) |
ghfit.m | [parmhat, se, parmci, output]=ghfit(X, alpha, flag) | PARMHAT=ghfit(X)返回描述GH的最大似然估计,LAMBDA=PARMHAT(1) 为尾部指数参数, ZETA=PARMHAT(2) 为形状参数,RHO=PARMHAT(3) 为偏度参数;SE返回估计的标准误差;PARMCI 返回参数估计的95%置信区间;OUTPUT 返回结构化的输出包括拟合的偏度和峰度以及MLE; […]=GITFIT(X, ALPHA) 返回100(1-ALPHA) percent 参数估计的C.I.;FLAG=1 进一步给出估计的均值和标准差,PARMHAT(4) 为均值,PARMHAT(5) 为标准差 |
ghpdf.m | y=ghpdf(x, param, m, sigma) | GH函数的pdf |
ghcdf
计算GH
分布的累计概率密度函数(cdf
),根据传入参数Param, m, sigma
计算在x
处的值
%% GH的CDF计算
% 使用 Flexible distributions toolbox计算
X = returns(:, 1);
[parmhat, se, parmci, output] = ghfit(X, 0.05, 1);
p = ghcdf(0.001, parmhat(1:3));
RHO>0
表示GHD
为右偏,RHO<0
表示GHD
为左偏
ghfit
使用GH
分布拟合序列,在设置FLAG=1
的情况下可以得到拟合的偏度(skewness
)和峰度(kurtosis
)
[parmhat, se, parmci, output] = ghfit(X, 0.05, 1);
ghpdf
GH
分布的pdf
函数,当
ζ
→
∞
\zeta\to\infty
ζ→∞且
ϱ
=
0
\varrho=0
ϱ=0时,GH
概率密度函数变为normal distribution
,当
ϱ
<
0
\varrho<0
ϱ<0,GH
分布呈现左偏的形状,当
ϱ
>
0
\varrho>0
ϱ>0,GH
分布呈现右偏的形状
ghpdf(x, Param, m, sigma)
给出在点x
处的pdf
值,拟合收益率序列如下图所示
% 拟合分布
sample_ret = returns(:, 1);
xmin = min(sample_ret)-0.01;
xmax = max(sample_ret)+0.01;
xp = xmin: 0.01:xmax;
[parmhat, se]=ghfit(sample_ret);
x_mean = mean(sample_ret); % 一阶矩信息
x_sigma = std(sample_ret); % 二阶矩信息
yp = ghpdf(xp, parmhat, x_mean, x_sigma);
hold on;
yyaxis left; % 激活左轴
plot(xp, yp, 'b--');
yyaxis right; % 激活右轴
histogram(X, 'Normalization', 'probability', 'FaceAlpha', 0.4);
legend('GH-fitted', 'returns');
hold off;
Skew Generalized t
SGT(skew generalized t)
是一种五参数分布,pdf
如下
形状参数 η > 0 , ψ > 2 \eta>0, \psi>2 η>0,ψ>2,偏度参数 ∣ λ ∣ < 1 |\lambda|<1 ∣λ∣<1, B ( ⋅ ) B(\cdot) B(⋅)为 β \beta β函数, s g n ( ⋅ ) sgn(\cdot) sgn(⋅)为符号函数, μ \mu μ为位置参数, θ \theta θ为正则化因子,使得 V ( x ) = σ 2 \mathbb{V}(x)=\sigma^2 V(x)=σ2
sgtcdf
返回在x
点处的累计概率密度
p = sgtcdf(x, Param, m, sigma)
sgtfit
% sgtfit parameter estimates and confidence intervals for skewed generalized t data
% 其余和GH类似
sgtinv
计算Inverse of skewed generalized T cumulative density function
的CDF
sgtpdf
SGT
分布对数据进行拟合,当
η
=
2
\eta=2
η=2时,函数成为standardized student's t-distribution with d.o.f ψ
. 当
ψ
=
∞
\psi=\infty
ψ=∞函数变为GED(η)
. 当
η
=
2
,
ψ
=
∞
\eta=2,\psi=\infty
η=2,ψ=∞时,SGT
变为skew normal
.
%% SGT的CDF计算
[sgt_p, se]=sgtfit(sample_ret);
yp = sgtpdf(xp, sgt_p, x_mean, x_sigma);
hold on;
yyaxis left;
plot(xp, yp, 'b--');
yyaxis right;
histogram(sample_ret, 'Normalization', 'probability', 'FaceAlpha', 0.4);
legend('SGT-fitted', 'returns');
hold off;
sgtrnd
从Skewed Generalized T
分布中进行抽样
skewtfit
Skewd Distributions:Fernandez and Steel(1998) proposed a quite general approach that allows the introduction of skewness in any continuous unimodal and symmetric distribution by changing the scale at each side of the mode
f
(
z
∣
ξ
)
=
2
ξ
+
1
ξ
[
f
(
ξ
z
)
H
(
−
z
)
+
f
(
z
ξ
)
H
(
z
)
]
f(z\mid \xi)=\frac{2}{\xi+\frac{1}{\xi}}[f(\xi_z)H(-z)+f(\frac{z}{\xi})H(z)]
f(z∣ξ)=ξ+ξ12[f(ξz)H(−z)+f(ξz)H(z)]
其中
0
<
ξ
<
∞
0<\xi<\infty
0<ξ<∞为形状参数,描述函数的非对称性程度,
ξ
=
1
\xi=1
ξ=1为对称分布,
f
(
z
∣
ξ
=
1
)
=
f
(
z
)
f(z\mid\xi=1)=f(z)
f(z∣ξ=1)=f(z).
H
(
z
)
=
(
1
+
s
g
n
(
z
)
)
/
2
H(z)=(1+sgn(z))/2
H(z)=(1+sgn(z))/2为Heaviside unit step funciton
.
[parmhat, se, parmci, output]=skewtfit(X, alpha, flag)
References
Flexible distributions toolbox
Highly flexible distributions to fit multiple frequency financial returns