Open PDiracDelta opened 4 years ago
Maybe these 2 things are related? Swapping p and 1-p and swapping result with -result?
When you put p=1-p
at the beginning and return result
instead, you get a different result, so that's not how that works. strangely enough I tested this a while ago and if I recall correctly, the current version does give the same result as when you fit in R ...
How is that possible?
EDIT: I just checked the results for my data set and compared to R output. Indeed, your version seems to give the correct answers. Why, though (read my post below)?
in log_likelihood I think you switched the terms with
p
and1-p
. If you check on wikipedia, thep
is in the term withln
that is summed over, and the1-p
is in the term withln
that is not summed over. In your code, it's the other way around. You can verify using the R?dnbinom
that its definition ofp
is identical to that of wikipedia (you are using R's suggestion for estimatingp
(orprob
).Also, you are returning
-result
instead ofresult
, which I also think is incorrect.