François Aucoin
2008-Jun-04 00:54 UTC
[R] Minimizing the negative log likelihood function...
Hey, The following is a function I wrote which generates random variables from a Kappa (2-parameter) distribution. rkappa <- function(n,beta,alpha){ if(alpha <= 0) stop("alpha must be greater than zero!") if(beta <= 0) stop("beta must be greater than zero!") Vec <- beta*exp((1/alpha)*(log(-(alpha/(-1 + exp(alpha*log(runif(n,0,1))))))+ alpha*log(runif(n,0,1)))) return(Vec) } Now I would like to estimate the parameters of such a distribution using the Maximum likelihood method. I know that I have to minimize the following negative log likelihood function: Neg.Log.Like <- function(beta,alpha,x){ -(sum( log((alpha/beta)*(alpha + (x/beta)^alpha)^( -(alpha + 1)/alpha)))) } I have tried several R's functions for optimization but the results I yield are not correct. Is there anybody who can help me? Thanks! Francois Aucoin [[alternative HTML version deleted]]
Karl Ove Hufthammer
2008-Jun-04 12:02 UTC
[R] Minimizing the negative log likelihood function...
Fran?ois Aucoin:> I have tried several R's functions for optimization but the results I > yield are not correct. > Is there anybody who can help me?I couldn't get it to estimate the correct values either, so I guess either your random number generator 'rkappa' is wrong, or your 'Neg.Log.Like' function is wrong. Or possibly both. -- Karl Ove Hufthammer