fitNmixPara {quickNmix} | R Documentation |
Fit Asymptotic N-mixture Model Using optimParallel
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
fitNmixPara(
cluster,
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,
LowerBounds = NULL,
...
)
Arguments
cluster |
cluster object created using makeCluster, for example: |
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: |
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 |
LowerBounds |
Lower bounds to be passed to optimParallel (if NULL, default values will be used), you may need to set this manually if you receive errors such as: "L-BFGS-B needs finite values of 'fn'". |
... |
Additional arguments passed to the optimization function optimParallel. |
Value
Returns the fitted model object.
Examples
if (interactive()) {
cl <- makeCluster(parallel::detectCores()-1) # number of clusters should be 2*p+1 for optimal gains
nit = matrix(c(1,1,0,1,1,2,2), nrow=1) # observations for 1 site, 7 sampling occassions
model1 = fitNmixPara(cl, nit, K=100) # fit the model with population upper bound K=100
parallel::stopCluster(cl)
}