lm():LINPACK/LAPACK中QR分解返回的qraux是什么

lm():LINPACK/LAPACK中QR分解返回的qraux是什么,r,matrix,regression,linear-regression,lm,R,Matrix,Regression,Linear Regression,Lm,rich.main3是R中的一个线性模型。我了解列表中的其余元素,但我不了解qraux是什么。文件上说它是 长度为ncol(x)的向量,包含关于“\bold{Q}”的附加信息 这意味着什么附加信息? str(rich.main3$qr) qr : num [1:164, 1:147] -12.8062 0.0781 0.0781 0.0781 0.0781 ... ..- attr(*, "dimnames")=List of 2 .. ..$ : chr [1:164] "1"

rich.main3
是R中的一个线性模型。我了解列表中的其余元素,但我不了解
qraux
是什么。文件上说它是

长度为ncol(x)的向量,包含关于“\bold{Q}”的附加信息

这意味着什么附加信息?

str(rich.main3$qr)

qr   : num [1:164, 1:147] -12.8062 0.0781 0.0781 0.0781 0.0781 ...


..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:164] "1" "2" "3" "4" ...
  .. ..$ : chr [1:147] "(Intercept)" "S2" "S3" "x1" ...
  ..- attr(*, "assign")= int [1:147] 0 1 1 2 3 4 5 6 7 8 ...
  ..- attr(*, "contrasts")=List of 3
  .. ..$ S    : chr "contr.treatment"
  .. ..$ ID   : chr "contr.treatment"
  .. ..$ Block: chr "contr.treatment"
 $ qraux: num [1:147] 1.08 1.06 1.16 1.21 1.27 ...
 $ pivot: int [1:147] 1 2 3 4 5 6 7 8 10 11 ...
 $ tol  : num 1e-07
 $ rank : int 21
 - attr(*, "class")= chr "qr"

大概你不知道QR分解是如何计算的。我用LaTeX写了以下内容,这可能会帮助你澄清这一点。当然,在一个编程网站上,我需要向你展示一些代码。最后,我为你提供了一个toy R function computing Householder反射


住户反射矩阵

户主转型

Householder QR因式分解(无旋转)

QR的紧凑存储和重新缩放


LAPACK辅助例程正在执行Householder变换。我还编写了以下toy R函数进行演示:

dlarfg <- function (x) {
  beta <- -1 * sign(x[1]) * sqrt(as.numeric(crossprod(x)))
  v <- c(1, x[-1] / (x[1] - beta))
  tau <- 1 - x[1] / beta
  y <- c(beta, rep(0, length(x)-1L))
  packed_yv <- c(beta, v[-1])
  oo <- cbind(x, y, v, packed_yv)
  attr(oo, "tau") <- tau
  oo
  }

你有什么想法吗,为什么他们不直接存储
u
(标准化
v
)?这样,应用H可以更快,因为不需要与tau相乘。我在这里问了这个问题:
set.seed(0); x <- rnorm(5)
dlarfg(x)
#              x         y           v   packed_yv
#[1,]  1.2629543 -2.293655  1.00000000 -2.29365466
#[2,] -0.3262334  0.000000 -0.09172596 -0.09172596
#[3,]  1.3297993  0.000000  0.37389527  0.37389527
#[4,]  1.2724293  0.000000  0.35776475  0.35776475
#[5,]  0.4146414  0.000000  0.11658336  0.11658336
#attr(,"tau")
#[1] 1.55063