friedsIndexBMM: Perform a binomial mixture model (BMM) analysis of mating...

View source: R/friedsIndexBMM.R

friedsIndexBMMR Documentation

Perform a binomial mixture model (BMM) analysis of mating competitiveness experiments to estimate Frieds Index and egg hatch probabilities under sterile and wildtype matings.

Description

friedsIndexBMM uses a two component binomial mixture model (BMM) to analyse the data from insect mating competitiveness experiments conducted in cages. All cages should contain the same numbers of females, wildtype males and sterilised males. The method uses only mixed mating cages and does not use the compatible and incompatible control cages that are used in traditional estimates of Frieds Index.

Usage

friedsIndexBMM(dataset, alpha_sterile = 1, beta_sterile = 1,
  alpha_wildtype = 1, beta_wildtype = 1, numChains = 1,
  control = list(adapt_delta = 0.99, max_treedepth = 20), iter = 2000,
  warmup = 1000)

Arguments

dataset

is a matrix containing columns named "NumEggs", "NumViable" and "Cage". Each row in dataset should correspond to the number of eggs laid ("NumEggs"), number of viable/hatched eggs ("NumViable") and the replicate cage number ("Cage") for each female. All values for "NumEgg", "NumViable" and "Cage" should be integers. The values used for "Cage" should be integers starting with 1 for the first replicate cage and increasing up to the maximum number of replicate cages.

alpha_sterile

the parameter alpha of the beta distribution to be used for the prior on the hatch probability of eggs produced from matings between wildtype females and sterilised males (alpha and beta default to 1.0 which is a uniform prior).

beta_sterile

the parameter beta of the beta distribution to be used for the prior on the hatch probability of eggs produced from matings between wildtype females and sterilised males (alpha and beta default to 1.0 which is a uniform prior).

alpha_wildtype

the parameter alpha of the beta distribution to be used for the prior on the hatch probability of eggs produced from matings between wildtype females and wildtype males (alpha and beta default to 1.0 which is a uniform prior).

beta_wildtype

the parameter beta of the beta distribution to be used for the prior on the hatch probability of eggs produced from matings between wildtype females and wildtype males (alpha and beta default to 1.0 which is a uniform prior).

numChains

the number of chains to use when sampling from the posterior distribution (defaults to 1).

control

a list of control parameters that is passed to the stan function in the package rstan. See the rstan package documentation for details. The default control parameters used in friedsIndexBMM are control = list(adapt_delta = 0.99, max_treedepth = 20).

iter

the number of samples to draw from the posterior distribution (defaults to 2000).

warmup

the number of initial samples to discard from the analysis to allow the chain(s) to warms-up/burn-in (defaults to 1000).

Value

The function returns a list containing the posterior samples from the BMM analysis (which can be passed to credibleIntevals for summarisation). The list item named p is a two column matrix, with the first column containing posterior samples of the sterile-mating egg hatch probability and the second column the posterior samples of the wildtype egg hatch probability. The list item named pi_global contains the posterior samples for the proportion of matings that were between a wildtype female and a sterilised male. Samples of pi_global can be used to obtain posterior samples of Fried's index as pi_global*wildtypeSterileRatio/(1 - pi_global), where wildtypeSterileRatio is the ratio of wildtype to sterile males that was used in the mixed mating cages. This calculation of Fried's index is performed for the user in the function credibleIntervals.

Examples

data(dataset_multiRep)
samples <- friedsIndexBMM(dataset_multiRep)
credibleIntervals(samples, wildToSterileRatio = 1) 

data(dataset_singleRep)
samples <- friedsIndexBMM(dataset_singleRep)
credibleIntervals(samples, wildToSterileRatio = 1) 

dpagendam/friedsIndex documentation built on July 17, 2022, 5:41 a.m.