Main Content

T.T.est2

两个样本T.-测试

Description

H= ttest2(Xyreturns a test decision for the null hypothesis that the data in vectorsXandy来自具有相同手段和等于但未知的差异的正常分布的独立随机样本,使用T.wo-sampleT.-测试。替代假设是数据Xandy来自不平等的人口。结果His1如果测试在5%的意义水平下拒绝零假设,并且0.除此以外。

H= ttest2(Xy名称那Valuereturns a test decision for the two-sampleT.- 最低与一个或多个名称值对参数指定的其他选项。例如,您可以在不假设等方差的情况下更改显着性级别或进行测试。

[HP.] = ttest2(___also returns theP.-值,P.,测试,使用先前语法中的任何输入参数。

[HP.CI.统计] = ttest2(___还返回人口差异的置信区间,CI.和结构统计containing information about the test statistic.

Examples

collapse all

Load the data set. Create vectors containing the first and second columns of the data matrix to represent students’ grades on two exams.

加载examgradesx =等级(:,1);Y =等级(:,2);

测试零假设,即两个数据样本来自具有相等手段的群体。

[H那P.那CI.那S.T.ats] = ttest2(x,y)
H = 0.
p = 0.9867.
CI.=2×1-1.9438 1.9771
统计=S.T.ruct with fields:Tstat.: 0.0167 df: 238 sd: 7.7084

归还的价值H = 0.indicates thatT.T.est2does not reject the null hypothesis at the default 5% significance level.

Load the data set. Create vectors containing the first and second columns of the data matrix to represent students’ grades on two exams.

加载examgradesx =等级(:,1);Y =等级(:,2);

Test the null hypothesis that the two data vectors are from populations with equal means, without assuming that the populations also have equal variances.

[h,p] = ttest2(X那y那'vartype''不等'
H = 0.
p = 0.9867.

归还的价值H = 0.indicates thatT.T.est2即使没有假设等异模式,也不会在默认5%的显着性水平下拒绝NULL假设。

Input Arguments

collapse all

示例数据,指定为向量,矩阵或多维数组。T.T.est2T.reats值作为缺失数据并忽略它们。

  • IfXandy被指定为vectors,它们不需要相同。

  • IfXandyare specified as matrices, they must have the same number of columns.T.T.est2执行一个单独的T.-测试along each column and returns a vector of results.

  • IfXandyare specified asmultidimensional arrays,它们必须具有相同的大小,但是first nonsingleton dimension

数据类型:|double

示例数据,指定为向量,矩阵或多维数组。T.T.est2T.reats值作为缺失数据并忽略它们。

  • IfXandy被指定为vectors,它们不需要相同。

  • IfXandyare specified as matrices, they must have the same number of columns.T.T.est2执行一个单独的T.-测试along each column and returns a vector of results.

  • IfXandyare specified asmultidimensional arrays,它们必须具有相同的大小,但是first nonsingleton dimensionT.T.est2works along the first nonsingleton dimension.

数据类型:|double

名称-Value Pair Arguments

指定可选的逗号分离对名称那Valuearguments.名称是参数名称和Valueis the corresponding value.名称must appear inside quotes. You can specify several name and value pair arguments in any order as名称1那Value1,...,NameN,ValueN

Example:'尾巴'那'right','Alpha',0.01,'Vartype','unequal'S.P.ecifies a right-tailed test at the 1% significance level, and does not assume thatXandy有平的人口差异。

意义程度of the hypothesis test, specified as the comma-separated pair consisting of'Alpha'和范围内的标量值(0,1)。

Example:'Alpha',0.01

数据类型:|double

输入矩阵的维度,用于测试指定为逗号分隔的对'Dim'和积极的整数值。例如,指定'昏暗',1测试列意味着,而'昏暗',2T.ests the row means.

Example:'昏暗',2

数据类型:|double

评估的替代假设的类型,指定为逗号分隔的配对组成'尾巴'and one of:

  • '都'-Test against the alternative hypothesis that the population means are not equal.

  • 'right'-Test against the alternative hypothesis that the population mean ofX比人口大于y

  • 'left'-Test against the alternative hypothesis that the population mean ofXis less than the population mean ofy

T.T.est2T.ests the null hypothesis that the population means are equal against the specified alternative hypothesis.

Example:'尾巴'那'right'

方差类型,指定为逗号分隔的配对组成'vartype'以及以下之一。

'equal' Conduct test using the assumption thatXandy来自具有未知但相同的差异的正常分布。
'不等' Conduct test using the assumption thatXandyare from normal distributions with unknown and unequal variances. This is called the Behrens-Fisher problem.T.T.est2使用Satterthwaite的近似为有效的自由度。

Vartype甚至必须是单个方差类型X是矩阵或多维数组。

Example:'vartype','不平等'

输出参数

collapse all

假设测试结果,返回1or0.

  • IfH=1那T.His indicates the rejection of the null hypothesis at theAlphaS.ignificance level.

  • IfH=0.,这表明未能拒绝零假设AlphaS.ignificance level.

P.-值of the test, returned as a scalar value in the range [0,1].P.是观察测试统计学的概率,如零假设下观察到的值。小值P.cast doubt on the validity of the null hypothesis.

Confidence interval for the difference in population means ofXandy那returned as a two-element vector containing the lower and upper boundaries of the 100 × (1 –Alpha)% confidence interval.

两种样本的测试统计T.-测试那returned as a structure containing the following:

  • Tstat.-Value of the test statistic.

  • DF.-Degrees of freedom of the test.

  • SD.-Pooled estimate of the population standard deviation (for the equal variance case) or a vector containing the unpooled estimates of the population standard deviations (for the unequal variance case).

更多关于

collapse all

两个样本T.-测试

两个样本T.-test是比较两个独立数据样本的位置参数的参数测试。

The test statistic is

T. = X ¯ - y ¯ S. X 2 N. + S. y 2 m

哪里 X ¯ and y ¯ 样本意味着,S.XandS.yare the sample standard deviations, andN.andm样品尺寸是样本尺寸。

In the case where it is assumed that the two data samples are from populations with equal variances, the test statistic under the null hypothesis has Student'sT.分销N.+m– 2自由度,以及样本标准偏差被汇总的标准偏差所取代

S. = N. - 1 S. X 2 + m - 1 S. y 2 N. + m - 2

In the case where it is not assumed that the two data samples are from populations with equal variances, the test statistic under the null hypothesis has an approximate Student'sT.分销a number of degrees of freedom given by Satterthwaite's approximation. This test is sometimes called Welch’sT.-测试。

Multidimensional Array

有超过两个dimensi多维数组ons. For example, ifX是一个1×3×4阵列,然后是一个Xis a three-dimensional array.

第一个不明飞特的维度

The first nonsingleton dimension is the first dimension of an array whose size is not equal to 1. For example, ifX是一个1-×2×3×4阵列,那么第二维度是第一个不连续的尺寸X

Tips

  • UseS.ampsizepwr计算:

    • 对应于指定功率和参数值的示例大小;

    • 给定特定样本大小的功率,给定真实参数值;

    • 使用指定的样本大小和功率可检测的参数值。

扩展能力

也可以看看

||

Introduced before R2006a