R/R2.global.R

R2.global <-
function(z, partition)
{
    n <- tapply(partition, partition, length)
    m <- tapply(z, partition, mean)

    mT <- mean(z)
    v <- var(z)

    if (var(z) == 0)
    {
        return(0)
    }

    R2 <- sum(n*(m-mT)**2) / (v*(length(z)-1))

    return(R2)
}

Try the SPODT package in your browser

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

SPODT documentation built on May 2, 2019, 9:43 a.m.