主要内容

vartest2

Two-sampleF- 相等差异的测试

描述

h= vartest2(x,y)返回对向量中数据的零假设的测试决定xy来自具有相同差异的正常分布,使用两个样本F-test. The alternative hypothesis is that they come from normal distributions with different variances. The resulth1if the test rejects the null hypothesis at the 5% significance level, and0otherwise.

example

h= vartest2(x,y,Name,Value)返回两个样本的测试决定F- 通过一个或多个名称值对参数指定的其他选项。例如,您可以更改显着性水平或进行单方面测试。

example

[h,p] = vartest2(___)还返回p-value of the test,p,使用上一个语法中的任何输入参数。

[h,p,ci,stats] = vartest2(___)还返回真实差异比率的置信区间,ci, and the structurestats包含有关测试统计量的信息。

例子

全部收缩

加载样本数据。创建包含数据矩阵的第一和第二列的向量,以表示学生和两次考试的成绩。

load考试; x = grades(:,1); y = grades(:,2);

Test the null hypothesis that the data inxycomes from distributions with the same variance.

[h,p,ci,stats] = vartest2(x,y)
h = 1
p = 0.0019
CI =2×11.2383 2.5494
stats =带有字段的结构:fstat: 1.7768 df1: 119 df2: 119

The returned resulth = 1表示这vartest2rejects the null hypothesis at the default 5% significance level.ci包含真正方差比的95%置信区间的下限和上限。statscontains the value of the test statistic for the F -test and the numerator and denominator degrees of freedom.

加载样本数据。创建包含数据矩阵的第一和第二列的向量,以代表两次考试的学生成绩。

load考试; x = grades(:,1); y = grades(:,2);

Test the null hypothesis that the data inxycomes from distributions with the same variance, against the alternative that the population variance ofx大于y.

vartest2(x,y,'Tail','正确的')
ans = 1

The returned resulth = 1表示这vartest2拒绝默认值为5%的显着性水平的无效假设,而有利于另一种假设,即种群差异x大于y.

Input Arguments

全部收缩

示例数据,指定为矢量,矩阵或多维阵列.

  • 如果xy是向量,它们不需要相同的长度。

  • 如果xyare matrices, they must have the same number of columns, but do not need to have the same number of rows.vartest2performs separate tests along each column and returns a vector of the results.

  • 如果xyare multidimensional arrays, they must have the same number of dimensions, and the same size along all but the第一个nonsingleton维度.

Data Types:single|双倍的

示例数据,指定为矢量,矩阵或多维阵列.

  • 如果xy是向量,它们不需要相同的长度。

  • 如果xyare matrices, they must have the same number of columns, but do not need to have the same number of rows.vartest2performs separate tests along each column and returns a vector of the results.

  • 如果xyare multidimensional arrays, they must have the same number of dimensions, and the same size along all but the第一个nonsingleton维度.

Data Types:single|双倍的

Name-Value Arguments

将可选的参数对Name1=Value1,...,NameN=ValueN, whereName是the argument name and价值是相应的值。名称值参数必须在其他参数之后出现,但是对的顺序并不重要。

Before R2021a, use commas to separate each name and value, and encloseNamein quotes.

例子:“尾巴”,“右”,“ alpha”,0.01specifies a right-tailed hypothesis test at the 1% significance level.

假设检验的显着性水平,指定为逗号分隔对'Α'和a scalar value in the range (0,1).

例子:'alpha',0.01

Data Types:single|双倍的

输入矩阵的维度进行测试,指定为逗号分隔对'Dim'和a positive integer value. For example, specifying'Dim',1测试每列中的数据是否方差平等,而'Dim',2测试每一行中的数据。

例子:'Dim',2

Data Types:single|双倍的

Type of alternative hypothesis to evaluate using theF-test, specified as the comma-separated pair consisting of'Tail'和one of the following.

'both' 测试人口差异不相等的替代假设。
'正确的' Test the alternative hypothesis that the population variance ofx大于y.
'剩下' Test the alternative hypothesis that the population variance ofx小于y.

例子:'Tail','right'

Output Arguments

全部收缩

Hypothesis test result, returned as1或者0.

  • 如果h= 1, this indicates the rejection of the null hypothesis at theAlphasignificance level.

  • 如果h= 0, this indicates a failure to reject the null hypothesis at theAlphasignificance level.

p- 测试值,在[0,1]范围内作为标量值返回。p是the probability of observing a test statistic as extreme as, or more extreme than, the observed value under the null hypothesis. Small values ofp对零假设的有效性产生怀疑。

Confidence interval for the true ratio of the population variances, returned as a two-element vector containing the lower and upper boundaries of the 100 × (1 –Alpha)置信区间%。

假设检验的测试统计量,返回为包含的结构:

  • fstat- 测试统计量的价值。

  • DF1- 测试的分子自由度。

  • DF2- 分母测试自由度。

More About

全部收缩

Two-SampleF-Test

The two-sampleF- 检验用于测试两个人群的方差是否相等。

The test statistic is

F = s 1 2 s 2 2 ,

wheres1s2are the sample standard deviations. The test statistic is a ratio of the two sample variances. The further this ratio deviates from 1, the more likely you are to reject the null hypothesis. Under the null hypothesis, the test statisticF有个F-distribution with numerator degrees of freedom equal toN1- 1和分母的自由度等于N2- 1,哪里N1N2are the sample sizes of the two data sets.

Multidimensional Array

多维阵列具有两个以上的维度。例如,如果x是a 1-by-3-by-4 array, thenx是一个三维阵列。

First Nonsingleton Dimension

第一个nonsingleton维度是大小不等于1的数组的第一个维度。例如,如果x是a 1-by-2-by-3-by-4 array, then the second dimension is the first nonsingleton dimension ofx.

Extended Capabilities

版本历史

在R2006a之前引入