rStats.js v1.3.0
    Preparing search index...

    Function qr

    • QR decomposition. Equivalent to R's qr().

      By default this uses Householder transformations with R's LINPACK-style limited column pivoting: columns that are (nearly) linearly dependent on earlier ones, as judged by tol, are moved to the right end and the rank is reduced. With lapack: true it uses LAPACK-style column pivoting (R's LAPACK = TRUE).

      The default method throws on NaN or infinite values. With lapack: true, such input does not throw and the result may differ from R's (which is not meaningful either).

      Parameters

      Returns QR

      The decomposition in compact form. See QR.

      // Least-squares fit of y on an intercept and x
      const q = qr([[1, 1], [1, 2], [1, 3], [1, 4]]);
      q.rank; // 2
      qrCoef(q, [2.1, 3.9, 6.2, 7.8]); // [0.15, 1.94] (up to rounding)