3 ms·
Nice eye! In this case it's a no op and the function has no effect because I've used the `rowwise()` call such that the data frame is evaluated one row at a tim
by RA_Fisher 9y ago
Nice eye! In this case it's a no op and the function has no effect because I've used the `rowwise()` call such that the data frame is evaluated one row at a time x 1.
The `prod` call is an artifact of me previously using the function in a vectorized manner to calculate the model's likelihood.[1] This isn't the common way one might see. More often one would work with the log likelihood [2]. The reason being that the product of the density can be converted into sums avoiding overflow errors. The likelihood is __very cool_. I liken it to a grand generalization of the needle of a record player wrt to information (entropy).
[1] https://en.wikipedia.org/wiki/Maximum_likelihood_estimation#Principles https://en.wikipedia.org/wiki/Maximum_likelihood_estimation#...
[2] https://en.wikipedia.org/wiki/Likelihood_function#Log-likelihood https://en.wikipedia.org/wiki/Likelihood_function#Log-likeli...
- nonbel 9y agoIn R you can just plug in a vector of probabilities directly to get the likelihood. Ie: p = seq(.01, .99, by = .01) y1 = dbinom(7, 47, p) y2 = dnbinom(40, 7, p) It doesn't matter much for this use case but that will also be much faster. It does simplify the code quite a bit too though.
- RA_Fisher 9y agoThank you for pushing me to see that, indeed I should take advantage of the vectorized aspect of this code!