logLikZ: Compute log-likelihood z-score

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/logLik.meteDist.R

Description

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

Usage

1
2
3
4
logLikZ(x, ...)

## S3 method for class 'meteDist'
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

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).

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

Author(s)

Andy Rominger <ajrominger@gmail.com>, Cory Merow

References

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

See Also

mseZ.meteDist

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
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') 

cmerow/meteR documentation built on May 13, 2019, 8:23 p.m.