search for: integ_res

Displaying 1 result from an estimated 1 matches for "integ_res".

2011 Feb 25
0
Fitting distribution in range
...stributions such that the integral from min(x) to max(x) of the fitted distribution will be one. Therefore I have wrote my own log-likelihood functions and then I am using mle {stats4}. So, for example: ll_gamma <- function(a,b) { integrand <- function(y){dgamma(y, shape=a, rate=b)} integ_res <- tryCatch({integrate(integrand,min_x,max_x)$value}, error=function(err){0}); if (integ_res == 0) { return(NA) } C = 1 / integ_res res = -(sum(log(C*dgamma(x,shape=a,rate=b)))) return(res) } m <- mean(x) v <- var(x) fit <- mle(minuslog=ll_gamma,start=list(a=m^2/v,b=m/v...