I am trying to generate the parameters of a kumaraswamy distribution
https://en.wikipedia.org/wiki/Kumaraswamy_distribution
I have a mean and CV of a variable x
mean.x <- 3000
cv.x <- 0.1
sd.x <- cv.x * mean.x
I normalise the mean.x and sd.x by a max and min value as follows:
x.max <- 6000
x.min <- 0
norm.mean.x <- (mean.x - x.min)/(x.max - x.min)
norm.sd.x <- (1/(x.max - x.min)) * sd.x
What I want to do is to estimate (via some fitting procedure) the a
and b
parameters of the kuma distribution? Could anyone explain how this can be done in R? I guess maybe I can start with some default value of a and b, sample n values, find the mean and sd, compared it with the mean and sd I have to derive sum of squared errors and keep changing a
and b
parameter to arrive at that set that gives the lowest sse. For e.g.
library(extraDistr)
kuma.n <- rkumar(100, a = 2, b = 1)
mean.kuma <- mean(kuma.n)
sd.kuma <- sd(kuma.n)
ssq <- (norm.mean.x - mean.kuma)^2 + (norm.sd.x - sd.kuma)^2
and keep changing a and b. However, this seems like an endless iteration so was wondering if anyone has a better solution to this.
EDIT:
the above is a made up data.
optim
function instats
: seehelp(optim)
or one of the many blogs on that in the net like r-bloggers.com/how-to-use-optim-in-r $\endgroup$