# r.marked.egg.fraction: Estimates of fraction of eggs marked accounting for... In ConnMatTools: Tools for Working with Connectivity Data

## Description

This function estimates the fraction of eggs "marked" at a site (where the "mark" could be micro-chemical or genetic) taking into account uncertainty in female (and potentially male in the case of dual genetic mark transmission) reproductive output. It generates a set of potential values for the fraction of eggs marked assuming that reproductive output of each marked or unmarked mature individual is given by a random variable drawn from a single probability distribution with known mean and standard deviation (or equivalently coefficient of variation) and that the numbers of marked and unmarked individuals are large enough that the central limit theorem applies and, therefore, their collective reproductive outputs are reasonably well described by a gamma distribution whose mean and standard deviation are appropriately scaled based on the number of individual reproducers. The function also returns the total egg production corresponding to each fraction of marked eggs, needed for estimating absolute connectivity values (i.e., elements of the connectivity matrix needed for assessing population persistence).

## Usage

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16``` ```r.marked.egg.fraction( n, n.females, n.marked.females = round(n.females * p.marked.females), mean.female = 1, cv.female, dual = FALSE, male.uncert = FALSE, n.males = n.females, n.marked.males = tryCatch(round(n.males * p.marked.males), error = function(e) n.marked.females), mean.male = mean.female, cv.male = cv.female, p.marked.females, p.marked.males = p.marked.females ) ```

## Arguments

 `n` Number of random values to estimates `n.females` Total number of mature females in the population `n.marked.females` Number of marked females in population `mean.female` Mean egg production of each mature female. Defaults to 1. `cv.female` Coefficient of variation of reproductive output of an individual mature female `dual` Logical variable. If `TRUE`, then the fraction of marked eggs is calculated assuming dual (male and female) mark transmission. Defaults to `FALSE`. `male.uncert` Logical variable. If `TRUE`, then variability in male sperm output is also taken into account when estimating the number of marked eggs. Defaults to `FALSE`. `n.males` Total number of mature males in the population. Only used if `dual=TRUE`. Defaults to being equal to `n.females`. `n.marked.males` Number of marked males in population. Only used if `dual=TRUE`. Defaults to being equal to `n.marked.females`. `mean.male` Mean sperm production of each mature male. Only used if `dual=TRUE` and `male.uncert=TRUE`. Defaults to being equal to `mean.female`. `cv.male` Coefficient of variation of reproductive output of an individual mature male. Only used if `dual=TRUE` and `male.uncert=TRUE`. Defaults to being equal to `cv.female`. `p.marked.females` Fraction of marked females in population. Can be supplied instead of `n.marked.females`. Ignored if `n.marked.females` is given. `p.marked.males` Fraction of marked males in population. Can be supplied instead of `n.marked.males`. Only used if `dual=TRUE`. Ignored if `n.marked.males` is given.

## Value

A list with the following elements:

p

Vector of length `n` with estimates for fraction of marked eggs

eggs

Vector of length `n` with estimates for total egg production

marked.eggs

Vector of length `n` with estimates for total number of marked eggs produced

sperm

Only returned if `dual=TRUE`. If `male.uncert=FALSE`, then a scalar equal to `n.males`. Otherwise, a vector of length `n` with estimates for total sperm production

marked.sperm

Only returned if `dual=TRUE`. If `male.uncert=FALSE`, then a scalar equal to `n.marked.males`. Otherwise, a vector of length `n` with estimates for total marked sperm production

## Author(s)

David M. Kaplan dmkaplan2000@gmail.com

## References

Kaplan DM, Cuif M, Fauvelot C, Vigliola L, Nguyen-Huu T, Tiavouane J and Lett C (in press) Uncertainty in empirical estimates of marine larval connectivity. ICES Journal of Marine Science. doi:10.1093/icesjms/fsw182.

Other connectivity estimation: `d.rel.conn.beta.prior()`, `d.rel.conn.dists.func()`, `d.rel.conn.finite.settlement()`, `d.rel.conn.multinomial.unnorm()`, `d.rel.conn.multiple()`, `d.rel.conn.unif.prior()`, `dual.mark.transmission()`, `optim.rel.conn.dists()`
 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46``` ```library(ConnMatTools) n.females <- 500 n.marked.females <- 100 p.marked.females <- n.marked.females/n.females mn <- 1 cv <- 1 # Numbers of males and marked males and variance in male sperm production # assumed the same as values for females # Random values from distribution of pure female mark transmission F=r.marked.egg.fraction(1000,n.females=n.females,n.marked.females=n.marked.females, mean.female=mn,cv.female=cv) # Random values from distribution of dual female-male mark transmission, but # fraction of marked eggs only depends on fraction of marked males Fm=r.marked.egg.fraction(1000,n.females=n.females,n.marked.females=n.marked.females, mean.female=mn,cv.female=cv,dual=TRUE,male.uncert=FALSE) # Random values from distribution of dual female-male mark transmission, with # fraction of marked eggs depending on absolute marked and unmarked sperm output FM=r.marked.egg.fraction(1000,n.females=n.females,n.marked.females=n.marked.females, mean.female=mn,cv.female=cv,dual=TRUE,male.uncert=TRUE) # Plot of pure female mark transmission hist(F\$p,50,main="Female mark transmission", xlab="Fraction of marked eggs", ylab="Frequency") # Female+male mark transmission, but no variability in male mark transmission h <- hist(Fm\$p,50,main="Female+male mark transmission, no male uncert.", xlab="Fraction of marked eggs", ylab="Frequency") hh <- hist((1-p.marked.females)*F\$p + p.marked.females, breaks=c(-Inf,h\$breaks,Inf),plot=FALSE) lines(hh\$mids,hh\$counts,col="red") # Plot of pure female mark transmission h <- hist(FM\$p,50,plot=FALSE) hh <- hist(Fm\$p, breaks=c(-Inf,h\$breaks,Inf),plot=FALSE) plot(h,ylim=c(0,1.1*max(hh\$counts,h\$counts)), main="Female+Male mark transmission, male uncert.", xlab="Fraction of marked eggs", ylab="Frequency") lines(hh\$mids,hh\$counts,col="red") ```