Q: Q matrix of QR decomposion with missing data

Usage Arguments Examples

Usage

1
Q(x, verbose = 0)

Arguments

x
verbose

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (x, verbose = 0) 
{
    miss <- apply(x, 1, function(xx) any(is.na(xx)))
    xc <- x[!miss, ]
    qf <- qr.Q(qqr <- qr(xc))
    if (verbose > 0) {
        cat("xc:", dim(xc), "\n")
        cat("qf:", dim(qf), "\n")
        print(qf)
    }
    if (ncol(xc) > ncol(qf)) 
        xc <- xc[, 1:ncol(qf)]
    ip <- sign(apply(qf * xc, 2, sum))
    qf <- qf * rep(ip, rep(nrow(qf), length(ip)))
    ret <- array(NA, dim = c(nrow(x), ncol(qf)))
    rownames(ret) <- rownames(x)
    colnames(ret) <- colnames(xc)
    ret[!miss, ] <- qf
    attr(ret, "rank") <- qqr$rank
    attr(ret, "miss") <- miss
    ret
  }

gmonette/spida15 documentation built on May 17, 2019, 7:26 a.m.