Re: [R] Fitting Data to a Noncentral Chi-Squared Distribution using MLE

2007-09-11 Thread Charles C. Berry
This is what I might do: > y <- rchisq( 1000, df=10, ncp=2 ) > library( stats4 ) > res <- mle( function(x,z) -sum( dchisq(y, x, z , log=TRUE ) ), start=list( > x=5, z=5 ) ) > coef(res) x z 10.355711 1.586123 > > ## or just to keep clear of boundary constraints: > > res <- mle(

[R] Fitting Data to a Noncentral Chi-Squared Distribution using MLE

2007-09-11 Thread Terence Broderick
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*