| theta.prob {untb} | R Documentation |
Determines the posterior probability (theta.prob()) and
likelihood (theta.likelihood()) for theta, given an ecosystem.
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)
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. |
If estimating theta, use theta.likelihood() rather than
theta.probability() because the former function is
much faster: the latter calculates a factor that is constant
(ie independent of theta).
Robin K. S. Hankin
S. P. Hubbell. The Unified Neutral Theory of Biodiversity. Princeton University Press, 2001.
http://en.wikipedia.org/wiki/Untb
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)
## Not run:
optimize(f=theta.likelihood,interval=c(0,100),maximum=TRUE,x=a)
## End(Not run)
## 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.