Reputation:
Let's say I have a sample that could follow an inverse gamma distribution (see Empirical PDF).
I would like to estimate the shape parameter alpha and the scale parameter beta with something like fitdistr
. Is it possible?
I have tried the this solution (following https://stats.stackexchange.com/questions/31934/maximum-likelihood-estimation-of-inverse-gamma-distribution-in-r-or-rpy):
f <- function(x, a, b){
((b^a)/gamma(a))*((1/x)^(a-1))*exp(-b/x) #PDF Inv. Gamma
}
fitdistr(x, f, list(a=.01, b=.01))
but it does not work for me. It says: non-finite finite-difference value [2].
The data can be found at https://www.dropbox.com/s/j4n09w1sszcv0ud/data.txt?dl=0 .
Upvotes: 0
Views: 1793
Reputation:
I have the answer. It is as simple as
fit = MASS::fitdistr(1/x1, "gamma")
Upvotes: 1