untb (version 1.0-20)

theta.prob: Posterior probabilities for theta

Description

Determines the posterior probability (theta.prob()) and likelihood (theta.likelihood()) for theta, given an ecosystem.

Usage

theta.prob(theta,x=NULL,S=no.of.spp(x),J=no.of.ind(x),give.log=FALSE)
theta.likelihood(theta,x=NULL,S=no.of.spp(x),J=no.of.ind(x),give.log=FALSE)

Arguments

theta
Biodiversity parameter
x
object of class count or census
give.log
Boolean, with default FALSE meaning to return the probability or likelihood, and TRUE meaning to return the logarithm of the probability, or the log-likelihood
S
If x is not supplied, the number of species in the ecosystem.
J
If x is not supplied, the number of individuals in the ecosystem. Arguments S and J are provided so that x need not be supplied if S and J are known.

References

S. P. Hubbell. The Unified Neutral Theory of Biodiversity. Princeton University Press, 2001.

http://en.wikipedia.org/wiki/Untb

See Also

phi, optimal.prob

Examples

Run this code
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)

optimize(f=theta.likelihood,interval=c(0,100),maximum=TRUE,x=a)
## Fails due to numerical overshoot

optimize(f=theta.likelihood,interval=c(0,100),maximum=TRUE,x=a,give.log=TRUE)
## Compare the true value of 2 (=2*1e-3*1000).  Not bad.

Run the code above in your browser using DataLab