[R] Warning with mle

Antje Niederlein niederlein-rstat at yahoo.de
Thu Jan 27 11:22:50 CET 2011

Hi there,

I'm pretty new to the field of fitting (anything). I try to fit a
distribution with mle, because my real data seems to follow a
zero-inflated poisson distribution. So far, I tried a simple example
to see whether I understand how to do it or not:

# example count data
x <- 0:10
y <- dpois(x, lambda = 1.4)

# zero-inflated poisson
zip <- function(x, lambda, prop) {
	 (1 - prop)*dpois(x,0) + prop*dpois(x,lambda)

ll <- function(lambda = 2, prop = 0.9) {
	y.fit <- zip(x, lambda, prop)
	sum( (y - y.fit)^2 )

fit <- mle(ll)

So far, so good. The result gives me

lambda   prop
   1.4    1.0

which is pretty nice.

But what goes wrong if I want to display confidence intervals? I get a
lot of warnings but I simply don't know why...


Has it something to do with constraints for my parameters (lambda
should be > than zero and prop should range from 0 to 1)? Do I have to
put it into the ll-function?

Is there any general comment on what I'm doing?


More information about the R-help mailing list