R/tam_orthonormalize_design_matrix.R

Defines functions tam_orthonormalize_design_matrix

## File Name: tam_orthonormalize_design_matrix.R
## File Version: 0.05

tam_orthonormalize_design_matrix <- function(x, w, eps=1e-10)
{
    cov_x <- tam_weighted_cross_product(x=x, w=w)
    dimnames(cov_x) <- NULL
    svd_cov_x <- svd(cov_x)
    Aj <- svd_cov_x$d
    Qj <- svd_cov_x$u
    ind <- which( Aj > eps )
    Qj <- Qj[,ind]
    Aj <- Aj[ind]
    # transformation matrix
    Wt <- Qj %*% diag( 1 / sqrt(Aj) )
    Wt_inv <- Qj %*% diag(sqrt(Aj))
    # orthonormalized x
    xo <- x %*% Wt
    #-- output
    res <- list(xo=xo, Wt=Wt, Wt_inv=Wt_inv)
    return(res)
}

Try the TAM package in your browser

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

TAM documentation built on Aug. 29, 2022, 1:05 a.m.