Hi All,

I'm trying to fit a theoretical distribution to some data, following the procedure on Bolker's Ecological Models and Data in R, but I'm having some problem... could someone please point me out what I'm doing  wrong?

here is the code

#create a random variable 
x <- sort(rpareto(100,1,0.5))

#the pdf
pdf.pareto <- function(x,location,shape){
	density <- -(location+1)*(location^(shape+1))*x^shape
	return(density)}

#predict the probability according to my pdf
y <- pdf.pareto(x,1,0.5)

#check that pdf function does what it should
plot(x,y,typ="l")

#the negative log-likelihood function
NLL.pareto <- function(location,shape){
	density <- pdf.pareto(x,location,shape)
	-sum(dpareto(density,location=location,shape=shape,log=TRUE))}
 
#run the optimisation with mle2 to derive the parameters of the pdf
fit.pareto <- mle2(NLL.pareto,start=list(location=1,shape=0.5))


when i run it, I get this message:
Error in optim(par = c(1, 0.5), fn = function (p)  : 
  initial value in 'vmmin' is not finite

I was almost convinced that the reasoning behind was correct, and to show it to myself i did the same thing with a less "exotic" distribution. In that case the code doesn't crash but the estimate i get are pretty weird...I'm starting to think that I'm trying to do something totally wrong...  
really appreciate any help
thanks
matteo



	[[alternative HTML version deleted]]

