simulate function

Generating data in singleRcapture

Generating data in singleRcapture

An S3 method for stats::simulate to handle singleRStaticCountData and singleRfamily classes.

## S3 method for class 'singleRStaticCountData' simulate(object, nsim = 1, seed = NULL, ...) ## S3 method for class 'singleRfamily' simulate(object, nsim, seed = NULL, eta, truncated = FALSE, ...)

Arguments

  • object: an object representing a fitted model.

  • nsim: a numeric scalar specifying:

    • number of response vectors to simulate in simulate.singleRStaticCountData, defaults to 1L.
    • number of units to draw in simulate.singleRfamily, defaults to NROW(eta).
  • seed: an object specifying if and how the random number generator should be initialized (‘seeded’).

  • ...: additional optional arguments.

  • eta: a matrix of linear predictors

  • truncated: logical value indicating whether to sample from truncated or full distribution.

Returns

a data.frame with n rows and nsim columns.

Examples

N <- 10000 ###gender <- rbinom(N, 1, 0.2) gender <- rep(0:1, c(8042, 1958)) eta <- -1 + 0.5*gender counts <- simulate(ztpoisson(), eta = cbind(eta), seed = 1) df <- data.frame(gender, eta, counts) df2 <- subset(df, counts > 0) ### check coverage with summary mod1 <- estimatePopsize( formula = counts ~ 1 + gender, data = df2, model = ztpoisson, controlMethod = list(silent = TRUE) ) mod1_sims <- simulate(mod1, nsim=10, seed = 1) colMeans(mod1_sims) mean(df2$counts)

See Also

stats::simulate() estimatePopsize()

Author(s)

Maciej Beręsewicz, Piotr Chlebicki

  • Maintainer: Maciej Beręsewicz
  • License: MIT + file LICENSE
  • Last published: 2025-02-13