偏斜广义误差分布的累积分布函数,用于 QQ 图。

huangapple go评论60阅读模式
英文:

Cumulative Distribution Function of the skewed generalized error distribution for qq-plot

问题

I'm trying to calculate the cumulative distribution function of the skewed generalized error distribution with the probability density function from Theodossiou (http://www.mfsociety.org/modules/modDashboard/uploadFiles/journals/MJ~0~p1a4fjq38m1k2p45t6481fob7rp4.pdf):

偏斜广义误差分布的累积分布函数,用于 QQ 图。

And in R it looks like this:

psi <- -0.09547862
m <- 0.1811856
g <- -0.1288893
d <- 0.8029088

c <- (2/(1+exp(-g)))-1
p <- exp(psi)

y <- function(x) ((d**(1-(1/d)))/(2*p))*gamma(1/d)**(-1)*exp(-(1/d)*((abs(x-m)**d)/((1+sign(x-m)*c)**(d)*p**(d))))

I do this is to fit the skewed generalized error distribution to my data and assess the distributions fit to my data by creating a qq-plot. So now I need to calculate the cumulative distribution function and then the inverse cdf. For the inverse cdf I plan to use the inversion-function from the GofKernel-Package. But for this I need the cdf. Is there any way to calculate that with numerical integration in R?

英文:

I´m trying to calculate the cumulative distribution function of the skewed generalized error distribution with the probability density function from Theodossiou(http://www.mfsociety.org/modules/modDashboard/uploadFiles/journals/MJ~0~p1a4fjq38m1k2p45t6481fob7rp4.pdf):

偏斜广义误差分布的累积分布函数,用于 QQ 图。

And in R it looks like this:

psi <- -0.09547862
m <- 0.1811856
g <- -0.1288893
d <- 0.8029088

c <- (2/(1+exp(-g)))-1
p <- exp(psi)

y <- function(x) ((d**(1-(1/d)))/(2*p))*gamma(1/d)**(-1)*exp(-(1/d)*((abs(x-m)**d)/((1+sign(x-m)*c)**(d)*p**(d))))

I do this is to fit the skewed generalized error distribution to my data and assess the distributions fit to my data by creating a qq-plot. So now I need to calculate the cumulative distribution function and then the inverse cdf. For the inverse cdf I plan to use the inversion-function from the GofKernel-Package. But for this I need the cdf. Is there anyway to calculate that with numerical integration in R?

答案1

得分: 0

为了通过积分获取累积函数,您可以将x值传递给一个从适当的极低值积分到上限为x的函数。

# 首先查看密度函数
plot(y(x) ~ x)

cum <- sapply(x, function(x) integrate(y, -10, x)$value)
plot(cum ~ x)

# 因此,反函数就是`x`关于`cum`的函数
plot(x ~ cum)

请注意,这是给定的代码的翻译部分。

英文:

To get a cumulative function via integration you can pass the x-values to a function that integrates from a suitable extreme low value to an upper limit that is x

 # First look at the density function
 plot( y(x) ~ x )


 cum &lt;- sapply(x, function(x) integrate(y,-10, x)$value )
 plot( cum ~ x)
 
 # So the inverse is just `x`  as a function of `cum`
 plot( x ~ cum)

答案2

得分: -1

一般来说,如果您想要估计累积分布函数,请使用以下方式使用ecdf函数:

x <- seq(-10, 10, 0.1)
Fn <- ecdf(y(x))
plot(Fn)

如果您想要可视化两个数据集的相似性,请使用qqplot如下所示:

y1 <- y(x)            # 从您的函数获取数据
y2 <- rnorm(100)      # 一些通用数据
qqplot(y1, y2)        # 如果这两个数据集来自相同的分布,您应该看到一条直线
英文:

In general, if you want to estimate the cumulative distribution function, use the function ecdf as follows:

x &lt;- seq(-10,10,0.1)
Fn &lt;- ecdf(y(x))
plot(Fn)

If you want to visualize how two data sets are similar, use qqplot as follows:

y1 &lt;- y(x)            # from your function
y2 &lt;- rnorm(100)      # some generic data
qqplot(y1, y2)        # if the two data sets are from the same 
                      # distribution, you should see a straight line

huangapple
  • 本文由 发表于 2023年2月16日 05:28:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/75465607.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定