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

    Function polychor

    • Polychoric correlation of two ordinal variables. By default the two-step estimate: thresholds from the margins, then the maximum-likelihood correlation given them. Equivalent to polycor::polychor() in R. It takes x and y or a table, as polychor(x, y) or polychor(table).

      Given x and y, the table has the sorted distinct values of x as rows and those of y as columns (pairs with a missing value are not counted). Rows and columns with a zero margin are removed with a warning; with fewer than two rows or columns left, rho is NaN (and the result has no other fields).

      With ML, the correlation and the thresholds are estimated together by maximum likelihood; with stdErr, the result also has their variances, the 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

      • table: readonly (readonly number[])[]

        A contingency table (array of rows of counts).

      • options: PolycorOptions & { stdErr: true }

        ML and stdErr (see PolycorOptions).

      Returns PolychorStdErrResult

      polychor([[20, 8, 1], [5, 30, 9], [2, 6, 25]]).rho; // 0.785882312445335
      polychor([[20, 8, 1], [5, 30, 9], [2, 6, 25]], { ML: true }).rho; // 0.7911463316235798
    • Polychoric correlation of two ordinal variables. By default the two-step estimate: thresholds from the margins, then the maximum-likelihood correlation given them. Equivalent to polycor::polychor() in R. It takes x and y or a table, as polychor(x, y) or polychor(table).

      Given x and y, the table has the sorted distinct values of x as rows and those of y as columns (pairs with a missing value are not counted). Rows and columns with a zero margin are removed with a warning; with fewer than two rows or columns left, rho is NaN (and the result has no other fields).

      With ML, the correlation and the thresholds are estimated together by maximum likelihood; with stdErr, the result also has their variances, the 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

      • table: readonly (readonly number[])[]

        A contingency table (array of rows of counts).

      • Optionaloptions: PolycorOptions

        ML and stdErr (see PolycorOptions).

      Returns PolycorResult

      polychor([[20, 8, 1], [5, 30, 9], [2, 6, 25]]).rho; // 0.785882312445335
      polychor([[20, 8, 1], [5, 30, 9], [2, 6, 25]], { ML: true }).rho; // 0.7911463316235798
    • Polychoric correlation of two ordinal variables given as vectors of category codes (see the table form).

      Parameters

      • x: readonly number[]

        Categories of the first variable.

      • y: readonly number[]

        Categories of the second variable, the same length.

      • options: PolycorOptions & { stdErr: true }

        ML and stdErr (see PolycorOptions).

      Returns PolychorStdErrResult

    • Polychoric correlation of two ordinal variables. By default the two-step estimate: thresholds from the margins, then the maximum-likelihood correlation given them. Equivalent to polycor::polychor() in R. It takes x and y or a table, as polychor(x, y) or polychor(table).

      Given x and y, the table has the sorted distinct values of x as rows and those of y as columns (pairs with a missing value are not counted). Rows and columns with a zero margin are removed with a warning; with fewer than two rows or columns left, rho is NaN (and the result has no other fields).

      With ML, the correlation and the thresholds are estimated together by maximum likelihood; with stdErr, the result also has their variances, the 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

      Returns PolycorResult

      polychor([[20, 8, 1], [5, 30, 9], [2, 6, 25]]).rho; // 0.785882312445335
      polychor([[20, 8, 1], [5, 30, 9], [2, 6, 25]], { ML: true }).rho; // 0.7911463316235798