简体   繁体   English

估计给定分位数的逆伽马分布的参数

[英]Estimate the parameters of an inverse gamma distribution given quantiles

I'm trying to estimate the parameters of an inverse Gamma distribution given its 0.025 and 0.975 quantiles.我试图估计逆 Gamma 分布的参数,因为它的分位数为 0.025 和 0.975。

Currently, I've found rriskDistributions::get.gamma.par which gives me the estimation of parameters given quantiles of a Gamma distribution.目前,我发现rriskDistributions::get.gamma.par可以让我估计给定 Gamma 分布的分位数的参数。 However, I cannot figure out the relationship between the quantiles of Gammas and inverse Gammas.但是,我无法弄清楚 Gamma 的分位数和逆 Gamma 之间的关系。

How should I continue, or is there a package that can do this for me?我应该如何继续,或者是否有可以为我执行此操作的软件包?

You can write your own objective function that computes the squared deviation between the computed quantiles for a particular set of inverse-gamma parameters and the target quantiles:您可以编写自己的目标函数,计算一组特定逆伽马参数的计算分位数与目标分位数之间的平方偏差:

library(invgamma)
objfun <- function(p,target) {
    qq <- qinvgamma(c(0.025,0.975),shape=p[1],rate=p[2])
    sum((qq-target)^2)
}

Then use optim() to minimize:然后使用optim()最小化:

## example
tt <- qinvgamma(c(0.025,0.975), shape=2,rate=2)
optim(par=c(1,4),  ## starting values; must be sensible
      fn=objfun,
      target=tt)
$par
[1] 1.980279 1.948050

$value
[1] 9.0741e-05

$counts
function gradient 
      61       NA 

$convergence
[1] 0

$message
NULL

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM