Learn R Programming

mmds (version 1.1)

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

Description

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

Usage

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.

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.

Details

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

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)
hist(sim.dat$distance)

Run the code above in your browser using DataLab