LocationTest
✖
LocationTest
Details 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 data1 and data2, LocationTest tests null hypothesis
against alternative hypothesis
, where
and
are defined for each test accordingly.
- 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 {x1,x2,…} or multivariate {{x1,y1,…},{x2,y2,…},…}.
- The argument μ0 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 "test".
- 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" normality paired sample test with unknown variance "PairedZ" normality paired sample test with known variance "Sign" robust median test for one sample or matched pairs "SignedRank" symmetry median test for one sample or matched pairs "T" normality mean test for one or two samples "MannWhitney" symmetry median test for two independent samples "Z" normality mean test with known variance - The "T" test performs Student
-test for univariate data and Hotelling's
test for multivariate data.
- The "Z" 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 "PairedT" and "PairedZ" tests perform "T" and "Z" 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 "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 MaxIterations Automatic max iterations for multivariate median tests Method Automatic the method to use for computing -values
SignificanceLevel 0.05 cutoff for diagnostics and reporting VerifyTestAssumptions Automatic what assumptions to verify - For tests of location, a cutoff
is chosen such that
is rejected only if
. The value of
used for the "TestConclusion" and "ShortTestConclusion" 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 0.05.
- Named settings for VerifyTestAssumptions in LocationTest include:
-
"EqualVariance" verify that data1 and data2 have equal variance "Normality" verify that all data is normally distributed "Symmetry" verify symmetry about a common median
Examples
open allclose allBasic Examples (3)Summary of the most common use cases
Test whether the mean or median of a population is zero using a collection of tests:

https://wolfram.com/xid/0h2peojsme-g7mcn

https://wolfram.com/xid/0h2peojsme-m6806n


https://wolfram.com/xid/0h2peojsme-ybn5y

Test whether the means of two populations differ by 2:

https://wolfram.com/xid/0h2peojsme-lq5ldd

https://wolfram.com/xid/0h2peojsme-soqc9


https://wolfram.com/xid/0h2peojsme-bzyk3e

At the 0.05 level, is significantly different from 2:

https://wolfram.com/xid/0h2peojsme-csendg

Compare the locations of multivariate populations:

https://wolfram.com/xid/0h2peojsme-2lnxj

https://wolfram.com/xid/0h2peojsme-nj57pj


https://wolfram.com/xid/0h2peojsme-b0spkt

At the 0.05 level, is not significantly different from {1,2}:

https://wolfram.com/xid/0h2peojsme-j55r4w

Scope (17)Survey of the scope of standard use cases
Testing (13)

https://wolfram.com/xid/0h2peojsme-mk1rwj
The -values are typically large when the mean is close to 0:

https://wolfram.com/xid/0h2peojsme-dcnktx

The -values are typically small when the mean is far from 0:

https://wolfram.com/xid/0h2peojsme-b15esj

Using Automatic is equivalent to testing for a mean of zero:

https://wolfram.com/xid/0h2peojsme-bbn60w

https://wolfram.com/xid/0h2peojsme-cv9w6t


https://wolfram.com/xid/0h2peojsme-nloyf


https://wolfram.com/xid/0h2peojsme-ccr6o1
The -values are typically large when the mean is close to μ0:

https://wolfram.com/xid/0h2peojsme-fk03hb

The -values are typically small when the mean is far from μ0:

https://wolfram.com/xid/0h2peojsme-e810zu

Test whether the mean vector of a multivariate population is the zero vector:

https://wolfram.com/xid/0h2peojsme-bqd543

https://wolfram.com/xid/0h2peojsme-hr2vr

Alternatively, test against {0.1,0,-0.05,0}:

https://wolfram.com/xid/0h2peojsme-cze22

Using Automatic applies the generally most powerful appropriate test:

https://wolfram.com/xid/0h2peojsme-d8h646

https://wolfram.com/xid/0h2peojsme-igjm8j

The property "AutomaticTest" can be used to determine which test was chosen:

https://wolfram.com/xid/0h2peojsme-ciuhxp


https://wolfram.com/xid/0h2peojsme-ekpnsf
The -values are generally small when the locations are not equal:

https://wolfram.com/xid/0h2peojsme-bud71n

The -values are generally large when the locations are equal:

https://wolfram.com/xid/0h2peojsme-nnksx4


https://wolfram.com/xid/0h2peojsme-exhx0q
The order of the datasets affects the test results:

https://wolfram.com/xid/0h2peojsme-f3e5kf


https://wolfram.com/xid/0h2peojsme-jqamzo

Test whether the mean difference vector of two multivariate populations is the zero vector:

https://wolfram.com/xid/0h2peojsme-cbbn53

https://wolfram.com/xid/0h2peojsme-fnaxqn

https://wolfram.com/xid/0h2peojsme-f9ns4d

Alternatively, test against {1,0,-1,0}:

https://wolfram.com/xid/0h2peojsme-hkcfuq

Perform a particular test for equal locations:

https://wolfram.com/xid/0h2peojsme-8xri

https://wolfram.com/xid/0h2peojsme-c5sfpm

Any number of tests can be performed simultaneously:

https://wolfram.com/xid/0h2peojsme-wyttw

Perform all tests appropriate to the data simultaneously:

https://wolfram.com/xid/0h2peojsme-lasd82

https://wolfram.com/xid/0h2peojsme-nu5yl

Use the property "AllTests" to identify which tests were used:

https://wolfram.com/xid/0h2peojsme-gvjord

Create a HypothesisTestData object for repeated property extraction:

https://wolfram.com/xid/0h2peojsme-0x5m5

https://wolfram.com/xid/0h2peojsme-cc8eh1
The properties available for extraction:

https://wolfram.com/xid/0h2peojsme-frvg20

Extract some properties from a HypothesisTestData:

https://wolfram.com/xid/0h2peojsme-c03go

https://wolfram.com/xid/0h2peojsme-bpn9dr
The -value and test statistic from a
-type test:

https://wolfram.com/xid/0h2peojsme-365dq


https://wolfram.com/xid/0h2peojsme-bn5rjv

Extract any number of properties simultaneously:

https://wolfram.com/xid/0h2peojsme-bycagv

https://wolfram.com/xid/0h2peojsme-dmu6hk
The -value and test statistic from a Mann–Whitney test:

https://wolfram.com/xid/0h2peojsme-i6fwj7

Reporting (4)
Tabulate the results from a selection of tests:

https://wolfram.com/xid/0h2peojsme-ba6zb1

https://wolfram.com/xid/0h2peojsme-hb1mu5
A full table of all appropriate test results:

https://wolfram.com/xid/0h2peojsme-c83kyd

A table of selected test results:

https://wolfram.com/xid/0h2peojsme-gxraq6

Retrieve the entries from a test table for customized reporting:

https://wolfram.com/xid/0h2peojsme-cg07e5

https://wolfram.com/xid/0h2peojsme-98x7a

https://wolfram.com/xid/0h2peojsme-fq0ubv

https://wolfram.com/xid/0h2peojsme-72dsk

The -values are above 0.05, so there is not enough evidence to reject
at that level:

https://wolfram.com/xid/0h2peojsme-evyuso

Tabulate -values for a test or group of tests:

https://wolfram.com/xid/0h2peojsme-fr3ezf

https://wolfram.com/xid/0h2peojsme-blo8x

https://wolfram.com/xid/0h2peojsme-g8i1dt


https://wolfram.com/xid/0h2peojsme-o0wuj

A table of -values from all appropriate tests:

https://wolfram.com/xid/0h2peojsme-d225dd

A table of -values from a subset of tests:

https://wolfram.com/xid/0h2peojsme-zutii

Report the test statistic from a test or group of tests:

https://wolfram.com/xid/0h2peojsme-dv0ouz

https://wolfram.com/xid/0h2peojsme-bsvl57

https://wolfram.com/xid/0h2peojsme-kx4361

The test statistic from the table:

https://wolfram.com/xid/0h2peojsme-bitsqd

A table of test statistics from all appropriate tests:

https://wolfram.com/xid/0h2peojsme-dw7vzl

Options (20)Common values & functionality for each option
AlternativeHypothesis (3)
A two-sided test is performed by default:

https://wolfram.com/xid/0h2peojsme-bgoxnx

https://wolfram.com/xid/0h2peojsme-he0w0s


https://wolfram.com/xid/0h2peojsme-jqt2u8

Perform a two-sided test or a one-sided alternative:

https://wolfram.com/xid/0h2peojsme-kwmm8d

https://wolfram.com/xid/0h2peojsme-dy0fuc


https://wolfram.com/xid/0h2peojsme-g8h639


https://wolfram.com/xid/0h2peojsme-f19ykz

Perform tests with one-sided alternatives when μ0 is given:

https://wolfram.com/xid/0h2peojsme-cay5xk

https://wolfram.com/xid/0h2peojsme-v01gr


https://wolfram.com/xid/0h2peojsme-ci67wa


https://wolfram.com/xid/0h2peojsme-m3sbc

MaxIterations (1)
Set the maximum number of iterations to use for multivariate median-based tests:

https://wolfram.com/xid/0h2peojsme-wsdxy

https://wolfram.com/xid/0h2peojsme-ctnr2c


https://wolfram.com/xid/0h2peojsme-etcz4z


https://wolfram.com/xid/0h2peojsme-l6esri

Method (6)
By default, -values are computed using asymptotic test statistic distributions:

https://wolfram.com/xid/0h2peojsme-v21sy

https://wolfram.com/xid/0h2peojsme-fifdab


https://wolfram.com/xid/0h2peojsme-b9g9ag

For univariate median-based tests, -values can be obtained using permutation methods:

https://wolfram.com/xid/0h2peojsme-hy6ohx

https://wolfram.com/xid/0h2peojsme-f69ts


https://wolfram.com/xid/0h2peojsme-drrw70

Set the number of permutations to use:

https://wolfram.com/xid/0h2peojsme-cv172p

https://wolfram.com/xid/0h2peojsme-co5msl


https://wolfram.com/xid/0h2peojsme-dicab0

By default, random permutations are used:

https://wolfram.com/xid/0h2peojsme-ktxmmb

For some tests, the permutation result is exact:

https://wolfram.com/xid/0h2peojsme-eogwew

https://wolfram.com/xid/0h2peojsme-0bkpt

The result is not affected by the number of permutations when exact tests are used:

https://wolfram.com/xid/0h2peojsme-b31jc0

For mean-based tests, the -value is exact under the assumptions of the test:

https://wolfram.com/xid/0h2peojsme-kz4t8i

https://wolfram.com/xid/0h2peojsme-erowd0


https://wolfram.com/xid/0h2peojsme-zi1fm

Set the seed used for generating random permutations:

https://wolfram.com/xid/0h2peojsme-cjrea

https://wolfram.com/xid/0h2peojsme-0du0


https://wolfram.com/xid/0h2peojsme-f7dru0

SignificanceLevel (3)
Set the significance level for diagnostic tests:

https://wolfram.com/xid/0h2peojsme-fn2ahc

https://wolfram.com/xid/0h2peojsme-dwfi1


https://wolfram.com/xid/0h2peojsme-cod4ca


Setting the significance level may alter which test is automatically chosen:

https://wolfram.com/xid/0h2peojsme-tvs8p

https://wolfram.com/xid/0h2peojsme-gbpe5z

A median-based test would have been chosen by default:

https://wolfram.com/xid/0h2peojsme-d5nssu

The significance level is also used for "TestConclusion" and "ShortTestConclusion":

https://wolfram.com/xid/0h2peojsme-bhkod7

https://wolfram.com/xid/0h2peojsme-lasldz

https://wolfram.com/xid/0h2peojsme-hykroc

https://wolfram.com/xid/0h2peojsme-bvt7nt


https://wolfram.com/xid/0h2peojsme-hpqqgh


https://wolfram.com/xid/0h2peojsme-flavjg


https://wolfram.com/xid/0h2peojsme-m2oyg2

VerifyTestAssumptions (7)
By default, normality and equal variance are tested when appropriate:

https://wolfram.com/xid/0h2peojsme-hkuna

https://wolfram.com/xid/0h2peojsme-b9i03c

If assumptions are not checked, some test results may differ:

https://wolfram.com/xid/0h2peojsme-bxfl8e

Diagnostics can be controlled as a group using All or None:

https://wolfram.com/xid/0h2peojsme-ma0mld

https://wolfram.com/xid/0h2peojsme-bg3dnp


https://wolfram.com/xid/0h2peojsme-foxivl

Diagnostics can be controlled independently:

https://wolfram.com/xid/0h2peojsme-btjvx7
Assume normality and symmetry but check for equal variances:

https://wolfram.com/xid/0h2peojsme-e6eshh


https://wolfram.com/xid/0h2peojsme-djybum

Unlisted assumptions are not tested:

https://wolfram.com/xid/0h2peojsme-db7e1z

https://wolfram.com/xid/0h2peojsme-dnfybp

The result is the same but a warning is issued:

https://wolfram.com/xid/0h2peojsme-fx7k7n


Test assumption values can be explicitly set:

https://wolfram.com/xid/0h2peojsme-fsso4k

https://wolfram.com/xid/0h2peojsme-blew9l


https://wolfram.com/xid/0h2peojsme-hh8mmo

The sign test was previously chosen because the data is not normally distributed:

https://wolfram.com/xid/0h2peojsme-gp604


Bypassing diagnostic tests can save compute time:

https://wolfram.com/xid/0h2peojsme-hrliot

https://wolfram.com/xid/0h2peojsme-mmqfh1


https://wolfram.com/xid/0h2peojsme-bglfb1

It is often useful to bypass diagnostic tests for simulation purposes:

https://wolfram.com/xid/0h2peojsme-kfpeh6

https://wolfram.com/xid/0h2peojsme-cxjgtt

The assumptions of the test hold by design, so a great deal of time can be saved:

https://wolfram.com/xid/0h2peojsme-cmfh98


https://wolfram.com/xid/0h2peojsme-btr43n

Applications (4)Sample problems that can be solved with this function
Test whether the locations of some populations are equivalent:

https://wolfram.com/xid/0h2peojsme-g2oo7p

https://wolfram.com/xid/0h2peojsme-bxofsv

The first two populations have similar locations:

https://wolfram.com/xid/0h2peojsme-pnos0u

The third population differs in location from the first:

https://wolfram.com/xid/0h2peojsme-djej1g

The heart and body weights of a group of house cats were obtained:

https://wolfram.com/xid/0h2peojsme-eedprd


https://wolfram.com/xid/0h2peojsme-45kfn
The heart weight of male cats is significantly greater than that of female cats:

https://wolfram.com/xid/0h2peojsme-lkkzna

Perhaps male cats are just larger in general:

https://wolfram.com/xid/0h2peojsme-4bpz1m

https://wolfram.com/xid/0h2peojsme-vp63s

The ratio of heart weight to body weight is not significantly different between the sexes:

https://wolfram.com/xid/0h2peojsme-lnyn7m

Six measurements were taken for 100 counterfeit Swiss banknotes and 100 genuine ones:

https://wolfram.com/xid/0h2peojsme-ijoy4a

https://wolfram.com/xid/0h2peojsme-segutj


https://wolfram.com/xid/0h2peojsme-oc4hh3
A plot of two of the measures for counterfeit and genuine notes:

https://wolfram.com/xid/0h2peojsme-ho092

A test of the bivariate median vectors shows a significant difference:

https://wolfram.com/xid/0h2peojsme-bws17i

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:

https://wolfram.com/xid/0h2peojsme-fslghe
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:

https://wolfram.com/xid/0h2peojsme-dd2zx4

https://wolfram.com/xid/0h2peojsme-gutvjo

Assuming the data is paired yields a significant result not present under independence:

https://wolfram.com/xid/0h2peojsme-cr7o6t


https://wolfram.com/xid/0h2peojsme-k5uh4q

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:

https://wolfram.com/xid/0h2peojsme-ff5ndi

Properties & Relations (9)Properties of the function, and connections to other functions
The -value suggests the expected proportion of false positives (Type I errors):

https://wolfram.com/xid/0h2peojsme-cvq37s

https://wolfram.com/xid/0h2peojsme-eba6zi
Setting the size of a test to 0.05 results in an erroneous rejection of about 5% of the time:

https://wolfram.com/xid/0h2peojsme-jqst60

Type II errors arise when is not rejected, given it is false:

https://wolfram.com/xid/0h2peojsme-sh4w3

https://wolfram.com/xid/0h2peojsme-ecyhwp
Increasing the size of the test lowers the Type II error rate:

https://wolfram.com/xid/0h2peojsme-bohuev

The power of each test is the probability of rejecting when it is false:

https://wolfram.com/xid/0h2peojsme-k88dus

https://wolfram.com/xid/0h2peojsme-g21kys

https://wolfram.com/xid/0h2peojsme-bpwa86

https://wolfram.com/xid/0h2peojsme-bw2785
The power of the tests at six different levels. The sign test has the lowest power in general:

https://wolfram.com/xid/0h2peojsme-hytehd

The power of tests decreases with smaller sample sizes:

https://wolfram.com/xid/0h2peojsme-buwzit

https://wolfram.com/xid/0h2peojsme-jgwmwy

https://wolfram.com/xid/0h2peojsme-jkexjg

https://wolfram.com/xid/0h2peojsme-mqdbra
The power of the tests is lower than in the previous example:

https://wolfram.com/xid/0h2peojsme-jigktp

For dependent samples, paired tests are more powerful than their non-paired counterparts:

https://wolfram.com/xid/0h2peojsme-j66v8i

https://wolfram.com/xid/0h2peojsme-cmva9i

https://wolfram.com/xid/0h2peojsme-bv63ul
Paired tests assume observations in one dataset are matched with observations in the other:

https://wolfram.com/xid/0h2peojsme-jy2qxj

A paired -test is equivalent to a
-test applied to the point-wise differences of two datasets:

https://wolfram.com/xid/0h2peojsme-kivqv

https://wolfram.com/xid/0h2peojsme-f29icn


https://wolfram.com/xid/0h2peojsme-b2ac3h

Paired tests assume that the data represents differences when given a single dataset:

https://wolfram.com/xid/0h2peojsme-l7hhm

A two-sided -value is twice the smaller of the two one-sided
-values:

https://wolfram.com/xid/0h2peojsme-cflass

https://wolfram.com/xid/0h2peojsme-35omm

https://wolfram.com/xid/0h2peojsme-i79bry

https://wolfram.com/xid/0h2peojsme-i02mm7

The LocationTest works with the values only when the input is a TimeSeries:

https://wolfram.com/xid/0h2peojsme-7py5sj

https://wolfram.com/xid/0h2peojsme-57bf57


https://wolfram.com/xid/0h2peojsme-vvd88


https://wolfram.com/xid/0h2peojsme-x80czr

LocationTest works with all the values together when the input is a TemporalData:

https://wolfram.com/xid/0h2peojsme-qry3ls

https://wolfram.com/xid/0h2peojsme-b1l4g0


https://wolfram.com/xid/0h2peojsme-t6toez

Test whether the means or medians of the two paths are equal:

https://wolfram.com/xid/0h2peojsme-kxzwhd

https://wolfram.com/xid/0h2peojsme-jdvl55

Possible Issues (3)Common pitfalls and unexpected behavior
Unknown variances and covariances are estimated from the data when using -type tests:

https://wolfram.com/xid/0h2peojsme-jngkk
For large samples, the estimation has little effect on the results:

https://wolfram.com/xid/0h2peojsme-cx2ni8

With small samples, -type tests should be used to account for the estimation:

https://wolfram.com/xid/0h2peojsme-xouu7

Median-based tests should be used if the data is not normally distributed:

https://wolfram.com/xid/0h2peojsme-ehpt5

https://wolfram.com/xid/0h2peojsme-hquemc


Median-based tests do not assume normality:

https://wolfram.com/xid/0h2peojsme-di0edh

Changing the significance level affects internal diagnostics:

https://wolfram.com/xid/0h2peojsme-85atl

https://wolfram.com/xid/0h2peojsme-bt9cpf
The degrees of freedom are affected by a test for variance:

https://wolfram.com/xid/0h2peojsme-i8h4ql


https://wolfram.com/xid/0h2peojsme-58mu8


https://wolfram.com/xid/0h2peojsme-83nv9

The -values are not equivalent:

https://wolfram.com/xid/0h2peojsme-c9gyq

Neat Examples (2)Surprising or curious use cases
A visual comparison of the discriminating power of some tests across the three alternatives:

https://wolfram.com/xid/0h2peojsme-dztkv1

https://wolfram.com/xid/0h2peojsme-hmvfj3

https://wolfram.com/xid/0h2peojsme-ck91ax

https://wolfram.com/xid/0h2peojsme-gsnsy4

https://wolfram.com/xid/0h2peojsme-lvnqhf

Compute the statistic when the null hypothesis is true:

https://wolfram.com/xid/0h2peojsme-2qqg3c

https://wolfram.com/xid/0h2peojsme-ywy3ty
The test statistic given a particular alternative:

https://wolfram.com/xid/0h2peojsme-c5cy2n
Compare the distributions of the test statistics:

https://wolfram.com/xid/0h2peojsme-87eb6q

Wolfram Research (2010), LocationTest, Wolfram Language function, https://reference.wolfram.com/language/ref/LocationTest.html.
Text
Wolfram Research (2010), LocationTest, Wolfram Language function, https://reference.wolfram.com/language/ref/LocationTest.html.
Wolfram Research (2010), LocationTest, Wolfram Language function, https://reference.wolfram.com/language/ref/LocationTest.html.
CMS
Wolfram Language. 2010. "LocationTest." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/LocationTest.html.
Wolfram Language. 2010. "LocationTest." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/LocationTest.html.
APA
Wolfram Language. (2010). LocationTest. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/LocationTest.html
Wolfram Language. (2010). LocationTest. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/LocationTest.html
BibTeX
@misc{reference.wolfram_2025_locationtest, author="Wolfram Research", title="{LocationTest}", year="2010", howpublished="\url{https://reference.wolfram.com/language/ref/LocationTest.html}", note=[Accessed: 30-April-2025
]}
BibLaTeX
@online{reference.wolfram_2025_locationtest, organization={Wolfram Research}, title={LocationTest}, year={2010}, url={https://reference.wolfram.com/language/ref/LocationTest.html}, note=[Accessed: 30-April-2025
]}