QR.Auxiliaries             package:base             R Documentation

_R_e_c_o_n_s_t_r_u_c_t _t_h_e _Q, _R, _o_r _X _M_a_t_r_i_c_e_s _f_r_o_m _a _Q_R _O_b_j_e_c_t

_D_e_s_c_r_i_p_t_i_o_n:

     Returns the original matrix from which the object was constructed
     or the components of the decomposition.

_U_s_a_g_e:

     qr.X(qr, complete = FALSE, ncol =)
     qr.Q(qr, complete = FALSE, Dvec =)
     qr.R(qr, complete = FALSE)

_A_r_g_u_m_e_n_t_s:

      qr: object representing a QR decomposition.  This will typically
          have come from a previous call to 'qr' or 'lsfit'.

complete: logical expression of length 1.  Indicates whether an
          arbitrary  orthogonal completion of the *Q* or *X* matrices
          is to be made, or whether the *R* matrix is to be completed 
          by binding zero-value rows beneath the square upper triangle.

    ncol: integer in the range '1:nrow(qr$qr)'.  The number of columns
          to be in the reconstructed *X*.  The default when 'complete'
          is 'FALSE' is the first 'min(ncol(X), nrow(X))' columns of
          the original *X* from which the qr object was constructed. 
          The default when 'complete' is 'TRUE' is a square matrix with
          the original *X* in the first 'ncol(X)' columns and an
          arbitrary orthogonal completion (unitary completion in the
          complex case) in the remaining columns.

    Dvec: vector (not matrix) of diagonal values.  Each column of the
          returned *Q* will be multiplied by the corresponding diagonal
          value.  Defaults to all '1's.

_V_a_l_u_e:

     'qr.X' returns *X*, the original matrix from which the qr object
     was constructed, provided 'ncol(X) <= nrow(X)'. If 'complete' is
     'TRUE' or the argument 'ncol' is greater than 'ncol(X)',
     additional columns from an arbitrary orthogonal (unitary)
     completion of 'X' are returned.

     'qr.Q' returns part or all of *Q*, the order-nrow(X) orthogonal
     (unitary) transformation represented by 'qr'.  If 'complete' is
     'TRUE', *Q* has 'nrow(X)' columns. If 'complete' is 'FALSE', *Q*
     has 'ncol(X)' columns.  When 'Dvec' is specified, each column of
     *Q* is multiplied by the corresponding value in 'Dvec'.

     'qr.R' returns *R*, the upper triangular matrix such that 'X == Q
     %*% R'.  The number of rows of *R* is 'nrow(X)' or 'ncol(X)',
     depending on whether 'complete' is 'TRUE' or 'FALSE'.

_S_e_e _A_l_s_o:

     'qr', 'qr.qy'.

_E_x_a_m_p_l_e_s:

     p <- ncol(x <- LifeCycleSavings[,-1]) # not the 'sr'
     qrstr <- qr(x)   # dim(x) == c(n,p)
     qrstr $ rank # = 4 = p
     Q <- qr.Q(qrstr) # dim(Q) == dim(x)
     R <- qr.R(qrstr) # dim(R) == ncol(x)
     X <- qr.X(qrstr) # X == x
     range(X - as.matrix(x))# ~ < 6e-12
     ## X == Q %*% R :
     Q %*% R

