({{, (RefLink[VarianceEquivalenceTest, paclet:ref/VarianceEquivalenceTest])[{(Subscript[data, 1]),(Subscript[data, 2]),…}] 
tests whether the variances of the (Subscript[data, i]) are equal. }, {, (RefLink[VarianceEquivalenceTest, paclet:ref/VarianceEquivalenceTest])[{(Subscript[data, 1]),…},"property"]
returns the value of "property".}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[VarianceEquivalenceTest, paclet:ref/VarianceEquivalenceTest]) performs a hypothesis test on the (Subscript[data, i]) with null hypothesis (Subscript[H, 0]) that the true population variances are identical to (Subscript[σ, 1]^2)=(Subscript[σ, 2]^2)=⋯, and alternative hypothesis (Subscript[H, a]) that at least one is different.

By default, a probability value or p-value is returned.

A small p-value suggests that it is unlikely that (Subscript[σ, 1]^2)=(Subscript[σ, 2]^2)=⋯.

The (Subscript[data, i]) must be univariate {(Subscript[x, 1]),(Subscript[x, 2]),…}.

(RefLink[VarianceEquivalenceTest, paclet:ref/VarianceEquivalenceTest])[{(Subscript[data, 1]),…}] will choose the most powerful test that applies to the data.

(RefLink[VarianceEquivalenceTest, paclet:ref/VarianceEquivalenceTest])[{(Subscript[data, 1]),…},(RefLink[All, paclet:ref/All])] will choose all tests that apply to the data.

(RefLink[VarianceEquivalenceTest, paclet:ref/VarianceEquivalenceTest])[{(Subscript[data, 1]),…},"test"] reports the p-value according to "test".

Most tests require normally distributed (Subscript[data, i]). If a test is less sensitive to a normality assumption, it is called robust. Some tests assume that (Subscript[data, i]) is symmetric around its medians.

The following tests can be used:

(RefLink[VarianceEquivalenceTest, paclet:ref/VarianceEquivalenceTest])[{(Subscript[data, 1]),…},"HypothesisTestData"] returns a (RefLink[HypothesisTestData, paclet:ref/HypothesisTestData]) object htd that can be used to extract additional test results and properties using the form htd["property"].

(RefLink[VarianceEquivalenceTest, paclet:ref/VarianceEquivalenceTest])[{(Subscript[data, 1]),…},"property"] can be used to directly give the value of "property".

Properties related to the reporting of test results include:

The following options can be given:

For tests of variance, a cutoff α is chosen such that (Subscript[H, 0]) is rejected only if p<α. The value of α used for the "TestConclusion" and "ShortTestConclusion" properties is controlled by the (RefLink[SignificanceLevel, paclet:ref/SignificanceLevel]) option. This value α is also used in diagnostic tests of assumptions, including tests for normality and symmetry. By default, α is set to 0.05.

Named settings for (RefLink[VerifyTestAssumptions, paclet:ref/VerifyTestAssumptions]) in (RefLink[VarianceEquivalenceTest, paclet:ref/VarianceEquivalenceTest]) include:

OpenersPrimaryExamplesSection(Spacer1)Examples  (30)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Test variances from two datasets for equivalence:

data=RandomVariate[NormalDistribution[],{2,(10^4)}];

htd=VarianceEquivalenceTest[data]

Create a (RefLink[HypothesisTestData, paclet:ref/HypothesisTestData]) object for further property extraction:

ℋ=VarianceEquivalenceTest[data,"HypothesisTestData"]

The full test table:

ℋ["TestDataTable",All]

Compare the variances of multiple datasets simultaneously:

data1=RandomVariate[NormalDistribution[1,1],(10^3)];
data2=RandomVariate[NormalDistribution[15,1],(10^3)];
data3=RandomVariate[GammaDistribution[4,1/2],(10^3)];

VarianceEquivalenceTest[{data1,data2,data3}]

The variances of the datasets:

Variance/@{data1,data2,data3}

OpenersExampleSection1(Spacer1)Scope  (12)

OpenersExampleSubsection0(Spacer1)Testing  (8)

Compare the variances of two datasets:

data1=RandomVariate[NormalDistribution[],500];
data2=RandomVariate[StudentTDistribution[5],500];
data3=RandomVariate[NormalDistribution[],350];

The p-values are typically large when the variances are equal:

VarianceEquivalenceTest[{data1,data3}]

The p-values are typically small when the variances are not equal:

VarianceEquivalenceTest[{data1,data2}]

Using (RefLink[Automatic, paclet:ref/Automatic]) applies the generally most powerful appropriate test:

data=RandomVariate[NormalDistribution[],{3,(10^4)}];

VarianceEquivalenceTest[data,Automatic]

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

VarianceEquivalenceTest[data,"AutomaticTest"]

Compare the variances of many datasets simultaneously:

data=RandomVariate[WeibullDistribution[1,2],{3,(10^2)}];

VarianceEquivalenceTest[data]

Compare the distributions of the datasets visually using (RefLink[SmoothHistogram, paclet:ref/SmoothHistogram]):

SmoothHistogram[data]

Perform a particular test for equal variance:

data=RandomVariate[NormalDistribution[],{3,(10^3)}];

VarianceEquivalenceTest[data,"Bartlett"]

Any number of tests can be performed simultaneously:

VarianceEquivalenceTest[data,{"PValue",{"Levene","Bartlett"}}]

Perform all tests, appropriate to the data, simultaneously:

data=RandomVariate[NormalDistribution[],{2,250}];

VarianceEquivalenceTest[data,All]

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

VarianceEquivalenceTest[data,"AllTests"]

Create a (RefLink[HypothesisTestData, paclet:ref/HypothesisTestData]) object for repeated property extraction:

data=RandomVariate[NormalDistribution[],{3,(10^4)}];

ℋ=VarianceEquivalenceTest[data,"HypothesisTestData"];

The properties available for extraction:

ℋ["Properties"]

Extract some properties from a (RefLink[HypothesisTestData, paclet:ref/HypothesisTestData]) object:

data=RandomVariate[NormalDistribution[],{3,(10^4)}];

ℋ=VarianceEquivalenceTest[data,"HypothesisTestData"];

The p-value and test statistic from a Levene test:

ℋ["PValue","Levene"]

ℋ["TestStatistic","Levene"]

Extract any number of properties simultaneously:

data=RandomVariate[NormalDistribution[],{4,100}];

ℋ=VarianceEquivalenceTest[data,"HypothesisTestData"];

The p-value and test statistic from a Brown–Forsythe test:

ℋ[{"PValue","BrownForsythe"},{"TestStatistic","BrownForsythe"}]

OpenersExampleSubsection1(Spacer1)Reporting  (4)

Tabulate the results from a selection of tests:

data=RandomVariate[NormalDistribution[],{2,(10^3)}];

ℋ=VarianceEquivalenceTest[data,"HypothesisTestData"];

ℋ["TestDataTable"]

A full table of all appropriate test results:

ℋ["TestDataTable",All]

A table of selected test results:

ℋ["TestDataTable",{"Bartlett","BrownForsythe"}]

Retrieve the entries from a test table for customized reporting:

data=BlockRandom[SeedRandom[1];RandomVariate[NormalDistribution[],{2,(10^3)}]];

ℋ=VarianceEquivalenceTest[data,"HypothesisTestData"];

res=ℋ["TestData",All];

ℋ["AllTests"]

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

Show[BarChart[res[[All,2]],ChartLabels->Placed[ℋ["AllTests"],Center],BarOrigin->Left],Graphics[{Dashed,InfiniteLine[{{.05,0},{.05,1}}]}]]

Tabulate p-values for a test or group of tests:

data=RandomVariate[NormalDistribution[],{2,(10^4)}];

ℋ=VarianceEquivalenceTest[data,"HypothesisTestData"];

ℋ["PValueTable","Levene"]

The p-value from the table:

ℋ["PValue","Levene"]

A table of p-values from all appropriate tests:

ℋ["PValueTable",All]

A table of p-values from a subset of tests:

ℋ["PValueTable",{"Levene","Bartlett","BrownForsythe"}]

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

data=RandomVariate[CauchyDistribution[1,2],{3,(10^3)}];

ℋ=VarianceEquivalenceTest[data,"HypothesisTestData"];

ℋ["TestStatisticTable"]

The test statistic from the table:

ℋ["TestStatistic"]

A table of test statistics from all appropriate tests:

ℋ["TestStatisticTable",All]

OpenersExampleSection2(Spacer1)Options  (6)

OpenersExampleSubsection2(Spacer1)SignificanceLevel  (3)

Set the significance level for diagnostic tests:

data=BlockRandom[SeedRandom[1];RandomVariate[StudentTDistribution[3],{2,50}]];

VarianceEquivalenceTest[data,"FisherRatio",SignificanceLevel->.005]

The default level is 0.05:

VarianceEquivalenceTest[data,"FisherRatio",SignificanceLevel->Automatic]

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

data=BlockRandom[SeedRandom[1];RandomVariate[StudentTDistribution[3],{3,50}]];

VarianceEquivalenceTest[data,"AutomaticTest",SignificanceLevel->.005]

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

VarianceEquivalenceTest[data,"AutomaticTest",SignificanceLevel->Automatic]

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

data=BlockRandom[SeedRandom[10];RandomVariate[NormalDistribution[0,1],{3,100}]];

ℋ1=VarianceEquivalenceTest[data,"HypothesisTestData",SignificanceLevel->.05];

ℋ2=VarianceEquivalenceTest[data,"HypothesisTestData",SignificanceLevel->.01];

ℋ1["TestConclusion"]//TraditionalForm

ℋ2["TestConclusion"]//TraditionalForm

ℋ1["ShortTestConclusion"]

ℋ2["ShortTestConclusion"]

OpenersExampleSubsection3(Spacer1)VerifyTestAssumptions  (3)

Diagnostics can be controlled as a group using (RefLink[All, paclet:ref/All]) or (RefLink[None, paclet:ref/None]):

data=RandomVariate[StudentTDistribution[3],{4,1000}];

Verify all assumptions:

VarianceEquivalenceTest[data,"Bartlett",VerifyTestAssumptions->All]

Check no assumptions:

VarianceEquivalenceTest[data,"Bartlett",VerifyTestAssumptions->None]

Diagnostics can be controlled independently:

data=RandomVariate[StudentTDistribution[3],{4,1000}];

Assume normality but check for symmetry:

VarianceEquivalenceTest[data,"Bartlett",VerifyTestAssumptions->"Symmetry"]

Only check for normality:

VarianceEquivalenceTest[data,"Bartlett",VerifyTestAssumptions->"Normality"]

Test assumption values can be explicitly set:

data=RandomVariate[CauchyDistribution[0,1],{3,100}];

VarianceEquivalenceTest[data,"TestDataTable"]

VarianceEquivalenceTest[data,"TestDataTable",VerifyTestAssumptions->"Normality"->True]

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

VarianceEquivalenceTest[data,{"TestDataTable","Levene"}]

OpenersExampleSection3(Spacer1)Applications  (2)

Test whether a group of populations shares a common variance:

data1=Table[RandomVariate[NormalDistribution[0,σ],100],{σ,RandomReal[{.5,10},8]}];

data2=Table[RandomVariate[NormalDistribution[0,σ],100],{σ,RandomReal[{.95,1.05},8]}];

{BoxWhiskerChart[data1],BoxWhiskerChart[data2]}

The first group of datasets was drawn from populations with very different variances:

VarianceEquivalenceTest[data1,"TestDataTable"]

Populations represented by the second group all have similar variances:

VarianceEquivalenceTest[data2,"TestDataTable"]

(RefLink[LocationEquivalenceTest, paclet:ref/LocationEquivalenceTest]) can be used to compare the means of several datasets simultaneously but requires that the datasets have common variance:

BlockRandom[SeedRandom[1];
data1=RandomVariate[NormalDistribution[1,1],100];
data2=RandomVariate[NormalDistribution[1.5,1],100];
data3=RandomVariate[NormalDistribution[.25,1],100];
]

SmoothHistogram[{data1,data2,data3}]

Use (RefLink[VarianceEquivalenceTest, paclet:ref/VarianceEquivalenceTest]) to determine if the variances are equivalent:

VarianceEquivalenceTest[{data1,data2,data3},"TestDataTable"]

(RefLink[LocationEquivalenceTest, paclet:ref/LocationEquivalenceTest]) can be used to compare the means:

LocationEquivalenceTest[{data1,data2,data3},"TestDataTable"]

OpenersExampleSection4(Spacer1)Properties & Relations  (5)

The Brown–Forsythe and Levene tests are equivalent but use different standardizing functions:

data=RandomVariate[NormalDistribution[],{3,100}];

BFL[data_,f_]:=Block[{n=Length/@data,k=Length[data],nt,μZ,z,μZZ},
nt=Total[n];
z=Abs@Table[Standardize[i,f,1&],{i,data}];
μZ=Mean/@z;
μZZ=(n/nt).μZ;
(((nt-k))/(k-1))((n.(((μZ-μZZ))^2))/(Total[(((z-μZ))^2),Infinity]))]

The Levene test uses (RefLink[Mean, paclet:ref/Mean]) to standardize the data:

BFL[data,Mean]

VarianceEquivalenceTest[data,{"TestStatistic","Levene"}]

The Brown–Forsythe test typically uses (RefLink[Median, paclet:ref/Median]):

BFL[data,Median]

VarianceEquivalenceTest[data,{"TestStatistic","BrownForsythe"}]

For heavy-tailed data, the 10% (RefLink[TrimmedMean, paclet:ref/TrimmedMean]) is used instead:

data2=RandomVariate[CauchyDistribution[0,1],{3,100}];

BFL[data2,TrimmedMean[#,.1]&]

VarianceEquivalenceTest[data2,{"TestStatistic","BrownForsythe"},VerifyTestAssumptions->None]

For k datasets and n total observations, the Brown–Forsythe and Levene test statistics both follow (RefLink[FRatioDistribution, paclet:ref/FRatioDistribution])[k-1,n-k] under (Subscript[H, 0]):

data=RandomVariate[NormalDistribution[],{1000,3,100}];

{bf,lv}=Transpose[(VarianceEquivalenceTest[#,{"TestStatistic",{"BrownForsythe","Levene"}},VerifyTestAssumptions->None]&/@data)];

df=VarianceEquivalenceTest[data[[1]],{"DegreesOfFreedom","Levene"}]

Show[Plot[PDF[FRatioDistribution@@df,x],{x,0,5},PlotRange->All],Histogram[{bf,lv},Automatic,"PDF"]]

DistributionFitTest[bf,FRatioDistribution[df[[1]],df[[2]]]]

DistributionFitTest[lv,FRatioDistribution[df[[1]],df[[2]]]]

Bartlett's test statistic:

k=4;

data=RandomVariate[NormalDistribution[],{k,1000}];

bart[dataSets_]:=Block[{n=Length/@dataSets,nt,v=Variance/@dataSets,k=Length[dataSets],Sp},
nt=Total[n];
n=n-1;
Sp=Log[((n.v)/(nt-k))];
(( (k-nt) Sp+n.Log[v])/((1/(3-3 k))(Total[(1/n)]-(1/(nt-k)))-1))]

bart[data]

VarianceEquivalenceTest[data,{"TestStatistic","Bartlett"},VerifyTestAssumptions->None]

Under (Subscript[H, 0]), the test statistic follows (RefLink[ChiSquareDistribution, paclet:ref/ChiSquareDistribution])[k-1]:

data2=RandomVariate[NormalDistribution[],{10000,k,100}];

bTest=bart/@data2;

Show[Plot[PDF[𝒟=ChiSquareDistribution[k-1],x],{x,0,15},PlotRange->All],SmoothHistogram[bTest,PlotStyle->Orange]]

DistributionFitTest[bTest,𝒟]

The variance equivalence test ignores the time stamps when the input is a (RefLink[TimeSeries, paclet:ref/TimeSeries]):

ts1=TimeSeries[];

ts2=TimeSeries[];

VarianceEquivalenceTest[{ts1,ts2}]

VarianceEquivalenceTest[{ts1["Values"],ts2["Values"]}]

The variance equivalence test recognizes the path structure of a (RefLink[TemporalData, paclet:ref/TemporalData]):

td=TemporalData[];

VarianceEquivalenceTest[td]

Use the values directly:

VarianceEquivalenceTest[td["ValueList"]]

OpenersExampleSection5(Spacer1)Possible Issues  (2)

The Fisher ratio test requires two datasets:

data=RandomVariate[NormalDistribution[],{3,100}];

VarianceEquivalenceTest[data,{"TestDataTable","FisherRatio"}]

Use any of the other tests instead:

VarianceEquivalenceTest[data,{"TestDataTable",{"Conover","Bartlett","Levene","BrownForsythe"}}]

Conover's test is the only test that does not assume the data is normally distributed:

data=RandomVariate[LaplaceDistribution[1,2],{2,100}];

VarianceEquivalenceTest[data,{"TestDataTable",{"FisherRatio","Bartlett","Levene","BrownForsythe"}}]

VarianceEquivalenceTest[data,{"TestDataTable","Conover"}]

OpenersExampleSection6(Spacer1)Neat Examples  (1)

Compute the statistic when the null hypothesis (Subscript[H, 0]) is true:

data1=RandomVariate[NormalDistribution[],{1500,100}];
data2=RandomVariate[NormalDistribution[1,1],{1500,100}];

T1=MapThread[VarianceEquivalenceTest[{#1,#2},"TestStatistic"]&,{data1,data2}];

The test statistic given a particular alternative:

data3=RandomVariate[NormalDistribution[0,.75],{1500,100}];

T2=MapThread[VarianceEquivalenceTest[{#1,#2},"TestStatistic"]&,{data1,data3}];

Compare the distributions of the test statistics:

SmoothHistogram[{T1,T2},Filling->Axis,PlotLegends->{"(Subscript[H, 0]) is True","(Subscript[H, 0]) is False"},PlotRange->All]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[HypothesisTestData, paclet:ref/HypothesisTestData])  ▪  (RefLink[LocationTest, paclet:ref/LocationTest])  ▪  (RefLink[LocationEquivalenceTest, paclet:ref/LocationEquivalenceTest])  ▪  (RefLink[VarianceTest, paclet:ref/VarianceTest])  ▪  (RefLink[DistributionFitTest, paclet:ref/DistributionFitTest])  ▪  (RefLink[IndependenceTest, paclet:ref/IndependenceTest])  ▪  (RefLink[LogRankTest, paclet:ref/LogRankTest])  ▪  (RefLink[FisherRatioTest, paclet:ref/FisherRatioTest])  ▪  (RefLink[LeveneTest, paclet:ref/LeveneTest])  ▪  (RefLink[BrownForsytheTest, paclet:ref/BrownForsytheTest])  ▪  (RefLink[ConoverTest, paclet:ref/ConoverTest])  ▪  (RefLink[SiegelTukeyTest, paclet:ref/SiegelTukeyTest])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Hypothesis Tests, paclet:guide/HypothesisTests])}})}})