1 ## theta.R (2002-08-28)
3 ## Population Parameter THETA
5 ## theta.h: using homozigosity
6 ## theta.k: using expected number of alleles
7 ## theta.s: using segregating sites in DNA sequences
9 ## Copyright 2002 Emmanuel Paradis
11 ## This file is part of the R-package `ape'.
12 ## See the file ../COPYING for licensing issues.
14 theta.h <- function(x, standard.error = FALSE)
16 HE <- H(x, variance = TRUE)
19 f <- function(th) HE - th * (1 + (2 * (1 + th)) / ((2 + th) * (3 + th)))
20 th <- uniroot(f, interval = c(0, 1))$root
22 SE <- (2 + th)^2 * (2 + th)^3 * sdH /
23 HE^2 * (1 + th) * ((2 + th) * (3 + th) * (4 + th) + 10 * (2 + th) + 4)
29 theta.k <- function(x, n = NULL, k = NULL)
39 if (is.factor(x)) { # ne pas remplacer par `else'...
44 f <- function(th) th * sum(1 / (th + (0:(n - 1)))) - k
45 th <- uniroot(f, interval = c(1e-8, 100))$root
49 theta.s <- function(s, n, variance = FALSE)
51 a1 <- sum(1 / (1:(n - 1)))
54 a2 <- sum(1 / (1:(n - 1))^2)
55 var.th <- (a1^2 * s + a2 * s^2) / (a1^2 * (a1^2 + a2))