fitNmix {quickNmix}R Documentation

Fit Asymptotic N-mixture Model

Description

Fit an open population N-mixture model using the asymptotic approximation. The four parameters are mean initial site abundance lambda, mean recruitments gamma, survival probability omega, and probability of detection pdet. Parameters can be made to vary over sites and over times by including parameter covariates. Note that this function is essentially a wrapper for optim acting on the nll function.

Usage

fitNmix(
  nit,
  K = NULL,
  starts = NULL,
  l_s_c = NULL,
  g_s_c = NULL,
  g_t_c = NULL,
  o_s_c = NULL,
  o_t_c = NULL,
  p_s_c = NULL,
  p_t_c = NULL,
  SMALL_a_CORRECTION = FALSE,
  VERBOSE = FALSE,
  outfile = NULL,
  method = "BFGS",
  ...
)

Arguments

nit

Matrix of counts data. Rows represent sites, columns represent sampling occasions. Note that if the data is a vector, then it will be converted to a matrix with a single row.

K

Upper bound on summations in the likelihood function. K should be chosen large enough that the negative log likelihood function is stable (unchanging as K increases). If K=NULL, K=5*max(nit) will be used as default. Default: NULL

starts

Either NULL for default starting values, or a vector of parameter values: c(log(lambda), log(gamma), logit(omega), logit(pdet)). Note that the parameter vector will need to be longer by one for each parameter coefficient if covariate values are supplied. The order of coefficients is: c(lambda, l_s_c, gamma, g_s_c, g_t_c, omega, o_s_c, o_t_c, pdet, p_s_c, p_t_c)

l_s_c

List of lambda site covariates, Default: NULL

g_s_c

List of gamma site covariates, Default: NULL

g_t_c

List of gamma time covariates, Default: NULL

o_s_c

List of omega site covariates, Default: NULL

o_t_c

List of omega time covariates, Default: NULL

p_s_c

List of pdet site covariates, Default: NULL

p_t_c

List of pdet time covariates, Default: NULL

SMALL_a_CORRECTION

If TRUE will apply the small a correction when calculating the transition probability matrix, Default: FALSE

VERBOSE

If TRUE, will print additional information during model fitting, Default: FALSE

outfile

Location of csv file to write/append parameter values, can be used to checkpoint long running model fits. Default: NULL

method

Optimization method, passed to optim function, options include: "BFGS", "Nelder-Mead", "CG". Default: "BFGS"

...

Additional arguments passed to the optimization function optim. For example: control = list(trace=1, REPORT=1, reltol=1e-10)

Value

Returns the fitted model object.

Examples

if (interactive()) {
nit = matrix(c(1,1,0,1,1), nrow=1) # observations for 1 site, 5 sampling occassions
model1 = fitNmix(nit, K=2)        # fit the model with population upper bound K=2
}

[Package quickNmix version 1.1.1 Index]