reduction_analysis: Analyse two sets of count data (such as FECRT) compared to a...

Description Usage Arguments Details Value References See Also Examples

View source: R/reduction_analysis.R

Description

Analyses two sets of count data for using any of (1) Christian approach, (2) my approach, (3) bootstrap, (4) MCMC (default 1-3). (4) calls reduction_model and then runs the model using runjags, and is the only one to permit ZI and LP. Requires Just Another Gibbs Sampler (JAGS) (see http://mcmc-jags.sourceforge.net)

Usage

1
2
3
4
5
6
7
8
9
reduction_analysis(name = NA, pre.data = NA, post.data = NA,
  data = list(pre = pre.data, post = post.data), animal.names = FALSE,
  efficacy = 95, confidence = 95, restrict.efficacy = TRUE,
  control.animals = FALSE, paired.model = FALSE, fix.variation = FALSE,
  fix.efficacy = TRUE, zero.inflation = FALSE,
  individual.analysis = FALSE, divide.data = 1, record.chains = FALSE,
  write.file = FALSE, bootstrap.iters = 10000, plot.graph = TRUE,
  skip.mcmc = NULL, stat.method = c("MCMC", "WAAVP", "Bootstrap"),
  custom.model = NA, ...)

Arguments

name

a name for the analysis (character). Missing by default (function will require it to be input).

pre.data

the pre-treatment data. Either a numeric vector, amatrix with repeated McMasters counts from the same sample (each row) indifferent columns, or an array with different animals in dimension 1,repeat samples from the same animal in dimension 2, repeated McMasterscounts from the same sample in dimension 3 (can be of length 1 if only 1count recorded). If an array, then the use.paired must be TRUE. Nodefault. Ignored if a value is specified for data.

post.data

the post-treatment data, for acceptable formats seepre.data.

data

either a path to a comma delimited csv file, or an existingR object containing the data. Data can be specified in one of thefollowing ways. If a matrix, the first column is pre-treatment data,the second column is the post-treatment data, and the third column (ifsupplied) indicates control (1) or treatment (0) animal. Alternatively,the first column is animal names id animal.names = TRUE, with columns 2and 3 making up the pre- and post-treatment data and optionally column 4the treatment of control status. If the data is specified as a list,then the first element is taken as the pre-treatment data, and thesecond element is taken as the post-treatment data. These elements ofthe list can be provided as for pre.data and post.data. If the data isin a comma delimited file, it must be in the format specified for asingle matrix. Missing data, or unused elements of non-ragged arrays,may be represented using NA, which will be removed from the data beforeanalysis. This argument is taken from the specified values of pre.dataand post.data by default. If a value is specified for data thenarguments specified for pre.data and post.data are ignored.

animal.names

either a character vector of names to be used foreach animal specified in the data, TRUE or FALSE. If TRUE, then animalnames are taken from the first column of the matrix supplied for data (amatrix must be supplied for data if animal.names is TRUE). If FALSE,then animal names are generated automatically. Default FALSE.

efficacy

the target % efficacy of the drug used. Used tocalculate the probability of resistance with the MCMC and bootstrapmethods. Default 95%.

confidence

the degree of confidence required with which to reportthe confidence limits for the true FEC reduction.

restrict.efficacy

option to restrict the estimate of efficacyfrom the MCMC method to values of greater than 0 (i.e. the mean faecalegg count cannot increase after treatment). If TRUE, then the prior forchange in mean egg count is uniform between 0 and 1, and if FALSE thenthe prior for change in mean egg count is uniform between 0 and 10. Ifusing control animals, then restrict.efficacy applies to the change inmean of the treated animals only, allowing the efficacy to be below 0. Default TRUE.

control.animals

indication of which animals are to be used ascontrols. Should be either a vector of TRUE/FALSE (or 1/0)corresponding to whether each animal is a control (TRUE) or treatment(FALSE), or simply FALSE (the default) in which case all animals areassumed to be treated. Ignored if data is specified as a matrix (or csvfile) with 3 columns, in which case the third column should reflect thetreatment status. Default FALSE.

paired.model

the FECRT can be run using two compound gammadistributions to describe the variability within and between animals inplace of the single gamma distribution combining the two sources ofvariability. When using two compound gamma distributions forpre-treatment data, the post-treatment data are paired to thepre-treatment data by animal. The advantage of using a singledistribution is that the model is more identifiable, and therefore islikely to converge more quickly and return errors less frequently. Theadvantage of the paired model is that it allows repeat measurements tobe incorporated in the model, and non-randomly missing data (ie.protocols that involve post-treatment sampling of only animals with ahigh pre-treatment count) to be modelled appropriately. The simplemodel cannot be used when using repeat samples within animal, and willprovide inaccurate results if animals are targeted for post-treatmentsampling based on their pre-treatment count. Default uses the simplemodel (FALSE).

zero.inflation

option to use a zero-inflated gamma Poisson inplace of the gamma Poisson distribution. If TRUE, zero inflateddistributions are used pre- and post-treatment (with the prevalencefixed between pre- and post-treatment distributions). Default FALSE.

divide.data

count division factor to allow egg count data in eggsper gram to be used raw (numeric). Default 1 (no transformation todata).

record.chains

option to allow the MCMC chains to be recorded forfuture use. If TRUE, the function returns the MCMC object as part ofthe return value (the MCMC object is not printed using the printmethod). If write.file==TRUE, the results are also saved using afilename containing the name of the analysis. Default FALSE.

write.file

option to write the results of the analysis to a textfile using a filename containing the name of the analysis. The contentsof the text file are identical to the return value of the function. Default FALSE.

bootstrap.iters

the number of bootstrap iterations to use for thebootstrap method. Default 10000.

plot.graph

an option to plot the posterior true egg countreduction from the MCMC method graphically. If write.file==TRUE thenthe graph is saved as a PDF, otherwise the graph is plotted on theactive device. Default FALSE.

skip.mcmc

option to omit the MCMC analysis, and return bootstrapand WAAVP method analysis results alone. Default FALSE.

...

other options to be passed directly to autorun.jags.

Details

Should probably discuss different methods here

Value

Returns a list of the results obtained using each method, printed using a custom print method.

References

M. J. Denwood, S. W. J. Reid, S. Love, M. K. Nielsen, L. Matthews, I. J. McKendrick, and G. T. Innocent. Comparison of three alternative methods for analysis of equine Faecal Egg Count Reduction Test data. Prev. Vet. Med. (2009), doi:10.1016/j.prevetmed.2009.11.009

See Also

reduction_model, count_analysis, bayescount, autoextend.jags, runjags This function applies a Bayesian [zero-inflated] gamma Poisson (negative binomial) model to faecal egg count reduction test (FECRT) data to return possible values for the mean drug efficacy. Pre-treatment data are assumed to arise from either a gamma-Poisson or zero-inflated gamma-Poisson distribution, with post-treatment data described by a separate gamma-Poisson or zero-inflated gamma-Poisson distribution. The change in mean between these distributions is therefore the mean egg count reduction. If paired.model=TRUE, a slightly different formulation is used whereby the observed count pre-treatment is assumed to follow a compound gamma-gamma-Poisson distribution with the variability within and between animals separated. The post treatment mean for each animal is derived from the pre-treatment animal mean and FEC reduction. This formulation allows data with non-random missing post-treatment counts to be analysed correctly, and also allows data with repeat counts from an individual to be analysed - providing a method of increasing the power of the method substantially. Results are also obtained using non-parametric bootstrapping and the method advocated in the 1992 World Association for the Advancement of Veterinary Parasitology (W.A.A.V.P.) methods for the detection of anthelmintic resistance in nematodes of veterinary importance (unless the data contains repeat values or missing values). Confidence intervals for the relevant statistics are printed to file if write.file = TRUE, and returned using a custom print method.

Lower level running of JAGS and assessing the simulation for convergence and required run length is done using autorun.jags. Note: The GUI interface for R in Windows may not continually refresh the output window, making it difficult to track the progress of the simulation (if silent.jags is FALSE). To avoid this, you can run the function from the terminal version of R (located in the Program Files/R/bin/ folder).

*THIS SOFTWARE IS INTENDED FOR EDUCATIONAL PURPOSES ONLY AND SHOULD NOT BE RELIED UPON FOR REAL WORLD APPLICATIONS*

fecrt.power and fecrt.power.limits for power analysis methods for the FECRT, bayescount, autorun.jags

Examples

1

mdenwood/bayescount documentation built on Sept. 2, 2017, 11:33 p.m.