simData2s {eggCounts} | R Documentation |
Simulate faecal egg count data (2-sample situation)
Description
Generates two samples of (zero-inflated) egg count data
Usage
simData2s(n = 10, preMean = 500, delta = 0.1, kappa = 0.5,
deltaShape = NULL, phiPre = 1, phiPost = phiPre, f = 50,
paired = TRUE, rounding = TRUE, seed = NULL)
Arguments
n |
positive integer. Sample size. |
preMean |
numeric. True pre-treatment epg. |
delta |
numeric. Proportion of epg left after treatment, between 0 and 1. 1 - |
kappa |
numeric. Overdispersion parameter, |
deltaShape |
numeric. Shape parameter for the distribution of reductions. If NULL, the same reduction is applied to the latent true epg of each animal. |
phiPre |
numeric. Pre-treatment prevalence (i.e. proportion of infected animals), between 0 and 1. |
phiPost |
numeric. Post-treatment prevalence, between 0 and 1. |
f |
integer or vector of integers. Correction factor of the egg counting technique |
paired |
logical. If TRUE, paired samples are simulated. Otherwise unpaired samples are simulated. |
rounding |
logical. If TRUE, the Poisson mean for the raw counts is rounded. The rounding applies since the mean epg is frequently reported as an integer value. For more information, see Details. |
seed |
an integer that will be used in a call to set.seed before simulation. If NULL, a random seed is allocated. |
Details
In the simulation of raw (master
) counts, it follows a Poisson distribution with some mean. The mean is frequently rounded down if it has a very low value and rounding = TRUE
, there expects to be some bias in the mean reduction when < 150 and
< 0.1. Set
rounding = FALSE
for not to have any bias.
Value
A data.frame with six columns, namely the observed epg (obs
),
actual number of eggs counted (master
) and true epg in the sample (true
) for both pre- and post- treatment.
Author(s)
Craig Wang
Michaela Paul
See Also
fecr_stan
for analyzing faecal egg count data with two samples
Examples
fec <- simData2s(n = 10, preMean = 500, delta = 0.1, kappa = 0.5)
## show the bias when the true reduction should be 95%
fec <- simData2s(n = 1e5, preMean = 150, delta = 0.05,
kappa = 0.5, seed = 1)
1 - mean(fec$masterPost)/mean(fec$masterPre)
## without bias
fec <- simData2s(n = 1e5, preMean = 150, delta = 0.05,
kappa = 0.5, seed = 1, rounding = FALSE)
1 - mean(fec$masterPost)/mean(fec$masterPre)