R/ThetatoF.R

Defines functions ThetatoF

Documented in ThetatoF

ThetatoF <- function(p,theta=4) {
   # convert disequilibrium parameter theta to the inbreeding coefficient f.
   part <- p*(1-p)*(4-theta)
   z1 <- part
   z2 <- -2*part-theta
   z3 <- part
   z <- c(z1,z2,z3)
   out <- polyroot(z)
   f <- Re(out)
   minoraf <- min(p,1-p)
   fmin <- -minoraf/(1-minoraf)
   # only roots in the range [fmin,1] make sense.
   f <- f[f>fmin]
   f <- f[f<1] 
   return(f)
}

Try the HardyWeinberg package in your browser

Any scripts or data that you put into this service are public.

HardyWeinberg documentation built on May 7, 2022, 5:05 p.m.