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

    Function propTrendTest

    • Chi-squared test for trend in proportions. Equivalent to R's prop.trend.test(x, n, score). The scores are the third argument or the option score (giving both is a RangeError).

      Parameters

      • x: Sample

        Numbers of events.

      • n: Sample

        Numbers of trials.

      • Optionalscore: Sample

        Scores of the groups. Default 1, 2, ..., k. A group with a NaN score is left out of the regression (as R's lm omits it), but its counts stay in the pooled proportion and the weights, as in R. Other scores must be finite, with at least two distinct values. With no events or only events (all proportions 0, or all 1) the test is not defined (an error, as in R).

      Returns PropTrendTestResult

      propTrendTest([15, 10, 8, 4], [30, 30, 30, 30]).statistic; // 9.573428850537288
      
    • Chi-squared test for trend in proportions, with the scores in the options: propTrendTest(x, n, { score: [0, 1, 2, 4] }).

      Parameters

      Returns PropTrendTestResult

      propTrendTest([15, 10, 8, 4], [30, 30, 30, 30], { score: [1, 2, 3, 4] }).statistic; // 9.573428850537288