I have a vector that I'm trying to fit to a distribution using the fitdistrplus
package in R. I think that I am getting close, but based on my results I feel like I can get closer. Here are the values I am trying to fit and the code I have produced so far.
library(fitdistrplus)
samplevec <- c(435, 278, 4579, 4102, 14988, 552, 469, 22461, 189, 18799, 82,
1387, 1937, 13527, 22759, 239, 11121, 427, 13471, 16903, 17569,
7076, 3215, 25895, 72, 2281, 2295, 1169, 11156, 428, 409, 1564,
335, 262, 7638, 28006, 24967, 2358, 1577, 2051, 148, 14535, 6270,
480, 4038, 322, 1409, 845, 3604, 252, 24505, 8327, 21417, 1169,
109, 7610, 1419, 327, 13913, 269, 454, 19464, 877, 1515, 6900,
180, 327, 27561, 3666, 6461, 5401, 1527, 3341, 15281, 1765, 1286,
4240, 287, 690, 252, 7150, 1394, 2638, 9158, 890, 21415, 6728,
26802, 1734, 1852, 13350, 3342, 289, 344, 5618, 10892, 5485,
1796, 235, 3704, 459, 325, 1684, 3592, 5001, 2160, 16749, 4009,
2080, 1926, 2899, 28374, 1122, 10726, 20111, 24853, 3678, 794,
5025, 3373, 375, 1152, 10288, 3139, 493, 2697)
# graph distribution (right-skewed)
plotdist(samplevec, histo = TRUE, demp = TRUE)
# fit to gamma, lognormal, and weibull
s_gamma <- fitdist(samplevec, 'gamma', lower = c(0, 0))
s_lognormal <- fitdist(samplevec, 'lnorm')
s_weibull <- fitdist(samplevec, 'weibull', lower = c(0, 0))
# plot the fits of 3 options
plotlegend <- c('Gamma', 'Lognormal', 'Weibull')
denscomp(list(s_gamma, s_lognormal, s_weibull), legendtext = plotlegend)
The fit appears reasonable, but there is a lot of emphasis on lower values. I'm not sure if it just looks this way because of the bins of the histogram though.
Question 1: Are there other right-skewed distributions that I should consider?
Question 2: Is there another algorithm besides maximum likelihood that I should consider?
dens <- density(samplevec)
to create the density model, then (afterdenscomp
), addlines(dens, lwd = 2)
. This way you don't need to look at two different graphs to compare the results. $\endgroup$