Learn R Programming

meteR (version 1.2)

logLikZ: Compute log-likelihood z-score

Description

logLikZ.meteDist computes a log-likelihood z-score by simulation from a fitted METE distribution

Usage

logLikZ(x, ...)
"logLikZ"(x, nrep = 999, return.sim = FALSE, ...)

Arguments

x
a meteDist object
...
arguments to be passed to methods
nrep
number of simulations from the fitted METE distribution
return.sim
logical; return the simulated liklihood values

Value

list with elements
z
The z-score
sim
nrep Simulated values (scaled by mean and sd as is the z-score) if return.sim=TRUE, NULL otherwise

Details

logLikZ.meteDist simulates from a fitted METE distribution (e.g. a species abundance distribution or individual power distribution) and calculates the likelihood of these simulated data sets. The distribution of these values is compared against the likelihood of the data to obtain a z-score, specifically z = ((logLik_obs - mean(logLik_sim)) / sd(logLik_sim))^2. This value is squared so that it will be approximately Chi-squared distributed and a goodness of fit test naturally arrises as 1 - pchisq(z, df=1).

References

Harte, J. 2011. Maximum entropy and ecology: a theory of abundance, distribution, and energetics. Oxford University Press.

See Also

mseZ.meteDist

Examples

Run this code
data(arth)
## object holding ecosystem structure function
esf1 <- meteESF(spp=arth$spp,
                abund=arth$count,
                power=arth$mass^(.75),
                minE=min(arth$mass^(.75)))
## calculate individual power distribution
ipd1 <- ipd(esf1)
## calculate z-score, keeping all simulated log likelihoods for plotting
llz <- logLikZ(ipd1, nrep=100, return.sim=TRUE)

plot(density(llz$sim),xlim=range(c(llz$sim,llz$obs)),
     xlab='scaled log(likelihood)^2',col='red')
abline(v=llz$z,lty=2)
legend('top',legend=c('data','simulated'),col=c('black','red'),
      lty=c(1,1),bty='n')

Run the code above in your browser using DataLab