Allows data-weighting as parameter
Usage
ddirmult(x, prob, ln_theta, log = TRUE)
Arguments
- x
numeric vector of observations across categories
- prob
numeric vector of category probabilities
- ln_theta
logit-ratio of effective and input sample size
- log
whether to return the log-probability or not
Examples
library(RTMB)
prob = rep(0.1,10)
x = rmultinom( n=1, prob=prob, size=20 )[,1]
f = function( ln_theta ) ddirmult(x, prob, ln_theta)
f( 0 )
#> [1] -15.26349
F = MakeTape(f, 0)
F$jacfun()(0)
#> [,1]
#> [1,] 0.850599