Learn R Programming

eggCounts (version 1.4)

simData2s: 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, 
  phiPre = 1, phiPost = phiPre, f = 50, paired = TRUE, 
  rounding = TRUE)

Arguments

n

sample size (number of faecal samples collected pre- and post-treatment)

preMean

true number of eggs per gram (epg) (i.e. worm burden) before treatment

delta

proportion of epg left after treatment, between 0 and 1. 1 - \(\delta\) is reduction in mean after treatment, delta = 0.1 indicates a 90% reduction

kappa

overdispersion parameter, \(\kappa \to \infty\) corresponds to Poisson

phiPre

pre-treatment prevalence (i.e. proportion of infected animals), between 0 and 1

phiPost

post-treatment prevalence, between 0 and 1

f

correction factor of the egg counting technique, either an integer or a vector of integers with length n

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, please see Details.

Value

A matrix with six columns, namely the observed epg (obs), number of eggs counted on microscope slide (master) and true egg counts (true) for both pre- and post- treatment.

Details

The simulation process does not exactly match the proposed models in [ref:paper], however the simulated data resembles the data observed in real world.

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 a up to 3-10% positive bias in the mean reduction when \(\mu\) < 150 and \(\delta\) < 0.1. Set rounding = FALSE if one does not wish to have any bias.

See Also

fecr_stan for analyzing faecal egg count data with two samples

Examples

Run this code
# NOT RUN {
fec <- simData2s(n=10, preMean=500, delta=0.1, kappa=0.5)

## show the positive bias when the true reduction should be 95%
set.seed(1)
fec <- simData2s(n=1e5, preMean=150, delta=0.05, kappa=0.5)
1-mean(fec[,5])/mean(fec[,2])
# }

Run the code above in your browser using DataLab