TTest

TTest[data]
tests whether the mean of data is zero.

TTest[{data1, data2}]
tests whether the means of and are equal.

TTest[dspec, 0]
tests the mean against .

TTest[dspec, 0, "property"]
returns the value of .

Details and OptionsDetails and Options

  • TTest performs a hypothesis test on data with null hypothesis that the true population mean is some value , and alternative hypothesis that .
  • Given and , TTest tests that against that .
  • By default a probability value or -value is returned.
  • A small -value suggests that it is unlikely that is true.
  • The data in dspec can be univariate or multivariate .
  • The argument can be a real number or a real vector with length equal to the dimension of the data.
  • TTest assumes that the data is normally distributed but is fairly robust to this assumption. TTest also assumes that the samples are independent in the two sample case.
  • TTest[dspec, 0, "HypothesisTestData"] returns a HypothesisTestData object htd that can be used to extract additional test results and properties using the form htd["property"].
  • TTest[dspec, 0, "property"] can be used to directly give the value of .
  • Properties related to the reporting of test results include:
  • "DegreesOfFreedom"the degrees of freedom used in a test
    "PValue"list of -values
    "PValueTable"formatted table of -values
    "ShortTestConclusion"a short description of the conclusion of a test
    "TestConclusion"a description of the conclusion of a test
    "TestData"list of pairs of test statistics and -values
    "TestDataTable"formatted table of -values and test statistics
    "TestStatistic"list of test statistics
    "TestStatisticTable"formatted table of test statistics
  • For univariate samples, TTest performs a Student test. The test statistic is assumed to follow a StudentTDistribution[df].
  • For multivariate samples, TTest performs Hotelling's test. The test statistic is assumed to follow a HotellingTSquareDistribution[p, df] where p is the dimension of data.
  • The degrees of freedom df, used to specify the distribution of the test statistic, depend on the sample size, number of samples, and in the case of two univariate samples, the results of a test for equal variances.
  • The following options can be used:
  • AlternativeHypothesis"Unequal"the inequality for the alternative hypothesis
    SignificanceLevel0.05cutoff for diagnostics and reporting
    VerifyTestAssumptionsAutomaticwhat assumptions to verify
  • For the TTest, a cutoff is chosen such that is rejected only if . The value of used for the and properties is controlled by the SignificanceLevel option. This value is also used in diagnostic tests of assumptions, including tests for normality, equal variance, and symmetry. By default is set to .
  • Named settings for VerifyTestAssumptions in TTest include:
  • "Normality"verify that all data is normally distributed
    "EqualVariance"verify that and have equal variance

ExamplesExamplesopen allclose all

Basic Examples (3)Basic Examples (3)

Test whether the mean of a population is zero:

In[1]:=
Click for copyable input
In[2]:=
Click for copyable input
Out[2]=

The full test table:

In[3]:=
Click for copyable input
Out[3]=

Test whether the means of two populations differ by 2:

In[1]:=
Click for copyable input

The mean difference :

In[2]:=
Click for copyable input
Out[2]=
In[3]:=
Click for copyable input
Out[3]=

At the 0.05 level, is significantly different from 2:

In[4]:=
Click for copyable input
Out[4]=

Compare the locations of multivariate populations:

In[1]:=
Click for copyable input

The mean difference vector :

In[2]:=
Click for copyable input
Out[2]=
In[3]:=
Click for copyable input
Out[3]=

At the 0.05 level, is not significantly different from :

In[4]:=
Click for copyable input
Out[4]=
New in 8
New to Mathematica? Find your learning path »
Have a question? Ask support »