Hi, I have written out the log-likelihood function to fit some data I have (called ONES20) to the non-central chi-squared distribution. 
   
  >library(stats4)
  >ll<-function(lambda,k){x<-ONES20; 25573*0.5*lambda-25573*log(2)-sum(-x/2)-log((x/lambda)^(0.25*k-0.5))-log(besselI(sqrt(lambda*x),0.5*k-1,expon.scaled=FALSE))}

  > est<-mle(minuslog=ll,start=list(lambda=0.05,k=0.006))
 
  R accepts the function definition without a problem, but gives this error when I ask for the mle of the parameters.
   
  Error in besselI(x, nu, 1 + as.logical(expon.scaled)) : 
        Non-numeric argument to mathematical function
In addition: Warning message:
NaNs produced in: sqrt(x = xx) 

  I am also anticipating another problem in that depending on the definition of the noncentral chi-squared distribution used, the parameters I provide the optimiser to start with lambda and k, may not be acceptable as they are doubles as opposed to integers. 
   
  Does anybody have any experience with the fitting of these distributions?
   
  Best Wishes
   
  Terence


audaces fortuna iuvat
       
---------------------------------

	[[alternative HTML version deleted]]

