[R] lm.fit algo

Pavlo Kononenko pkononenko at gmail.com
Mon Aug 17 23:09:32 CEST 2009


Hi, everyone,

This is a little silly, but I cant figure out the algorithm behind
lm.fit function used in the context of promax rotation algorithm:

The promax function is:

promax <- function(x, m = 4)
{
    if(ncol(x) < 2) return(x)
    dn <- dimnames(x)
    xx <- varimax(x)
    x <- xx$loadings
    Q <- x * abs(x)^(m-1)
    U <- lm.fit(x, Q)$coefficients
    d <- diag(solve(t(U) %*% U))
    U <- U %*% diag(sqrt(d))
    dimnames(U) <- NULL
    z <- x %*% U
    U <- xx$rotmat %*% U
    dimnames(z) <- dn
    class(z) <- "loadings"
    list(loadings = z, rotmat = U, crap = x, coeff = Q)
}

And the line I'm having trouble with is:

U <- lm.fit(x, Q)$coefficients

I'm trying to rewrite this routine in Java and got stuck on the lm.fit part.

Thanks,
~Pavlo




More information about the R-help mailing list