This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

LocationTest

LocationTest[data]
tests whether the mean or median of the data is zero.
LocationTest
tests whether the means or medians of and are equal.
LocationTest
tests a location measure against .
LocationTest
returns the value of .
  • LocationTest performs a hypothesis test on data with null hypothesis that the true population location parameter is some value , and alternative hypothesis 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.
  • 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 returns a HypothesisTestData object htd that can be used to extract additional test results and properties using the form htd["property"].
  • 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 .
"EqualVariance"verify that and have equal variance
"Normality"verify that all data is normally distributed
"Symmetry"verify symmetry about a common median
Test whether the mean or median of a population is zero using a collection of tests:
Test whether the means of two populations differ by 2:
The mean difference :
At the level is significantly different from 2:
Compare the locations of multivariate populations:
The mean difference vector :
At the level is not significantly different from :
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]=
Test versus :
The -values are typically large when the mean is close to 0:
The -values are typically small when the mean is far from 0:
Using Automatic is equivalent to testing for a mean of zero:
Test versus :
The -values are typically large when the mean is close to :
The -values are typically small when the mean is far from :
Test whether the mean vector of a multivariate population is the zero vector:
Alternatively, test against :
Using Automatic applies the generally most powerful appropriate test:
The property can be used to determine which test was chosen:
Test versus :
The -values are generally small when the locations are not equal:
The -values are generally large when the locations are equal:
Test versus :
The order of the datasets affects the test results:
Test whether the mean difference vector of two multivariate populations is the zero vector:
Alternatively, test against :
Perform a particular test for equal locations:
Any number of tests can be performed simultaneously:
Perform all tests appropriate to the data simultaneously:
Use the property to identify which tests were used:
Create a HypothesisTestData object for repeated property extraction:
The properties available for extraction:
Extract some properties from a HypothesisTestData:
The -value and test statistic from a -type test:
Extract any number of properties simultaneously:
The -value and test statistic from a Mann-Whitney test:
Tabulate the results from a selection of tests:
A full table of all appropriate test results:
A table of selected test results:
Retrieve the entries from a test table for customized reporting:
The -values are above so there is not enough evidence to reject at that level:
Tabulate -values for a test or group of tests:
The -value from the table:
A table of -values from all appropriate tests:
A table of -values from a subset of tests:
Report the test statistic from a test or group of tests:
The test statistic from the table:
A table of test statistics from all appropriate tests:
A two-sided test is performed by default:
Test versus :
Perform a two-sided test or a one-sided alternative:
Test versus :
Test versus :
Test versus :
Perform tests with one-sided alternatives when is given:
Test versus :
Test versus :
Set the maximum number of iterations to use for multivariate median-based tests:
By default -values are computed using asymptotic test statistic distributions:
For univariate median-based tests -values can be obtained using permutation methods:
Set the number of permutations to use:
By default random permutations are used:
For some tests, the permutation result is exact:
The result is not affected by the number of permutations when exact tests are used:
For mean-based tests, the -value is exact under the assumptions of the test:
Set the seed used for generating random permutations:
Set the significance level for diagnostic tests:
By default, is used:
Setting the significance level may alter which test is automatically chosen:
A median-based test would have been chosen by default:
The significance level is also used for and :
By default normality and equal variance are tested when appropriate:
If assumptions are not checked, some test results may differ:
Diagnostics can be controlled as a group using All or None:
Verify all assumptions:
Check no assumptions:
Diagnostics can be controlled independently:
Assume normality and symmetry but check for equal variances:
Only check for normality:
Unlisted assumptions are not tested:
Normality is assumed:
The result is the same but a warning is issued:
Bypassing diagnostic tests can save compute time:
It is often useful to bypass diagnostic tests for simulation purposes:
The assumptions of the test hold by design, so a great deal of time can be saved:
The results are identical:
Test whether the locations of some populations are equivalent:
The first two populations have similar locations:
The third population differs in location from the first:
The heart and body weights of a group of house cats were obtained:
The heart weight of male cats is significantly greater than that of female cats:
Perhaps male cats are just larger in general:
The ratio of heart weight to body weight is not significantly different between the sexes:
Six measurements were taken for 100 counterfeit Swiss banknotes and 100 genuine ones:
A plot of two of the measures for counterfeit and genuine notes:
A test of the bivariate median vectors shows a significant difference:
Samples were drawn from a pool of water at 10 randomly selected locations. Each sample was tested for zinc concentration at both the surface of the water and the bottom of the pool:
A visual inspection of the data. The distance between the vertical bars shows the quantity being tested under an assumption of dependence and independence respectively:
Assuming the data is paired yields a significant result not present under independence:
Assume a laboratory test showed that zinc concentrations form a gradient that becomes higher with increasing depth. This information justifies the use of a one-sided alternative:
The -value suggests the expected proportion of false positives (Type I errors):
Setting the size of a test to results in an erroneous rejection of about 5% of the time:
Type II errors arise when is not rejected, given it is false:
Increasing the size of the test lowers the Type II error rate:
The power of each test is the probability of rejecting when it is false:
The power of the tests at six different levels. The sign test has the lowest power in general:
The power of tests decreases with smaller sample sizes:
The power of the tests is lower than in the previous example:
For dependent samples, paired tests are more powerful than their non-paired counterparts:
Paired tests assume observations in one dataset are matched with observations in the other:
A paired -test is equivalent to a -test applied to the point-wise differences of two datasets:
Paired tests assume that the data represents differences when given a single dataset:
A two-sided -value is twice the smaller of the two one-sided -values:
Unknown variances and covariances are estimated from the data when using -type tests:
For large samples the estimation has little effect on the results:
With small samples -type tests should be used to account for the estimation:
Median-based tests should be used if the data is not normally distributed:
Median-based tests do not assume normality:
Changing the significance level affects internal diagnostics:
The degrees of freedom are affected by a test for variance:
The -values are not equivalent:
A visual comparison of the discriminating power of some tests across the three alternatives:
New in 8