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

    Function stuartMaxwellTest

    • Stuart-Maxwell test of marginal homogeneity of a square table (paired classifications into the same categories). Equivalent to DescTools::StuartMaxwellTest() in R. The degrees of freedom differ where categories are removed.

      Categories with no counts off the diagonal (in their row and column) are removed. With the K categories left, d the differences of the row and column sums of the first K - 1 and S their covariance (S_ii = r_i + c_i - 2 x_ii, S_ij = -(x_ij + x_ji)), the statistic d' S^-1 d is chi-squared with K - 1 degrees of freedom (DescTools keeps the original number of categories less 1). For a 2 x 2 table it is McNemar's statistic without correction.

      Parameters

      • table: readonly Counts[]

        A square table of counts as an array of rows.

      Returns StuartMaxwellTestResult

      The test result, with statisticName "chi-squared"; see StuartMaxwellTestResult.

      RangeError for a table that is not square with at least two rows, negative or non-finite counts, fewer than 2 categories left ("Too many equal marginals, cannot compute") and categories whose off-diagonal counts fall into unconnected groups (S is then singular).

      stuartMaxwellTest([[20, 3, 2], [4, 15, 6], [1, 5, 30]]).statistic; // 0.30534351145038163