Nmix: Univariate N-mixture models

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

View source: R/Nmix.R

Description

Fits univariate N-mixture models

Usage

1
Nmix(sp1, start, method = "BFGS", K, mixture, Xp, Xl)

Arguments

sp1

observation matrix for the species

start

initial values for the optimization process

method

optimization method passed to optim. Defaults to "BFGS"

K

truncation number of the infinite summations in the log-likelihood. Defaults to max(sp1, sp2) + 100

mixture

latent abundance distribution specification. "P" for Poisson, "NB" for negative binomial and "NeymanA" for Neyman-A distributions are available. Defaults to "P"

Xp

model matrix for detection probabilities

Xl

model matrix for abundance parameter

Details

The function fits Royle's (2004) N-mixture model to data on species abundance collected at R sites over T time occasions. The model for observation on site i at time t can be specified as

Y_{it}|N_i ~ Bin(N_i,p_{it})

N_i ~ a count distribution with mean ╬╗_i.

Here, users may define a Poisson, negative binomial or Neyman-A distributions for the latent abundances N_i.

Value

An object of class uniNmix and Nmix, for which many methods are available (see methods(class = "uniNmix") and methods(class = "Nmix"))

Author(s)

Rafael A. Moral <rafael_moral@yahoo.com.br>, Clarice G. B. Dem├ętrio and John Hinde

References

Royle, J.A. (2004) Models for estimating population size from spatially replicated counts. Biometrics 60:108-105.

See Also

jointNmix

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
## simulating data with negative binomial latent abundances
R <- 10 # sites
T <- 10 # time occasions
lambda <- 5 # abundance parameter
p <- .3 # probability of detection
phi <- 1 # dispersion parameter
set.seed(1234); Ni <- rnbinom(R, mu=lambda, size=phi) # latent abundances
y <- matrix(0, ncol=T, nrow=R)
set.seed(1234); for(i in 1:R) y[,i] <- rbinom(T, Ni, p) # observed abundances

## fitting the Poisson N-mixture model
fitp <- Nmix(y, Xp=cbind(rep(1, R*T)), Xl=cbind(rep(1, R)), mixture="P", K=25)

## fitting the negative binomial N-mixture model
fitnb <- Nmix(y, Xp=cbind(rep(1, R*T)), Xl=cbind(rep(1, R)), mixture="NB", K=25)

## fitting the Neyman-A N-mixture model
fitna <- Nmix(y, Xp=cbind(rep(1, R*T)), Xl=cbind(rep(1, R)), mixture="NeymanA", K=25)

## likelihood-ratio test between Poisson and negbin models
anova(fitp, fitnb)

## comparing using AIC
lapply(list(fitp, fitnb, fitna), AIC)

## conditional posterior probability functions for abundances
plot(fitnb, posterior = TRUE)

## estimated abundances vs. true abundances
data.frame(getranef.uniNmix(fitnb), Ni)

Example output

Univariate N-mixture model fit by maximum likelihood 
Univariate N-mixture model fit by maximum likelihood 
Univariate N-mixture model fit by maximum likelihood 
logLik(object) = -79.3753 (df = 2)
logLik(object2) = -77.3264 (df = 3)
     Chisq d.f. p.value
1 4.097875    1  0.0429
[[1]]
[1] 162.7507

[[2]]
[1] 160.6528

[[3]]
[1] 163.071

    Ni1 Ni
1  0.01  0
2  1.10  2
3  1.02  1
4  2.63  5
5  0.01  0
6  0.01  0
7  1.05  1
8  3.41  4
9  8.03 14
10 1.02  1

jointNmix documentation built on May 2, 2019, 8:18 a.m.