LocationTest

LocationTest[data]
tests whether the mean or median of the data is zero.

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

LocationTest[dspec, 0]
tests a location measure against .

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

Details and OptionsDetails and Options

  • LocationTest performs a hypothesis test on data with null hypothesis that the true population location parameter is some value , and alternative hypothesis that .
  • Given and , LocationTest 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.
  • LocationTest[dspec] will choose the most powerful test that applies to dspec.
  • LocationTest[dspec, Automatic] is equivalent to .
  • LocationTest[dspec, 0, All] will choose all tests that apply to dspec.
  • LocationTest[dspec, 0, "test"] reports the -value according to .
  • Tests based on means assume the data in dspec is normally distributed. Some tests assume the data is symmetric about a common median. Tests that do not assume symmetry or normality are classified as robust.
  • A paired sample test assumes equal-length dependent data.
  • The following tests can be used:
  • "PairedT"normalitypaired sample test with unknown variance
    "PairedZ"normalitypaired sample test with known variance
    "Sign"robustmedian test for one sample or matched pairs
    "SignedRank"symmetrymedian test for one sample or matched pairs
    "T"normalitymean test for one or two samples
    "MannWhitney"symmetrymedian test for two independent samples
    "Z"normalitymean test with known variance
  • The test performs Student -test for univariate data and Hotelling's test for multivariate data.
  • The test performs a -test assuming the sample variance is the known variance for univariate data and Hotelling's test assuming the sample covariance is the known covariance for multivariate data.
  • The and tests perform and tests on the paired differences of two datasets. A single dataset is treated as a list of differences.
  • LocationTest[dspec, 0, "HypothesisTestData"] returns a HypothesisTestData object htd that can be used to extract additional test results and properties using the form htd["property"].
  • LocationTest[dspec, 0, "property"] can be used to directly give the value of .
  • Properties related to the reporting of test results include:
  • "AllTests"list of all applicable tests
    "AutomaticTest"test chosen if Automatic is used
    "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
  • The following options can be used:
  • AlternativeHypothesis"Unequal"the inequality for the alternative hypothesis
    MaxIterationsAutomaticmax iterations for multivariate median tests
    MethodAutomaticthe method to use for computing -values
    SignificanceLevel0.05cutoff for diagnostics and reporting
    VerifyTestAssumptionsAutomaticwhat assumptions to verify
  • For tests of location, 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 LocationTest include:
  • "EqualVariance"verify that and have equal variance
    "Normality"verify that all data is normally distributed
    "Symmetry"verify symmetry about a common median

ExamplesExamplesopen allclose all

Basic Examples (3)Basic Examples (3)

Test whether the mean or median of a population is zero using a collection of tests:

In[1]:=
Click for copyable input
In[2]:=
Click for copyable input
Out[2]=
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 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 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 »