Learn R Programming

ABCp2 (version 1.2)

ABC_P2_norm: ABC Extimation of P2 for Normal Distribution

Description

This function fits offspring data to a special case of the normal distribution, in which zero and negative values of offspring are excluded, and estimates P2 based on that distribution and the specificed priors.

Usage

ABC_P2_norm(n, ObsMean, M_Lo, M_Hi, SD_Lo, SD_Hi, delta, iter)

Arguments

n
number of observations.
ObsMean
the observed mean number of offspring sired by the second male.
M_Lo
minimum mean value for the distribution.
M_Hi
maximum mean value for the distribution.
SD_Lo
minimum standard deviation value for the distribution.
SD_Hi
maximum standard deviation value for the distribution.
delta
maximum allowed difference between the estimated mean and observed mean number of offspring produced by the second male.
iter
number of iterations used to build the posterior.

Value

posterior
Posterior distribution of P2 values.
Avg
Vector of values for the mean parameter.
Std
Vector of values for the standard deviation parameter.

Examples

Run this code
#Fit the Mean and Standard Deviation hyperpriors to a distribution of offspring. 

data(fungus)
fit_dist_norm(fungus$Total_Offspring)

#Use hyperiors and priors calculated from the data to estimate P2. 
#Plot the saved distributions for the Mean and Standard Deviation parameters.
#Adjust, if necessary.

fungus_P2<-ABC_P2_norm(12, 9.9, 11.35, 17.31, 8.22, 12.44, 0.1, 100)
hist(fungus_P2$posterior)
hist(fungus_P2$Avg)
hist(fungus_P2$Std)

Run the code above in your browser using DataLab