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

    Function aov

    • Analysis of variance. Equivalent to R's aov(). From samples, one way: the fit of the model y ~ g (as aov("y ~ g", data)), with the values in a column y and the groups as a factor g; aovSummary gives the table of R's summary(aov(y ~ g)).

      The levels of g are the group labels (sorted as R orders factor levels), or the positions of the samples in the list (from 1) for an array of samples, as in TukeyHSD. Missing values are left out, and a sample left empty has no level.

      Parameters

      • x: Sample | readonly Sample[]

        An array of samples (groups), or one sample with group labels g.

      • Optionalg: readonly GroupLabel[]

        Group labels, parallel to x.

      Returns LmFormulaResult

      const fit = aov([[2.9, 3.0, 2.5, 2.6, 3.2], [3.8, 2.7, 4.0, 2.4], [2.8, 3.4, 3.7, 2.2, 2.0]]);
      const t = aovSummary(fit);
      t.rowNames; // ["g", "Residuals"]
      t.table[0]; // [2, 0.44678571428571, 0.22339285714286, 0.56007326007326, 0.58663299104174]
    • Analysis of variance from a model formula, as R's aov(formula, data) (with weights and contrasts): the same fit as lm with a formula; aovSummary gives the table of R's summary(aov(...)). With one Error() term (y ~ W + Error(id/W)) the fit has error strata: the result is an AovStrataFit whose tables aovSummary returns, one per stratum.

      Parameters

      • formula: string

        A formula such as "y ~ A * B".

      • data: DataFrame

        The data frame: an object of columns.

      • Optionaloptions: LmFormulaOptions

      Returns LmFormulaResult | AovStrataFit

      const fit = aov("y ~ g", { y: [4.2, 5.1, 6.3, 5.8, 7.9, 8.4], g: ["a", "a", "b", "b", "c", "c"] });
      aovSummary(fit).rowNames; // ["g", "Residuals"]