Learn R Programming

mmds (version 1.1)

fitmix: Mixture Model Distance Detection Function Fitting

Description

Fits a mixture of half-normals as a detection function to distance sampling data collected via either line or point transects, possibly with covariates.

Usage

fitmix(data, width, mix.terms = 1, pt = FALSE, model.formula = "~1", initialvalues = NULL, showit = 0, ctrl.options = c(maxit = 10000), opt.method = "BFGS+SANN", usegrad = TRUE, ftype = "hn")

Arguments

data
data.frame containing the distances and covariates to be used in the analusis (see Details).
width
Truncation distance.
mix.terms
Number of mixture components to use. Defaults to 1 (ie. CDS).
pt
Is the data from point transects? Default FALSE.
model.formula
Formula to be used for the covariates. Defaults to "~1" (ie. no covariates).
initialvalues
User supplied initialvalues if needed. Defaults to NULL. See mmds.pars for more information.
showit
Debugging level from 0 to 3, with 3 being most verbose. Defaults to 0.
ctrl.options
Options to give to the optim. Defaults to c(maxit=10000).
opt.method
Optimisation method to use, one of "BFGS", "BFGS+SANN" or "EM". Defaults to "BFGS+SANN", see Details.
usegrad
Should analytic derivatives be used in the optimisation? Default TRUE.
ftype
Function type to be used as the detection function, currently only "hn".

Value

a ds.mixture model object.

Details

This is the main routine that fits mixture model detection functions. data should be a data.frame with (at least) a column named distance. Any covariates given in model.formula should be named in data. Note that rows with distance greater than width will be discarded. See step.ds.mixture for AIC selection for the number of mixture components.

References

Miller, D.L. and L. Thomas (in prep.). Mixture model distance sampling detection functions.

See Also

summary.ds.mixture step.ds.mixture plot.ds.mixture sim.mix mmds.gof ds.mixture mmds.gof fitmix mmds.pars step.ds.mixture

Examples

Run this code
library(mmds)
set.seed(0)
## simulate some line transect data from a 2 point mixture
sim.dat<-sim.mix(c(-0.223,-1.897,inv.reparam.pi(0.3)),2,100,1)
## fit the model
fit.sim.dat<-fitmix(sim.dat,1,2)
## what happened?
summary(fit.sim.dat)

Run the code above in your browser using DataLab