对于双曲线分布,如何确定R中事件的概率?
我想知道如何计算对于双曲线分布,如何确定R中事件的概率?,r,probability-density,probability-theory,hyperbolic-function,R,Probability Density,Probability Theory,Hyperbolic Function,我想知道如何计算p≥ -0.0001。我对数学、统计学和R都是新手 我目前正在对R中的一些利差数据进行建模。我能够将数据建模为特定分布(在以下示例中,这是双曲线),并执行似然比测试,以确认使用指定分布的可行性 在我的头脑中,一旦我获得了分布,我现在能够更可靠地计算我的概率,因为我更准确地理解了曲线下的面积 我曾假设,一旦分布匹配,我将能够进行与t统计相似的测试,但我不知道如何做到这一点 我看到了pnorm(x)函数,也看到了phyper,但是我不知道如何简单地计算p≥ -0.0001 下面是我的
p≥ -0.0001
。我对数学、统计学和R都是新手
我目前正在对R中的一些利差数据进行建模。我能够将数据建模为特定分布(在以下示例中,这是双曲线),并执行似然比测试,以确认使用指定分布的可行性
在我的头脑中,一旦我获得了分布,我现在能够更可靠地计算我的概率,因为我更准确地理解了曲线下的面积
我曾假设,一旦分布匹配,我将能够进行与t统计相似的测试,但我不知道如何做到这一点
我看到了pnorm(x)
函数,也看到了phyper
,但是我不知道如何简单地计算p≥ -0.0001
下面是我的代码,非常感谢您的帮助
`#
库(ghyp)
图书馆(时间系列)
#转换为时间序列
E答案已发布,并涉及pghyp
功能
@fg nu
# Coverting to Time Series
E <- timeSeries(A[,"Spread"])
# Fitting
ef <- (density(E))
ghdfit <- fit.ghypuv(E,symmetric = FALSE, control = list(maxit = 1000))
hypfit <- fit.hypuv(E,symmetric = FALSE, control = list(maxit = 1000))
nigfit <- fit.NIGuv(E,symmetric = FALSE, control = list(maxit = 1000))
# Density
ghddens <- dghyp(ef$x, ghdfit)
hypdens <- dghyp(ef$x, hypfit)
nigdens <- dghyp(ef$x, nigfit)
nordens <- dnorm(ef$x, mean = mean(E),sd = sd(c(E[,1])))
col.def <- c("black","red","green","orange")
plot(ef, xlab = " Spread ", ylab = expression(f(x)),ylim = c(0,50), main ='CABLE - 3 Day Comparison across 28 Years')
lines(ef$x, ghddens, col = "red")
lines(ef$x, hypdens, col = "blue")
lines(ef$x, nigdens, col = "green")
lines(ef$x, nordens, col = "orange")
legend("topleft", legend = c("Empirical","GHD","HYP","NIG","NORM"), col = col.def, lty = 1)
# QQ Plot
qqghyp(ghdfit, line = TRUE, ghyp.col = "red", plot.legend = FALSE, gaussian = FALSE, main = " ", cex = 0.8)
qqghyp(hypfit, add = TRUE, ghyp.pch = 2, ghyp.col = "green", gaussian = FALSE, line = FALSE, cex = 0.8)
qqghyp(nigfit,add = TRUE, ghyp.pch = 3, ghyp.col = "orange", gaussian = FALSE, line = FALSE, cex = 0.8)
legend("topleft", legend = c("GHD","HYP","NIG"), col = col.def[-c(1,5)], pch = 1:3)
# Diagnostic
options(scipen=999)
AIC <- stepAIC.ghyp(E, dist = c("ghyp","hyp","NIG"), symmetric = FALSE, control = list(maxit=1000))
LRghdnig <- lik.ratio.test(ghdfit,nigfit)
LRghdhyp <- lik.ratio.test(ghdfit,hypfit)