X-Git-Url: https://git.donarmstrong.com/?p=ape.git;a=blobdiff_plain;f=R%2Fcompar.ou.R;h=2e1d3a512dbf63ce810542b902468ef04193032d;hp=7732b31bf6f0c6582e0a9afae50fbebb380a7b7e;hb=071f848fadb1be486490a10f3de8324d3aaa5cb7;hpb=2741f6e9f61e33c7b499f27c47604606d08f4bea diff --git a/R/compar.ou.R b/R/compar.ou.R index 7732b31..2e1d3a5 100644 --- a/R/compar.ou.R +++ b/R/compar.ou.R @@ -1,4 +1,4 @@ -## compar.ou.R (2010-03-15) +## compar.ou.R (2010-11-04) ## Ornstein--Uhlenbeck Model for Continuous Characters @@ -53,8 +53,9 @@ compar.ou <- function(x, phy, node = NULL, alpha = NULL) ## fixed a bug below: must be '%*% theta' instead of '* theta' (2010-03-15) M <- rowSums((exp(-alpha * Wend) - exp(-alpha * Wstart)) %*% theta) V <- exp(-alpha * W) * (1 - exp(-2 * alpha * (Tmax - W/2))) - n * log(2 * pi * sigma2) + log(det(V)) + - (t(x - M) %*% chol2inv(V) %*% (x - M)) / sigma2 + R <- chol(V) # correction by Cecile Ane (2010-11-04) + n * log(2 * pi * sigma2) + 2 * sum(log(diag(R))) + + (t(x - M) %*% chol2inv(R) %*% (x - M)) / sigma2 } out <- if (is.null(alpha))