In the single f model we may parameterize in terms of the allele frequencies and λ=\log((ff_{\min})/(1f)) where f_{\min}=p_{\min}/(1p_{\min}) and p_{\min} is the minimum allele frequency. The prior for λ is assumed normal and this function finds the mean and standard deviation of this normal, given two values for f, with associated probabilities.
1  LambdaOptim(nsim, bvec, f1, f2, p1, p2, init)

nsim 
the optimization is carried out by simulating from the joint prior on allele frequencies and λ, and this argument gives the number of simulations to take from the prior 
bvec 
vector of length k of prior specification for the HWE Dirichlet prior, where k is the number of alleles. 
f1 
first quantile for inbreeding coefficient f 
f2 
second quantile for inbreeding coefficient f 
p1 
probability associated with 
p2 
probability associated with 
init 
initial values for 
lambdamu 
prior mean for λ 
lambdasd 
prior standard deviation for λ 
This function can be unstable and good starting values may be needed. It is also recommended to check the output by simulating from the given prior to see if the empirical quantiles match with those desired; the function SinglefPrior
may be used for this
Jon Wakefield (jonno@u.washington.edu)
Wakefield, J. (2010). Bayesian methods for examining HardyWeinberg equilibrium. Biometrics; Vol 66:25765
HWEImportSamp
1 2 3  bvec < c(1,1,1,1)
init < c(3,log(1.1))
lampr < LambdaOptim(nsim=10000,bvec=bvec,f1=0,f2=0.26,p1=0.5,p2=0.95,init)

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
All documentation is copyright its authors; we didn't write any of that.