js function

Fitting function for Jolly-Seber model using Schwarz-Arnason POPAN formulation

Fitting function for Jolly-Seber model using Schwarz-Arnason POPAN formulation

A function for computing MLEs for a specified Jolly-Seber open population capture-recapture model for processed dataframe x with user specified formulas in parameters that create list of design matrices dml. This function can be called directly but is most easily called from crm that sets up needed arguments.

js( x, ddl, dml, model_data = NULL, parameters, accumulate = TRUE, initial = NULL, method = "BFGS", hessian = FALSE, debug = FALSE, chunk_size = 1e+07, refit, itnmax = NULL, control = NULL, scale, ... )

Arguments

  • x: processed dataframe created by process.data
  • ddl: list of dataframes for design data; created by call to make.design.data
  • dml: list of design matrices created by create.dm from formula and design data
  • model_data: a list of all the relevant data for fitting the model including imat, Phi.dm,p.dm,Phi.fixed,p.fixed, and time.intervals. It is used to save values and avoid accumulation again if the model was re-rerun with an additional call to js when using autoscale or re-starting with initial values. It is stored with returned model object.
  • parameters: equivalent to model.parameters in crm
  • accumulate: if TRUE will accumulate capture histories with common value and with a common design matrix for Phi and p to speed up execution
  • initial: initial values for parameters if desired; if named vector from previous run it will match to columns with same name
  • method: method to use for optimization; see optimx
  • hessian: if TRUE will compute and return the hessian
  • debug: if TRUE will print out information for each iteration
  • chunk_size: specifies amount of memory to use in accumulating capture histories; amount used is 8*chunk_size/1e6 MB (default 80MB)
  • refit: non-zero entry to refit
  • itnmax: maximum number of iterations
  • control: control string for optimization functions
  • scale: vector of scale values for parameters
  • ...: any remaining arguments are passed to additional parameters passed to optimx or js.lnl

Returns

The resulting value of the function is a list with the class of crm,js such that the generic functions print and coef can be used. - beta: named vector of parameter estimates - lnl: -2log likelihood - AIC: lnl + 2 number of parameters

  • convergence: result from optimx; if 0 optimx thinks it converged - count: optimx results of number of function evaluations - reals: dataframe of data and real Phi and p estimates for each animal-occasion excluding those that occurred before release

  • vcv: var-cov matrix of betas if hessian=TRUE was set

Details

It is easiest to call js through the function crm. Details are explained there.

Be cautious with this function at present. It does not include many checks to make sure values like fixed values will remain in the specified range of the data. Normally this would not be a big problem but because js.lnl calls an external FORTRAN subroutine via cjs.lnl, if it gets a subscirpt out of bounds, it will cause R to terminate. So make sure to save your workspace frequently if you use this function in its current implementation.

References

Schwarz, C. J., and A. N. Arnason. 1996. A general methodology for the analysis of capture-recapture experiments in open populations. Biometrics 52:860-873.

Author(s)

Jeff Laake

  • Maintainer: Jeff Laake
  • License: GPL (>= 2)
  • Last published: 2023-10-19

Useful links