Hi,
On Aug 17, 2009, at 5:09 PM, Pavlo Kononenko wrote:
> 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
Isn't this doing a least squares regression using the predictor
variables in x and the (I guess) real valued numbers in vector Q?
x is a matrix of n (observations) by p (predictors)
The $coefficients is just taking the vector of coefficients/weights
over the predictors -- this would be a vector of length p -- such that
x %*% t(t(U)) ~ Q
* t(t(U)) is ugly, but I just want to say get U to be a column vector
* ~ is used as "almost equals")
You'll need some numerical/scientific/matrix library in java, perhaps
this could be a place to start:
http://commons.apache.org/math/userguide/stat.html#a1.5_Multiple_linear_regression
Hope that helps,
-steve
--
Steve Lianoglou
Graduate Student: Computational Systems Biology
| Memorial Sloan-Kettering Cancer Center
| Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact