untb (version 1.0-9)

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, give.log = FALSE)
theta.likelihood(theta,x=NULL,S=species.count(x),J=length(x),give.log=FALSE)

Arguments

theta
Biodiversity parameter
x
Ecosystem vector
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
In function theta.likelihood(), if x is not supplied, the number of species in the ecosystem.
J
In function theta.likelihood(), 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

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 <- 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(n=1000,gens=1000,prob=1e-3,start.mono=TRUE)

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 DataCamp Workspace