Documentation/Calc Functions/TTEST

    From The Document Foundation Wiki

    Function name:

    TTEST

    Category:

    Statistical Analysis

    Summary:

    Performs a two-sample t-test and returns a probability (p-value), which can be used to infer whether there is evidence that the two samples are drawn from populations with different means.

    A t-test is a commonly used statistical hypothesis test designed to investigate the means of two sample data sets. TTEST can perform three different types of t-test:

    • A paired samples comparison of means
    • A comparison of means for independent samples assuming equal population variances
    • A comparison of means for independent samples assuming unequal population variances

    In addition, TTEST can optionally perform either a one-tailed or a two-tailed t-test.

    Syntax:

    TTEST(Data 1; Data 2; Mode; Type)

    Returns:

    Returns a real number in the range [0, 1], which is the probability (p-value) calculated for a t-test with the given arguments. This probability is computed assuming a null hypothesis in which the two samples come from the same population. The smaller the returned probability, the greater the evidence that the two samples are from populations with different means.

    Arguments:

    Data 1 is an array of real numbers that is one of the sample data sets. This argument can take the form of an explicit cell range, the name of a named range, the name of a database range, or an inline constant array.

    Data 2 is an array of real numbers that is the other sample data set. This argument can take the form of an explicit cell range, the name of a named range, the name of a database range, or an inline constant array. If the Type argument is set to 1, then Data 1 and Data 2 should have the same dimensions.

    Mode is an integer value of 1 or 2, or a reference to a cell containing that number, which indicates how many tails should be used in the test. If Mode is equal to 1 then TTEST performs a one-tailed test and if Mode equals 2 then it performs a two-tailed test.

    Type is an integer in the range [1, 3], or a reference to a cell containing that number, which indicates the type of t-test to perform. Set Type to 1 for a paired samples comparison of means; set Type to 2 for a comparison of means for independent samples assuming equal population variances; and set Type to 3 for a comparison of means for independent samples assuming unequal population variances.

    • If either Mode or Type is non-numeric, then TTEST reports a #VALUE! error.
    • TTEST ignores any cell in Data 1 or Data 2 that contains text or is empty.
    • If either Mode or Type is a non-integer value, then TTEST truncates it to an integer value.
    • If, after any truncation, Mode is less than 1 or greater than 2, then TTEST reports an invalid argument error (Err:502).
    • If, after any truncation, Type is less than 1 or greater than 3, then TTEST reports an invalid argument error (Err:502).
    • If, after any truncation, Type is equal to 1 and the dimensions of Data 1 and Data 2 are different, then TTEST reports an invalid argument error (Err:502).

    Additional details:

    • Calc's T.TEST and TTEST functions perform identical calculations. The requirements for TTEST are specified in ODF 1.2; T.TEST is provided for interoperability with Microsoft Excel.
    • For more information on t-tests, visit Wikipedia's Student's t-test page.

    Examples:

    The data in the following table is utilized in the examples that follow. Three sample data sets are provided and the objective of the t-tests are to compare the means of Sample 1 and Sample 2, and the means of Sample 1 and Sample 3.

      A B C
    1 Sample 1 Sample 2 Sample 3
    2 -1.34 -1.45 2
    3 -0.775 -1.16 0.215
    4 -1.19 -0.646 3.28
    5 -2.86 -3.07 3.69
    6 -0.603 2.6 1.33
    7 0.113 0.0215 1.14
    8 -2.11 0.143 0.685
    9 -0.0596 -2 1.79
    10 0.0541 2.03 -1.17
    11 2.65 -1.34 1.75
    12 -1.29 1.63 3.27
    13 1.51 1.27 2.28
    14 -0.433 -0.552 -1.93
    15 0.0838 -1.07 3.74
    16 2.79 1.84 0.589


    Formula Description Returns
    =TTEST(A2:A16; B2:B16; 1; 1) using the data shown in the table above. Here the function calculates a one-tailed t-test for a paired samples comparison of the means of Sample 1 and Sample 2. The high p-value returned provides no evidence contradicting the null hypothesis that the two samples come from the same population. Note that a two-tailed version of the same test with the formula =TTEST(A2:A16; B2:B16; 2; 1) returns 0.819175028404305, which is twice the value for a one-tailed test. 0.409587514202152
    =TTEST(A2:A16; C2:C16; 1; 2) using the data shown in the table above. Here the function calculates a one-tailed t-test for a comparison of the means of Sample 1 and Sample 3 as independent samples assuming equal population variances. In this case, the low p-value returned provides evidence that contradicts the null hypothesis that the two samples come from the same population – it is more likely that Sample 1 and Sample 3 are drawn from populations with different means. Note that a two-tailed version of the same test with the formula =TTEST(A2:A16; C2:C16; 2; 2) returns 0.00671471460933283, which is twice the value for a one-tailed test but still very low. 0.00335735730466641
    =TTEST({4.5, 3.2, 0.3, -3.5, -2.6}; {5.6, -3.4, -1.1, -2.3}; 2.5; 3.9) Here the function calculates a t-test for the two samples passed as inline arrays. The Mode and Type are both non-integer values and are truncated to integers 2 and 3 respectively. Note that the dimensions of the first two arguments are not the same and this is valid when the Mode argument is set to 2 or 3. 0.799036131214819

    Related LibreOffice functions:

    F.TEST

    FTEST

    T.DIST

    T.DIST.2T

    T.DIST.RT

    T.INV

    T.INV.2T

    T.TEST

    TDIST

    TINV

    Z.TEST

    ZTEST

    ODF standard:

    Section 6.18.81, part 2

    Related (or similar) Excel functions:

    TTEST