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

    Function qrCoef

    • Least-squares coefficients for a vector response. Equivalent to R's qr.coef().

      Coefficients are returned in the original column order. Coefficients of columns that were not used (those after position rank in pivot) are NaN (R's NA). For a decomposition computed with lapack: true, the first min(nrow, ncol) pivoted columns are used.

      Parameters

      • q: QR

        A QR decomposition from qr.

      • y: readonly number[] | Float64Array<ArrayBufferLike>

        The response vector, with as many elements as the decomposed matrix has rows.

      Returns number[]

      The coefficient vector (one element per column of the decomposed matrix).

      const q = qr([[1, 1], [1, 2], [1, 3], [1, 4]]);
      qrCoef(q, [2.1, 3.9, 6.2, 7.8]); // [0.15, 1.94] (up to rounding)
    • Least-squares coefficients for each column of a matrix response.

      Parameters

      • q: QR

        A QR decomposition from qr.

      • y: MatrixInput

        The response matrix (array of rows), with as many rows as the decomposed matrix.

      Returns number[][]

      The coefficients as an array of rows (one row per column of the decomposed matrix, one column per column of y).

    • Least-squares coefficients.

      Parameters

      Returns number[] | number[][]

      A vector if y is a vector, otherwise an array of rows.