I'm trying to estimate the parameters of the Weibull distribution by some numerical methods (namely Graphical, Modified maximum likelihood and Equivalent energy) in R language. My problem is that I'm not getting success in calculate their equations in R like a function. Could someone help me with that?
OBS.: I would like to do the calculations like this:
mm = function(val){
sigma = sd(val);
vmedia = mean(val);
cte = (sigma/vmedia)^2;
KSUP = 10;
KINF = 0;
repeat {
mmk = (KSUP + KINF)/2;
tentativa = (gamma(1 + 2/mmk) - (gamma(1 + 1/mmk)^2))/(gamma(1 + 1/mmk)^2);
err = cte - tentativa;
if (abs(err) > 1e-05) {
if (err < 0) {
KINF = mmk;
} else {
KSUP = mmk;
}
}
else {break;}
}
mmc = vmedia/gamma(1+1/mmk);
return(c(mmk, mmc));
}
source("momento.R")
m=mm(val)
mmk=m[1]
mmc=m[2]
mmk
mmc