r - 如何计算 R 中拟合 T 分布的矩(均值、方差、偏度、峰度)?
问题描述
我已经将样本数据(标准普尔 500 指数回报)拟合到 T 分布,现在必须计算前四个时刻。但是,我不知道如何处理它,我的代码如下所示:这基本上是情节以及我如何将其与 rugarch 配合使用。有什么方法可以快速计算方差/均值/峰度/偏度?谢谢
library(QRM)
library(rugarch)
dist_st2 <- fitdist("std", training_sample,
control=list(tol=1e-20, delta=1e-6))
dist_st2$pars
dist_st2$pars["sigma"]
density_st2 <- ddist(distribution = "std", x,
mu = dist_st2$pars["mu"],
sigma = dist_st2$pars["sigma"],
shape = dist_st2$pars["shape"])
hist(training_sample, freq = FALSE, breaks = 40,
ylim = c(0, 0.85), xlim = c(-5, 5), border = "gray")
points(x, density_norm, type = "l", lwd = 2, col = COLORS[1])
points(x, density_st2, type = "l", lwd = 2, col = COLORS[2])
lines(density_emp, lwd = 2, lty = 2, col = COLORS[3])
legend("topleft", lty = c(1, 1, 2), col = COLORS[1:3], bty = "n",
legend = c("Normal distribution", "Student-t distribution",
"Empirical distribution"))
解决方案
我不能肯定地说,因为我不熟悉 rugarch 包并且文档有点肤浅。但在我看来,你已经拥有它们了。
dist_st2$pars["mu"]
是第一个时刻。dist_st2$pars["sigma"]^2
应该是第二个(请不要将标准差平方才能得到方差)。dist_st2$pars["shape"]
是第四个。- 应该有
dist_st2$pars["skew"]
第三个。
推荐阅读
- vba - 尝试通过从设计器中的 ControlSource 调用函数来填充 Access ContinuousForm 中的 ComboBox(每行不同的记录集)
- c# - 通过反射访问模型类的布尔值并访问它们的值
- visual-studio-2019 - 使用多个 IsEmbedded 引用时的验证错误
- node.js - Blob Storage Azure 和 javascript,如何列出特定 blob 的所有快照
- python - python kmeans 聚类真实数据质心
- mysql - 如何在mysql中按给定年份计算月份和成员明智总数
- powershell - Powershell AD 脚本无法导出到 csv
- multithreading - Parallel For-Each vs Scatter Gather in mule
- extjs - Extjs 网格过滤器为空且不为空复选框
- java - 如何将持续时间转换为秒?