ID EN
Miscellaneous

qr

R Base 3.6.2 🇮🇩 Bahasa Indonesia

qr menghitung dekomposisi QR suatu matriks.

Syntax

R
qr(x, …)
# S3 method for default
qr(x, tol = 1e-07 , LAPACK = FALSE, &#8230;)<p></p><p>qr.coef(qr, y)
qr.qy(qr, y)
qr.qty(qr, y)
qr.resid(qr, y)
qr.fitted(qr, y, k = qr$rank)
qr.solve(a, b, tol = 1e-7)
# S3 method for qr
solve(a, b, &#8230;)</p><p>is.qr(x)
as.qr(x)</p>

Arguments

Parameter Deskripsi
x a numeric or complex matrix whose QR decomposition is to be computed. Logical matrices are coerced to numeric.
tol the tolerance for detecting linear dependencies in the columns of x. Only used if LAPACK is false and x is real.
qr a QR decomposition of the type computed by qr.
y, b a vector or matrix of right-hand sides of equations.
a a QR decomposition or (qr.solve only) a rectangular matrix.
k effective rank.
LAPACK logical. For real x, if true use LAPACK otherwise use LINPACK (the default).
&#8230; further arguments passed to or from other methods

Return Value

Dekomposisi QR matriks yang dihitung oleh LINPACK(*) atau LAPACK. Komponen dalam nilai yang dikembalikan berhubungan langsung dengan nilai yang dikembalikan oleh DQRDC(2)/DGEQP3/ZGEQP3. matriks qra dengan dimensi yang sama dengan x. Segitiga atas berisi \(\bold{R}\) dekomposisi dan segitiga bawah berisi informasi tentang \(\bold{Q}\) dekomposisi (disimpan dalam bentuk kompak). Perlu diperhatikan bahwa penyimpanan yang digunakan oleh DQRDC dan DGEQP3 berbeda. vektor qrauxa dengan panjang ncol(x) yang berisi

Details

Dekomposisi QR memainkan peran penting dalam banyak teknik statistik. Secara khusus dapat digunakan untuk menyelesaikan persamaan \(\bold{Ax} = \bold{b}\) untuk matriks tertentu \(\bold{A}\), dan vektor \(\bold{b}\). Hal ini berguna untuk menghitung koefisien regresi dan dalam menerapkan algoritma Newton-Raphson. Fungsi qr.coef, qr.resid, dan qr.fitted mengembalikan koefisien, residu, dan nilai pas yang diperoleh saat menyesuaikan y ke matriks dengan dekomposisi QR qr. (Jika menggunakan pivot, beberapa koefisiennya adalah NA.) qr.qy dan qr.qty menghasilkan Q %*% y dan t(Q) %*% y, dengan Q adalah matriks (lengkap) \(\bold{Q}\). Semua fungsi di atas menyimpan nama dim (dan nama) x dan y jika ada. solve.qr adalah metode penyelesaian objek qr. qr.solve memecahkan sistem persamaan melalui QR

Contoh

Example
R
# NOT RUN {
hilbert <- function(n) { i <- 1:n; 1 / outer(i - 1, i, "+") }
h9 <- hilbert(9); h9
qr(h9)$rank           #--> only 7
qrh9 <- qr(h9, tol = 1e-10)
qrh9$rank             #--> 9
##-- Solve linear equation system  H %*% x = y :
y <- 1:9/10
x <- qr.solve(h9, y, tol = 1e-10) # or equivalently :
x <- qr.coef(qrh9, y) #-- is == but much better than
                      #-- solve(h9) %*% y
h9 %*% x              # = y


## overdetermined system
A <- matrix(runif(12), 4)
b <- 1:4
qr.solve(A, b) # or solve(qr(A), b)
solve(qr(A, LAPACK = TRUE), b)
# this is a least-squares solution, cf. lm(b ~ 0 + A)

## underdetermined system
A <- matrix(runif(12), 3)
b <- 1:3
qr.solve(A, b)
solve(qr(A, LAPACK = TRUE), b)
# solutions will have one zero, not necessarily the same one
# }

See Also

qr.Q qr.R qr.X for reconstruction of the matrices. lm.fit lsfit eigen svd. det (using qr) to compute the determinant of a matrix.