R_ the QR Decomposition of a Matrix

© All Rights Reserved

23 views

R_ the QR Decomposition of a Matrix

© All Rights Reserved

- Reservoir Monitoring PNL
- VisionWorkbook-2010-01-07
- opencv2refman
- COBOL Lab
- List of Programs for Practical Class XII
- Introduction to Matlab 1
- Unit-I
- Mathematical Economics Course Outline
- HASHIM_Optimal Speed Control for DC Motors Using LQR
- Introduction to Mathcad
- Chapter 20 I Matrices ENHANCE
- Mathematics Form 5
- Matrices Basic Concepts
- Free Open Source Software
- lecture notes
- CPP Arrays
- design project 1 edsgn 100 1
- Matrix Algebra Notes
- Memory Address Calculation in an Array – Guide for School
- Linear Maps

You are on page 1of 4

html

qr {base} R Documentation

Description

Usage

qr(x, ...)

## Default S3 method:

qr(x, tol = 1e-07 , LAPACK = FALSE, ...)

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 class 'qr'

solve(a, b, ...)

is.qr(x)

as.qr(x)

Arguments

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).

...

further arguments passed to or from other methods

1 of 4 17/Sep/2017, 4:41 PM

R: The QR Decomposition of a Matrix http://127.0.0.1:31810/library/base/html/qr.html

Details

The QR decomposition plays an important role in many statistical techniques. In particular it can

be used to solve the equation \bold{Ax} = \bold{b} for given matrix \bold{A}, and vector \bold{b}.

It is useful for computing regression coefficients and in applying the Newton-Raphson algorithm.

The functions qr.coef, qr.resid, and qr.fitted return the coefficients, residuals and fitted

values obtained when fitting y to the matrix with QR decomposition qr. (If pivoting is used, some

of the coefficients will be NA.) qr.qy and qr.qty return Q %*% y and t(Q) %*% y, where Q is the

(complete) \bold{Q} matrix.

All the above functions keep dimnames (and names) of x and y if there are any.

solve.qr is the method for solve for qr objects. qr.solve solves systems of equations via the

QR decomposition: if a is a QR decomposition it is the same as solve.qr, but if a is a rectangular

matrix the QR decomposition is computed first. Either will handle over- and under-determined

systems, providing a least-squares fit if appropriate.

It is not possible to coerce objects to mode "qr". Objects either are QR decompositions or they are

not.

The LINPACK interface is restricted to matrices x with less than 2^31 elements.

Unsuccessful results from the underlying LAPACK code will result in an error giving a positive

error code: these can only be interpreted by detailed study of the FORTRAN code.

Value

in the returned value correspond directly to the values returned by DQRDC(2)/DGEQP3

/ZGEQP3.

qr

a matrix with the same dimensions as x. The upper triangle contains the \bold{R} of the

decomposition and the lower triangle contains information on the \bold{Q} of the

decomposition (stored in compact form). Note that the storage used by DQRDC and

DGEQP3 differs.

qraux

a vector of length ncol(x) which contains additional information on \bold{Q}.

rank

the rank of x as computed by the decomposition(*): always full rank in the LAPACK case.

pivot

information on the pivoting strategy used during the decomposition.

2 of 4 17/Sep/2017, 4:41 PM

R: The QR Decomposition of a Matrix http://127.0.0.1:31810/library/base/html/qr.html

Non-complex QR objects computed by LAPACK have the attribute "useLAPACK" with value TRUE.

In the (default) LINPACK case (LAPACK = FALSE), qr() uses a modified version of LINPACK's

DQRDC, called dqrdc2. It differs by using the tolerance tol for a pivoting strategy which

moves columns with near-zero 2-norm to the right-hand edge of the x matrix. This strategy means

that sequential one degree-of-freedom effects can be computed in a natural way.

Note

To compute the determinant of a matrix (do you really need it?), the QR decomposition is much

more efficient than using Eigen values (eigen). See det.

Using LAPACK (including in the complex case) uses column pivoting and does not attempt to

detect rank-deficient matrices.

Source

For qr, the LINPACK routine DQRDC (but modified to dqrdc2(*)) and the LAPACK routines

DGEQP3 and ZGEQP3. Further LINPACK and LAPACK routines are used for qr.coef, qr.qy and

qr.aty.

and their guides are listed in the references.

References

Anderson. E. and ten others (1999) LAPACK Users' Guide. Third Edition. SIAM.

Available on-line at http://www.netlib.org/lapack/lug/lapack_lug.html.

Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth &

Brooks/Cole.

Dongarra, J. J., Bunch, J. R., Moler, C. B. and Stewart, G. W. (1978) LINPACK Users Guide.

Philadelphia: SIAM Publications.

See Also

qr.Q, qr.R, qr.X for reconstruction of the matrices. lm.fit, lsfit, eigen, svd.

Examples

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

3 of 4 17/Sep/2017, 4:41 PM

R: The QR Decomposition of a Matrix http://127.0.0.1:31810/library/base/html/qr.html

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

4 of 4 17/Sep/2017, 4:41 PM

- Reservoir Monitoring PNLUploaded byRioPrawira
- VisionWorkbook-2010-01-07Uploaded byShuja Ahmed
- opencv2refmanUploaded bysndupont
- COBOL LabUploaded bysurekhalathan
- List of Programs for Practical Class XIIUploaded bykishan_pant4645
- Introduction to Matlab 1Uploaded byNiketGhelani
- Unit-IUploaded bysonu modi
- Mathematical Economics Course OutlineUploaded byishtiaqlodhran
- HASHIM_Optimal Speed Control for DC Motors Using LQRUploaded byAnonymous PsEz5kGVae
- Introduction to MathcadUploaded byjayalakshmi
- Chapter 20 I Matrices ENHANCEUploaded byjuriah binti ibrahim
- Mathematics Form 5Uploaded byNurul Atirah
- Matrices Basic ConceptsUploaded byAitazaz Ahsan
- Free Open Source SoftwareUploaded byfpttmm
- lecture notesUploaded byfdsfsdfsd
- CPP ArraysUploaded byjosefalarka
- design project 1 edsgn 100 1Uploaded byapi-397442768
- Matrix Algebra NotesUploaded byAssan Achibat
- Memory Address Calculation in an Array – Guide for SchoolUploaded byvivek
- Linear MapsUploaded byAshvin Grace
- 140368616-Haykin-Xue-Neural-Networks-and-Learning-Machines-3ed-Soln.pdfUploaded byLucius Morningstar
- Dynamic Composite Cracked Element ModelUploaded byAbdul Khader Shahadaf
- UntitledUploaded byapi-63318741
- Matlab LectUploaded bymensahgraham
- XLTHNN_Hoi.docxUploaded byGiahoi Tcdn
- Vectors and Matrices FinalUploaded byPG Chong
- Www Sanfoundry Com (1)Uploaded byanis ansari
- Math141b Set 6 f18Uploaded byNema Elfaramawy
- DEES Science II (1).docxUploaded byBernie Mac
- Adversarial Character AnimationUploaded byJohn Doe

- R cheatsheet Data WranglingUploaded byarekbee
- Lunar 2018Uploaded byloshude
- R_ Character Translation and CasefoldingUploaded byloshude
- R_ Report Capabilities of This Build of RUploaded byloshude
- Datatable Cheat Sheet RUploaded byloshude
- R_ Numeric VersionsUploaded byloshude
- R_ Push Text Back on to a ConnectionUploaded byloshude
- R_ Class for 'No Quote' Printing of Character StringsUploaded byloshude
- R_ Time Intervals _ DifferencesUploaded byloshude
- R_ Date ClassUploaded byloshude
- R_ Combine Values Into a Vector or ListUploaded byloshude
- R_ Functions to Retrieve Values Supplied by Calls to the BrowserUploaded byloshude
- R_ Functions to Manipulate Connections (Files, URLs, ...)Uploaded byloshude
- R_ Apply a Function to a Data Frame Split by FactorsUploaded byloshude
- R_ Bitwise Logical OperationsUploaded byloshude
- R_ Binding and Environment Locking, Active BindingsUploaded byloshude
- R_ Environment AccessUploaded byloshude
- R_ QuotesUploaded byloshude
- R_ Display Numbers in OctalUploaded byloshude
- R_ Approximate String Matching (Fuzzy Matching)Uploaded byloshude
- R_ Lists - Generic and Dotted PairsUploaded byloshude
- R_ Date-Time ClassesUploaded byloshude
- R_ FactorsUploaded byloshude
- R_ Determine Duplicate ElementsUploaded byloshude
- Approximate String Distances in RUploaded byloshude
- Data Output in rUploaded byloshude
- Dplyr Windows Rank in rUploaded byloshude
- Dplyr Helpers in rUploaded byloshude
- dphly lead lag in rUploaded byloshude

- 01_10_2013_15_26_40MV Current Transformers.pdfUploaded byMihai Bancu
- Measurements and Instrumentation Objective Type QuestionsUploaded byDinesh Panchal
- Regenerative Breaking SystemUploaded byDishant Chauhan
- 05-CE10302_1185Uploaded bybutelcanec
- Achieve Realistic Caustics in 3D Studio Max with Mental RayUploaded byMarieta Delcheva Petkova
- 08-Semeter Radar Signal ProcessingUploaded byPK Verma
- (EXS 87) Riccardo a. a. Muzzarelli (Auth.), Prof. Dr. P. Jolles, Prof. R. a. a. Muzzarelli (Eds.)-Chitin and Chitinases-Birkhauser Basel (1999)Uploaded byMozart7
- BS EN 1926:2006Uploaded bylkzasj dksik
- PowerPoint Presentation (5822034)Uploaded byNaga Lakshmaiah
- Activated Carbon FilterUploaded byrohitkush
- CHAPTER 1 IntroductionUploaded byShamima akter
- Exemplo 9.5, Tipler e MoscaUploaded byLaís Velame
- Combined Gas Law Problems and answersUploaded byDimple Quibranza
- koefisien TanahUploaded bypatrik_rantetanayaho
- Magnetic susceptibility of petroleum reservoir ﬂuids.pdfUploaded bydelmarciogomes6739
- Reaction MechanismUploaded bySiddarth Singh
- Analysis of Slabs SpanningUploaded bynuwan01
- ENVI_MosaickingUploaded bykalebtekle
- RussiaPower 2012_Moscow_Paper Siemens_SGT5-2000E_Richter-Rev.pdfUploaded byDidik Agus Setiawan
- Virtual Retinal DisplayUploaded bysaket_mn
- Exam 1 8.022Uploaded byAbhik Sarkar
- kinematics in one dimensionUploaded bySandra Meru
- JEE-Main-2014-Online-11-04-14Uploaded byKumar Sujeet
- 194302 Desert Magazine 1943 FebruaryUploaded bydm1937
- 2a. Glukoza, GOD-PAPUploaded byMarija Kondeva
- solar water heatingUploaded byapi-240887715
- 1 a Signals and SpectraUploaded byKeith Aguilar Zarate
- Demonstrate Simple Phase Demodulation Using Hilbert TransformUploaded byYonathan Setiawan
- rotor dynamic without equationsUploaded byUygar Durgunay
- Quad CopterUploaded byyogesh