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

    Function cor

    • Correlation of two vectors, or correlation matrix of the columns of a matrix (or between the columns of x and y). Equivalent to R's cor(). Pearson correlations are computed in double-double, so they can be slightly more accurate than R's (exactly 1 for perfectly correlated data).

      Parameters

      Returns number

      cor([1, 2, 3, 4], [2, 4, 5, 9]);                         // 0.9647638212377322
      cor([1, 2, 3, 4], [2, 4, 5, 9], { method: "spearman" }); // 1
    • Correlation of two vectors, or correlation matrix of the columns of a matrix (or between the columns of x and y). Equivalent to R's cor(). Pearson correlations are computed in double-double, so they can be slightly more accurate than R's (exactly 1 for perfectly correlated data).

      Parameters

      • x: readonly (readonly number[])[] | Sample
      • Optionaly: readonly (readonly number[])[] | Sample
      • Optionaloptions: CovOptions

      Returns number | number[][]

      cor([1, 2, 3, 4], [2, 4, 5, 9]);                         // 0.9647638212377322
      cor([1, 2, 3, 4], [2, 4, 5, 9], { method: "spearman" }); // 1