qr.coef
Use a QR Matrix Decomposition

Description

Functions of a QR decomposition with a vector or matrix representing the response.

Usage

qr.coef(qr, y) 
qr.fitted(qr, y, k = qr$rank) 
qr.resid(qr, y) 
qr.qty(qr, y) 
qr.qy(qr, y) 
qr.solve(a, b, tol = 1e-07)

Arguments

qr an object of class "qr" representing a QR decomposition. Typically, this comes from a previous call to qr or lsfit.
y a vector or matrix of numeric (or complex) data (the "dependent" or "response" data). The length of the vector or the number of rows of the matrix must correspond to the number of rows in the x matrix from which the decomposition was computed.
a an object representing a QR decomposition or a matrix (qr.solve only).
b a vector or matrix containing the right-hand sides of the equation (qr.solve only).
tol the tolerance for detecting linear dependencies among columns of a when a is a matrix (qr.solve only).
k not supported in Spotfire Enterprise Runtime for R.
Value
qr.coef,
qr.fitted,
qr.resid
return the coefficients, the fitted values, and the residuals obtained by a least squares fit of y to the x matrix, from which qr was obtained.
qr.qy, qr.qty return the results of the matrix multiplications: Q %*% y and t(Q) %*% y (Conj(t(Q)) %*% y in the complex case), where Q is the order-nrow(x) orthogonal (or unitary) transformation represented by qr.
qr.solve returns the results of solve.qr(a, b) if a is a QR decomposition. This is the least squares solution of x h = b where a is the QR decomposition of x. If a is a matrix, the QR decomposition is computed first, then solve.qr is called.
References
Anderson, E., Bai, Z., Bischof, C., Blackford, S., Demmel, J., Dongarra, J., Du Croz, J., Greenbaum, A., Hammarling, S., McKenney, A., Sorensen D., (1999). LAPACK Users' Guide. SIAM, Philadelphia.
Thisted, R. A. (1988). Elements of Statistical Computing. Chapman and Hall, New York.
Differences between Spotfire Enterprise Runtime for R and Open-source R
Note
The results of qr.coef, qr.fitted, and qr.resid reflect an intercept term only if an intercept column is added to the matrix (as in a call to lm.fit).
The QR decomposition used does not contain an explicit orthogonal (or unitary) matrix.
See Also
qr, qr.X, lm.fit, solve,
Examples
x <- cbind(1, runif(20), runif(20, 1, 10))  # X matrix with constant
y <- x %*% c(2, 13.5, -0.7) + rnorm(20, 0, 0.2)
reg0 <- lm.fit(x, y, method = "qr")
coef(reg0)
qr.coef(reg0$qr, y)  # same values as coef(reg0)
qr.solve(x, y)  # also same values as coef(reg0)

z1 <- qr.fitted(reg0$qr, y) z2 <- qr.resid(reg0$qr, y) z3 <- qr.qy(reg0$qr, y) z4 <- qr.qty(reg0$qr, y)

Package base version 6.1.1-7
Package Index