I want to fit a distribution to some data to sample from it in a subsequent simulation. There are I got a dataset that looks somehwat like this:
dat <- data.frame(num=1:10, value=c(6000, 2800, 1000, 230, 142, 53, 32, 21, 10, 110))
Every entry of "num" refers to a non-negative discrete observation, except the last one (in this case num=10) which is a category of "10 or more". The column "value" refers to the frequency of that observation. The data is extremly right skewed, but an exponential distribution seems to be a decent fit if you ignore the last row of the data. (note: this isn't the real data)
I happen to know the maximum value that can occur, let's say that one is 500. So in other words I know the area under the curve between 10 and 500, which is the frequency of the last category, and have exact values before that. How do I fit an exponential (or other fitting) distribution to this data that satisfies these constraints?
So far I only managed to fit an exponential distribution to the first 9 columns and predict values for the subsequent values of 10-500 like this:
m.exp <- nls(value ~ I(a * exp(b * num)), data = dat, start = list(a = 1, b = 0), trace = T) new_dat <- predict(m.exp, newdata = data.frame(num=c(9:500)))
This does work somewhat, but the area under the curve between 9 and 500 obviously is not correct (e.g. it is not equal to 110). Another solution I implemented is fitting a triangle, which does satisfy the area under curve and the maximum value, but the distribution would be far off from the prior distribution of values.
Edit: Is it possible to fit a distribution that has 112 (the frequency of "10 and more") as the area under the curve between the values 9 and 500, which roughly follows the same distribution as the values before it?