I am trying to find the root of the following function. Basically, I am trying to find n1, n2, prob1, and prob2 from a mixture of two negative binomials.. I differentiated the log likelihood with respect to n and am trying to solve this equation. zij and y are both a column of vectors. y is the data and zij are the conditional probability of being in a particular distribution. I tried uniroot but it failed ..is there anything in R that can do this?? The problem is I generated the data I am using from a mixture of two negative binomials. f=function(n) { sum((1-zij)*(digamma(y+n)-digamma(n))) } uniroot(f, c(1,100))$root Error in uniroot(f, c(1, 100)) : f() values at end points not of opposite sign [[alternative HTML version deleted]]