Sample.
Optionaly: Sample | TTestOptions
Second sample for a two-sample or paired test. May be omitted, and the options
passed in its place: tTest(x, { mu: 1 }).
Optionaloptions: TTestOptions
See TTestOptions.
The test result, with statisticName "t"; see TTestResult.
const r = tTest([5.1, 4.9, 5.6, 5.8, 6.0, 5.4], { mu: 5 });
r.statistic; // 2.7351263280759737
r.parameter; // 5
r.pValue; // 0.04102919855187924
r.confInt; // [5.028074545960439, 5.905258787372895]
tTest([1, 2, 3, 4, 5], [3, 4, 5, 6, 8]).pValue; // 0.0849560662972433 (Welch)
There is also a formula form, tTest("y ~ g", data, options) (next overload).
Student's t-test from a formula and a data frame. As R's t.test(formula, data): "y ~ g" compares
the two levels of g (the first level is x; estimateNames and nullValueName name the levels, as in R),
"y ~ 1" is the one-sample test and "Pair(a, b) ~ 1" the paired test of a and b (the option paired is not
allowed). Only the variables of the formula count: the rows where one of them is missing are dropped.
"y ~ g", "y ~ 1" or "Pair(a, b) ~ 1".
The data frame: an object of columns (null or NaN for a missing value).
Optionaloptions: TTestOptions
See TTestOptions.
Student's t-test. Equivalent to R's
t.test().Performs a one-sample, two-sample (Welch's by default, or pooled-variance with
varEqual: true) or paired t-test.NaNvalues are dropped. As in R, each sample needs 2 observations, except that withvarEqual: truea two-sample test needs 1 in each and 3 in all; an error is also thrown if the data are essentially constant.