R/CCAwa1.R

Defines functions `CCAwa1`

`CCAwa1` <-
    function(Y, X)
{
    require(vegan) || stop("requires wascores function in vegan")
    EPS <- sqrt(.Machine$double.eps)
    X <- as.matrix(X)
    wts <- rowSums(Y)
    u <- rnorm(nrow(Y))
    eig <- 0
    repeat {
        v <- wascores(u, Y, expand = TRUE)
        w <- wascores(v, t(Y), expand = TRUE)
        u <- fitted(lm(w ~  X, w = wts))
        if (abs(attr(v, "shrinkage") - eig) < EPS)
            break
        eig <- attr(v, "shrinkage")
    }
    list(eig = attr(v, "shrinkage"), w = w, u = u, v = v)
}

Try the barebone package in your browser

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

barebone documentation built on May 2, 2019, 5:17 p.m.