# FITDIST: Why am I getting this shape for the gamma distribution?

I am using fitdist to fit a gamma distribution based on this link: How to draw fitted graph and actual graph of gamma distribution in one plot?

My code is as follows:

# save density function of
den <- density(brain$$freq_1) dat <- data.frame(x = den$$x, y = den\$y)
ggplot(data = dat, aes(x = x, y = y)) +
geom_point(size = 1) +
theme_classic()


# fit gamma dist:
fit.params <- fitdistr(x, "gamma", lower = c(0, 0))

summary(fit.params)
Length Class  Mode
estimate 2      -none- numeric
sd       2      -none- numeric
vcov     4      -none- numeric
loglik   1      -none- numeric
n        1      -none- numeric

# plot density and fitted gamma dist:

ggplot(data = dat, aes(x = x,y = y)) +
geom_point(size = 1) +
geom_line(aes(x=dat$$x, y=dgamma(dat$$x,fit.params$$estimate["shape"], fit.params$$estimate["rate"])), color="red", size = 1) + theme_classic()


[]

My question is why do I get this strange looking gamma distribution peaking out at zero?

• Presumably because your data have a very heavy right tail (strong right skew) -- if you fit a gamma, that implies a very peaked distribution. What does a histogram of the log of your variable look like? – Glen_b -Reinstate Monica Feb 20 at 3:33