simulate {singleRcapture} | R Documentation |
Generating data in singleRcapture
Description
An S3 method for stats::simulate
to handle singleRStaticCountData
and
singleRfamily
classes.
Usage
## 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:
|
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. |
Value
a data.frame
with n
rows and nsim
columns.
Author(s)
Maciej Beręsewicz, Piotr Chlebicki
See Also
stats::simulate()
estimatePopsize()
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)
[Package singleRcapture version 0.2.1.2 Index]