Skip to main content

StatsTTest

StatsTTest [/ALPH=alpha /CI /DFM=m /MEAN=meanV /PAIR /TAIL=n /T=k /Z /Q] wave1 [, wave2 ]

The StatsTTest operation performs two kinds of T-tests: the first compares the mean of a distribution with a specified mean value (/MEAN) and the second compares the means of the two distributions contained in wave1 and wave2, which must contain at least two data points, can be any real numeric type, and can have an arbitrary number of dimensions. Output is to the W_StatsTTest wave in the current data folder or optionally to a table.

Flags

/ALPH=valSets the significance level (default val =0.05).
/CIComputes the confidence intervals for the mean(s).
/DEST=tWaveSpecify the output wave for the T-Test. If you do not specify this flag, the operation saves the output in the wave W_StatsTTest in the current data folder.
This flag was added in Igor Pro 10.00.
/DFM=mSpecifies method for calculating the degrees of freedom.
m =0:Default; computes equivalent degrees of freedom accounting for possibly different variances.
m =1:Computes equivalent degrees of freedom but truncates to a smaller integer.
m =2:Computes degrees of freedom by
DF=n1+n22\displaystyle D F=n_{1}+n_{2}-2
where n is the sum of points in the wave. Appropriate when variances are equal.
/FREECreates the specified destination wave as a free wave.
/FREE is allowed only in functions, and only if the destination waves are simple names or wave reference structure fields.
See Free Waves for more discussion.
The /FREE flag was added in Igor Pro 10.00.
/MEAN=meanVCompares meanV with the mean of the distribution in wave1. Outputs are the number of points in the wave, the degrees of freedom (accounting for any NaNs), the average, standard deviation (σ),
sXˉ=σDF+1,\displaystyle s_{\bar{X}}=\frac{\sigma}{\sqrt{D F+1}},
the statistic
t=Xˉ mean VsXˉ\displaystyle t=\frac{\bar{X}-\text { mean } V}{s_{\bar{X}}}
and the critical value, which depends on /TAIL.
/PAIRSpecifies that the input waves are pairs and computes the difference of each pair of data to get the average difference dˉ\displaystyle \bar{d}and the standard error of the difference Sdˉ\displaystyle S_{\bar{d}}. The t statistic is the ratio of the two
t=dˉsdˉ.\displaystyle t=\frac{\bar{d}}{s_{\bar{d}}} .
In this case H0 is that the difference dˉ\displaystyle \bar{d} is zero.
This mode does not support /CI and /DFM.
/QNo results printed in the history area.
/T=kDisplays results in a table. k specifies the table behavior when it is closed.
k =0:Normal with dialog (default).
k =1:Kills with no dialog.
k =2:Disables killing.
The table is associated with the test, not the data. If you repeat the test, it will update any existing table with the new results.
/TAIL=tailCodeSpecifies H0.
tailCode =1:One tailed test (µ<sub>1</sub> <= µ<sub>2</sub>).
tailCode = 2:One tailed test (µ<sub>1</sub> >= µ<sub>2</sub>).
tailCode =4:Default; two tailed test (µ<sub>1</sub> = µ<sub>2</sub>).
When performing paired tests using /PAIR:
tailCode =1:One tailed test (µ<sub>d</sub> <= 0).
tailCode = 2:One tailed test (µ<sub>d</sub> >= 0).
tailCode =4:Default; two tailed test (µ<sub>d</sub> = 0).
Here µd is the mean of the difference population.
/ZIgnores errors. V_flag will be set to -1 for any error and to zero otherwise.

Details

When comparing the mean of a single distribution with a hypothesized mean value, you should use /MEAN and only one wave (wave1 ). If you use two waves StatsTTest performs the T-test for the means of the corresponding distributions (which is incompatible with /MEAN).

When comparing the means of two distributions, the default t-statistic is computed from Welch's approximate t:

t=xˉ1xˉ2s12n1+s22n2,t^{\prime}=\frac{\bar{x}_{1}-\bar{x}_{2}}{\displaystyle \sqrt{\frac{s_{1}^{2}}{n_{1}}+\frac{s_{2}^{2}}{n_{2}}}},

where

si2\displaystyle s_{i}^{2}

are variances, ni are the number of samples and

Xˉi\displaystyle \bar{X}_{i}

are the averages of the respective waves. This expression is appropriate when the number of points and the variances of the two waves are different. If you want to compute the t-statistic using pooled variance you can use the /AEVR flag. In this case the pooled variance is given by

sp2=(n11)s12+(n21)s22n1+n22,\displaystyle s_{p}^{2}=\frac{\left(n_{1}-1\right) s_{1}^{2}+\left(n_{2}-1\right) s_{2}^{2}}{n_{1}+n_{2}-2},

and the t-statistic is

t=xˉ1xˉ2sp1n1+1n2.\displaystyle t=\frac{\bar{x}_{1}-\bar{x}_{2}}{s_{p} \sqrt{\frac{1}{n_{1}}+\frac{1}{n_{2}}}} .

The different test are:

H0Rejection Condition
µ12|t| >= Tc(alpha,ν)
µ12t <= Tc(alpha, ν)
µ12t >= Tc(alpha, ν)

Tc is the critical value and ν is the effective number of degrees of freedom (see /DFM flag). When accounting for possibly unequal variances, ν is given by

v=(s12n1+s22n2)2(s12n1)2n11+(s22n2)2n21.v=\frac{\left(\displaystyle \frac{s_{1}^{2}}{n_{1}}+\frac{\displaystyle s_{2}^{2}}{n_{2}}\right)^{2}}{\displaystyle \frac{\left(\displaystyle \frac{s_{1}^{2}}{n_{1}}\right)^{2}}{\displaystyle n_{1}-1}+\frac{\displaystyle \left(\frac{\displaystyle s_{2}^{2}}{n_{2}}\right)^{2}}{\displaystyle n_{2}-1}} .

The critical values (Tc) are computed by numerically by solving for the argument at which the cumulative distribution function (CDF) equals the appropriate values for the tests. The CDF is given by

F(x)={12 betai (v2,12,vv+x2)x<0112 betai (v2,12,vv+x2)x0F(x)=\left\{\begin{array}{ll} \displaystyle \frac{1}{2} \text { betai }\left(\frac{v}{2}, \frac{1}{2}, \frac{v}{v+x^{2}}\right) & x<0 \\ \\ \displaystyle 1-\frac{1}{2} \text { betai }\left(\frac{v}{2}, \frac{1}{2}, \frac{v}{v+x^{2}}\right) & x \geq 0 \end{array}\right.

To get the critical value for the upper one-tail test we solve F(x)=1-alpha. For the lower one-tail test we solve for x the equation F(x)=alpha. In the two-tailed test the lower critical value is a solution for F(x)=alpha/2 and the upper critical value is a solution for F(x)=1-alpha/2.

The T-test assumes that both samples are randomly taken from normally distributed populations.

See Also

Statistical Analysis, StatsStudentPDF, StatsStudentCDF, StatsInvStudentCDF

References

Zar, J.H., Biostatistical Analysis, 4th ed., 929 pp., Prentice Hall, Englewood Cliffs, New Jersey, 1999. See in particular Section 8.1.

Demos

Open T-Test Demo.pxp