# modeP: Posterior Mode of Parents In MasterBayes: ML and MCMC Methods for Pedigree Reconstruction and Analysis

## Description

Finds the mode of the posterior marginal distribution of parents

## Usage

 `1` ```modeP(postP, threshold=0, marginal=FALSE, USasNA=TRUE) ```

## Arguments

 `postP` posterior distribution of parentage `threshold` threshold probability under which ML parents are replaced by NA `marginal` logical; should the marginal mode be calculated from the joint distribution? `USasNA` logical; should usampled parents be replaced by NA?

## Details

Individuals that do not have a parent assignment with a posterior probability exceeding the `threshold`, or whose parents belong to the base or unsampled population (if `USasNA=TRUE`), have NA as their parents. Please bear in mind that the mode of the marginal distribution (returned by `MCMCped` if `write_postP="MARGINAL"`) may be different from the mode of the joint distribution (`write_postP="JOINT"`). For example the male that has the highest marginal probability (marginal with respect to potential mothers) may not be the male that is in the parental category (i.e. dam/sire combination) with the highest probability. If `write_postP="JOINT"` was sepcified, then the mode of the marginal distribution can be obtained by specifying `marginal=TRUE`. The modes are marginal with respect to other offspring and with multigenerational pedigrees may not coincide with the mode of the distribution of pedigrees.

## Value

 `P` pedigree with id in the first column, and dam and sire in the second and third columns `prob` marginal posterior probability of the most likely parental combination (joint) or the most likely mother (marginal) `prob.male` marginal posterior probability of the most likely father (marginal)

## Author(s)

`MCMCped`
 ``` 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``` ```## Not run: data(WarblerP) data(WarblerG) GdP<-GdataPed(WarblerG) var1<-expression(varPed(c("lat", "long"), gender="Male", relational="OFFSPRING")) # paternity is to be modelled as a function of distance # between offspring and male territories res1<-expression(varPed("offspring", restrict=0)) # indivdiuals from the offspring generation are excluded as parents res2<-expression(varPed("terr", gender="Female", relational="OFFSPRING", restrict="==")) # mothers not from the offspring territory are excluded PdP<-PdataPed(formula=list(var1,res1,res2), data=WarblerP, USsire=FALSE) tP<-tunePed(beta=30) model1<-MCMCped(PdP=PdP, GdP=GdP, tP=tP, nitt=3000, thin=2, burnin=1000) ped<-modeP(model1\$P, threshol=0.9) ped ## End(Not run) ```