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

    Function polyserial

    • Polyserial correlation of a numeric variable and an ordinal one. By default the two-step (ad hoc) estimate. Equivalent to polycor::polyserial(x, y) in R.

      Pairs with a missing value are dropped. The categories of y are its sorted distinct values, coded 1, 2, ...; with fewer than two, rho is NaN (and the result has no other fields). A two-step estimate beyond ±0.9999 is set to ±0.9999 with a warning.

      With ML, the correlation and the thresholds are estimated together by maximum likelihood; with stdErr, the result also has their variances, polycor's chi-square test of bivariate normality and the thresholds (with stdErr alone, the correlation is maximised given the two-step thresholds). The exact maximum is returned (R's optimisers stop about 1e-4 short of it). If the likelihood increases up to |rho| = 0.9999, rho is ±0.9999 with a warning.

      Parameters

      • x: readonly number[]

        The numeric variable.

      • y: readonly number[]

        Categories of the ordinal variable, the same length.

      • options: PolycorOptions & { stdErr: true }

        ML and stdErr (see PolycorOptions).

      Returns PolyserialStdErrResult

      polyserial([0.2, -1.1, 0.8, 1.5, -0.3, 0.1, -0.9, 2.0], [1, 1, 2, 3, 2, 2, 1, 2]).rho; // 0.8085111526489707
      
    • Polyserial correlation of a numeric variable and an ordinal one. By default the two-step (ad hoc) estimate. Equivalent to polycor::polyserial(x, y) in R.

      Pairs with a missing value are dropped. The categories of y are its sorted distinct values, coded 1, 2, ...; with fewer than two, rho is NaN (and the result has no other fields). A two-step estimate beyond ±0.9999 is set to ±0.9999 with a warning.

      With ML, the correlation and the thresholds are estimated together by maximum likelihood; with stdErr, the result also has their variances, polycor's chi-square test of bivariate normality and the thresholds (with stdErr alone, the correlation is maximised given the two-step thresholds). The exact maximum is returned (R's optimisers stop about 1e-4 short of it). If the likelihood increases up to |rho| = 0.9999, rho is ±0.9999 with a warning.

      Parameters

      • x: readonly number[]

        The numeric variable.

      • y: readonly number[]

        Categories of the ordinal variable, the same length.

      • Optionaloptions: PolycorOptions

        ML and stdErr (see PolycorOptions).

      Returns PolycorResult

      polyserial([0.2, -1.1, 0.8, 1.5, -0.3, 0.1, -0.9, 2.0], [1, 1, 2, 3, 2, 2, 1, 2]).rho; // 0.8085111526489707