R/CAeig.R

`CAeig` <-
function (Y) 
{
    Y <- as.matrix(Y)/sum(Y)
    r <- rowSums(Y)
    c <- colSums(Y)
    YY <- diag(1/sqrt(c)) %*% t(Y) %*% diag(1/r) %*% Y %*% diag(1/sqrt(c))
    SOL <- eigen(YY, symmetric = TRUE)
    SOL$vectors <- diag(1/sqrt(c)) %*% SOL$vectors
    SOL$u <- Y %*% SOL$vectors
    SOL$u <- diag(1/r) %*% SOL$u %*% diag(1/sqrt(SOL$values))
    SOL$u <- SOL$u[,-1]
    SOL$vectors <- SOL$vectors[,-1]
    SOL$values <- SOL$values[-1]
    SOL
}

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.