theta.prob
Posterior probabilities for theta
Determines the posterior probability and likelihood for theta, given an ecosystem.
- Keywords
- math
Usage
theta.prob(theta, x=NULL, give.log=TRUE)
theta.likelihood(theta, x=NULL, S=NULL, J=NULL, give.log=TRUE)
Arguments
- theta
- biodiversity parameter
- x
- object of class count or census
- give.log
- Boolean, with
FALSE
meaning to return the value, and defaultTRUE
meaning to return the (natural) logarithm of the value - S, J
- In function
theta.likelihood()
, the number of individuals (J
) and number of species (S
) in the ecosystem, ifx
is not supplied. These arguments are provided so thatx
need n
Details
The probability is given on page 122 of Hubbell (2001): $$\frac{J!\theta^S}{ 1^{\phi_1}2^{\phi_2}\ldots J^{\phi_J} \phi_1!\phi_2!\ldots \phi_J! \prod_{k=1}^J\left(\theta+k-1\right)}.$$
The likelihood is thus given by $$\frac{\theta^S}{\prod_{k=1}^J\left(\theta+k-1\right)}.$$
Etienne observes that the denominator is equivalent to a Pochhammer symbol $(\theta)_J$, so is thus readily evaluated as $\Gamma(\theta+J)/\Gamma(\theta)$ (Abramowitz and Stegun 1965, equation 6.1.22).
Note
If estimating theta
, use theta.likelihood()
rather than
theta.probability()
because the former function generally
executes much faster: the latter calculates a factor that is
independent of theta
.
The likelihood function $L(\theta)$ is any function of
$\theta$ proportional, for fixed observation $z$, to
the probability density $f(z,\theta)$. There is thus
a slight notational inaccuracy in speaking of
Note that $S$ is a sufficient statistic for $\theta$.
Function theta.prob()
does not give a PDF for
$\theta$ (so, for example, integrating over the real line
does not give unity). The PDF is over partitions of $J$; an
example is given below.
Function theta.prob()
requires a count object (as opposed to
theta.likelihood()
, for which $J$ and $S$ are
sufficient) because it needs to call phi()
.
References
- S. P. Hubbell 2001.
The Unified Neutral Theory of Biodiversity , Princeton University Press. - M. Abramowitz and I. A. Stegun 1965.Handbook of Mathematical Functions, New York: Dover
See Also
Examples
theta.prob(1,rand.neutral(15,theta=2))
gg <- as.count(c(rep("a",10),rep("b",3),letters[5:9]))
theta.likelihood(theta=2,gg)
optimize(f=theta.likelihood,interval=c(0,100),maximum=TRUE,x=gg)
a <- untb(start=rep(1,1000),gens=1000,prob=1e-3)
## First, an example showing that theta.prob() is a PDF:
library(untb)
a <- count(c(dogs=3,pigs=3,hogs=2,crabs=1,bugs=1,bats=1))
x <- parts(no.of.ind(a))
f <- function(x){theta.prob(theta=1.123,extant(count(x)))}
sum(apply(x,2,f)) ## should be one exactly.