sim.mix: Simulate data from a mixture model detection function

Description Usage Arguments Details Value Author(s) Examples

View source: R/sim.mix.R

Description

Simulate data from a (line or point transect) mixture model detection function with or without covariates using rejection sampling.

Usage

1
2
  sim.mix(pars, mix.terms, n, width, zdim = 0, z = NULL,
    pt = FALSE, showit = FALSE)

Arguments

pars

Parameters of the model to fit. See mmds.pars for details.

mix.terms

Number of mixture components.

n

Number of data to generate.

width

Truncation distance.

zdim

Number of columns of z. Defaults to 0.

z

Covariate data. Defaults to NULL. See details for more information.

pt

Should point transect data be generated? Defaults to FALSE.

showit

Print the acceptance rate. Defaults to FALSE.

Details

This routine uses rejection sampling, so may be rather slow of large sample sizes. Direct sampling will be available soon.

Value

a data.frame with the following columns:

observed Whether the object was observed, always n 1s. Kept for mmds compatability.
object Object identifier, numbered 1 to n. Kept for mmds compatability.
distance Observed distances.
Then follows as many columns as there are columns as z, named as in z.

Author(s)

David L. Miller

Examples

1
2
3
4
5
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)
hist(sim.dat$distance)

mmds documentation built on May 2, 2019, 8:55 a.m.

Related to sim.mix in mmds...