I am trying to fit a three parameter inverse gamma distribution to my data in either R or Python. I would like to do this using maximum likelihood estimation (MLE).

The pdf of the three parameter inverse gamma is given by:

enter image description here

Where Γ is the gamma function, ρ is the shape, α is the scale and s is the location parameter

I haven't spotted an R package that can perform MLE to this distribution directly (if you know of one, please let me know!). So I think this leaves either:

  • (A) working out the log-likelihood function of the formula
  • (B) transforming the data to a gamma distribution. However, this distribution only has two parameters so I'm not clear on how I would calculate the third parameter (I'm not a very mathematical person!).

Any help on a method to use MLE to fit an inverse gamma distribution to my data would be much appreciated! Many thanks in advance.


1 Answer 1


Since you know the density, you can just use fitdistr.

# Sample data
x <- rinvgamma(1000, 1,2)

f <- function(x, rho, a, s)
  1/(a*gamma(rho)) * (a / (x-s))^(rho+1) * exp( - a/(x-s) )
fitdistr( x, f, list(rho=1, a=1, s=0) )
  • $\begingroup$ Thank you for your solution Vincent. Much appreciated! Will try this now. $\endgroup$
    – Faith
    Jul 9, 2012 at 16:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.