Next: Models, Previous: Basic Statistical Functions, Up: Statistics

— Function File: [`pval`, `f`, `df_b`, `df_w`] = **anova** (`y, g`)

Perform a one-way analysis of variance (ANOVA). The goal is to test whether the population means of data taken from

kdifferent groups are all equal.Data may be given in a single vector

ywith groups specified by a corresponding vector of group labelsg(e.g., numbers from 1 tok). This is the general form which does not impose any restriction on the number of data in each group or the group labels.If

yis a matrix andgis omitted, each column ofyis treated as a group. This form is only appropriate for balanced ANOVA in which the numbers of samples from each group are all equal.Under the null of constant means, the statistic

ffollows an F distribution withdf_banddf_wdegrees of freedom.The p-value (1 minus the CDF of this distribution at

f) is returned inpval.If no output argument is given, the standard one-way ANOVA table is printed.

— Function File: [`pval`, `chisq`, `df`] = **bartlett_test** (`x1, ...`)

Perform a Bartlett test for the homogeneity of variances in the data vectors

x1,x2, ...,xk, wherek> 1.Under the null of equal variances, the test statistic

chisqapproximately ollows a chi-square distribution withdfdegrees of freedom.The p-value (1 minus the CDF of this distribution at

chisq) is returned inpval.If no output argument is given, the p-value is displayed.

— Function File: [`pval`, `chisq`, `df`] = **chisquare_test_homogeneity** (`x, y, c`)

Given two samples

xandy, perform a chisquare test for homogeneity of the null hypothesis thatxandycome from the same distribution, based on the partition induced by the (strictly increasing) entries ofc.For large samples, the test statistic

chisqapproximately follows a chisquare distribution withdf=`length (`

c`)`

degrees of freedom.The p-value (1 minus the CDF of this distribution at

chisq) is returned inpval.If no output argument is given, the p-value is displayed.

— Function File: [`pval`, `chisq`, `df`] = **chisquare_test_independence** (`x`)

Perform a chi-square test for indepence based on the contingency table

x. Under the null hypothesis of independence,chisqapproximately has a chi-square distribution withdfdegrees of freedom.The p-value (1 minus the CDF of this distribution at chisq) of the test is returned in

pval.If no output argument is given, the p-value is displayed.

— Function File: **cor_test** (`x, y, alt, method`)

Test whether two samples

xandycome from uncorrelated populations.The optional argument string

altdescribes the alternative hypothesis, and can be`"!="`

or`"<>"`

(non-zero),`">"`

(greater than 0), or`"<"`

(less than 0). The default is the two-sided case.The optional argument string

methodspecifies on which correlation coefficient the test should be based. Ifmethodis`"pearson"`

(default), the (usual) Pearson's product moment correlation coefficient is used. In this case, the data should come from a bivariate normal distribution. Otherwise, the other two methods offer nonparametric alternatives. Ifmethodis`"kendall"`

, then Kendall's rank correlation tau is used. Ifmethodis`"spearman"`

, then Spearman's rank correlation rho is used. Only the first character is necessary.The output is a structure with the following elements:

pval- The p-value of the test.
stat- The value of the test statistic.
dist- The distribution of the test statistic.
params- The parameters of the null distribution of the test statistic.
alternative- The alternative hypothesis.
method- The method used for testing.
If no output argument is given, the p-value is displayed.

— Function File: [`pval`, `f`, `df_num`, `df_den`] = **f_test_regression** (`y, x, rr, r`)

Perform an F test for the null hypothesis rr * b = r in a classical normal regression model y = X * b + e.

Under the null, the test statistic

ffollows an F distribution withdf_numanddf_dendegrees of freedom.The p-value (1 minus the CDF of this distribution at

f) is returned inpval.If not given explicitly,

r= 0.If no output argument is given, the p-value is displayed.

— Function File: [`pval`, `tsq`] = **hotelling_test** (`x, m`)

For a sample

xfrom a multivariate normal distribution with unknown mean and covariance matrix, test the null hypothesis that`mean (`

x`) ==`

m.Hotelling's T^2 is returned in

tsq. Under the null, (n-p) T^2 / (p(n-1)) has an F distribution with p and n-p degrees of freedom, where n and p are the numbers of samples and variables, respectively.The p-value of the test is returned in

pval.If no output argument is given, the p-value of the test is displayed.

— Function File: [`pval`, `tsq`] = **hotelling_test_2** (`x, y`)

For two samples

xfrom multivariate normal distributions with the same number of variables (columns), unknown means and unknown equal covariance matrices, test the null hypothesis`mean (`

x`) == mean (`

y`)`

.Hotelling's two-sample T^2 is returned in

tsq. Under the null,(n_x+n_y-p-1) T^2 / (p(n_x+n_y-2))has an F distribution with p and n_x+n_y-p-1 degrees of freedom, where n_x and n_y are the sample sizes and p is the number of variables.

The p-value of the test is returned in

pval.If no output argument is given, the p-value of the test is displayed.

— Function File: [`pval`, `ks`] = **kolmogorov_smirnov_test** (`x, dist, params, alt`)

Perform a Kolmogorov-Smirnov test of the null hypothesis that the sample

xcomes from the (continuous) distribution dist. I.e., if F and G are the CDFs corresponding to the sample and dist, respectively, then the null is that F == G.The optional argument

paramscontains a list of parameters ofdist. For example, to test whether a samplexcomes from a uniform distribution on [2,4], usekolmogorov_smirnov_test(x, "uniform", 2, 4)With the optional argument string

alt, the alternative of interest can be selected. Ifaltis`"!="`

or`"<>"`

, the null is tested against the two-sided alternative F != G. In this case, the test statisticksfollows a two-sided Kolmogorov-Smirnov distribution. Ifaltis`">"`

, the one-sided alternative F > G is considered. Similarly for`"<"`

, the one-sided alternative F > G is considered. In this case, the test statistickshas a one-sided Kolmogorov-Smirnov distribution. The default is the two-sided case.The p-value of the test is returned in

pval.If no output argument is given, the p-value is displayed.

— Function File: [`pval`, `ks`, `d`] = **kolmogorov_smirnov_test_2** (`x, y, alt`)

Perform a 2-sample Kolmogorov-Smirnov test of the null hypothesis that the samples

xandycome from the same (continuous) distribution. I.e., if F and G are the CDFs corresponding to thexandysamples, respectively, then the null is that F == G.With the optional argument string

alt, the alternative of interest can be selected. Ifaltis`"!="`

or`"<>"`

, the null is tested against the two-sided alternative F != G. In this case, the test statisticksfollows a two-sided Kolmogorov-Smirnov distribution. Ifaltis`">"`

, the one-sided alternative F > G is considered. Similarly for`"<"`

, the one-sided alternative F < G is considered. In this case, the test statistickshas a one-sided Kolmogorov-Smirnov distribution. The default is the two-sided case.The p-value of the test is returned in

pval.The third returned value,

d, is the test statistic, the maximum vertical distance between the two cumulative distribution functions.If no output argument is given, the p-value is displayed.

— Function File: [`pval`, `k`, `df`] = **kruskal_wallis_test** (`x1, ...`)

Perform a Kruskal-Wallis one-factor "analysis of variance".

Suppose a variable is observed for

k> 1 different groups, and letx1, ...,xkbe the corresponding data vectors.Under the null hypothesis that the ranks in the pooled sample are not affected by the group memberships, the test statistic

kis approximately chi-square withdf=k- 1 degrees of freedom.The p-value (1 minus the CDF of this distribution at

k) is returned inpval.If no output argument is given, the p-value is displayed.

— Function File: **manova** (`y, g`)

Perform a one-way multivariate analysis of variance (MANOVA). The goal is to test whether the p-dimensional population means of data taken from

kdifferent groups are all equal. All data are assumed drawn independently from p-dimensional normal distributions with the same covariance matrix.The data matrix is given by

y. As usual, rows are observations and columns are variables. The vectorgspecifies the corresponding group labels (e.g., numbers from 1 tok).The LR test statistic (Wilks' Lambda) and approximate p-values are computed and displayed.

— Function File: [`pval`, `chisq`, `df`] = **mcnemar_test** (`x`)

For a square contingency table

xof data cross-classified on the row and column variables, McNemar's test can be used for testing the null hypothesis of symmetry of the classification probabilities.Under the null,

chisqis approximately distributed as chisquare withdfdegrees of freedom.The p-value (1 minus the CDF of this distribution at

chisq) is returned inpval.If no output argument is given, the p-value of the test is displayed.

— Function File: [`pval`, `z`] = **prop_test_2** (`x1, n1, x2, n2, alt`)

If

x1andn1are the counts of successes and trials in one sample, andx2andn2those in a second one, test the null hypothesis that the success probabilitiesp1andp2are the same. Under the null, the test statisticzapproximately follows a standard normal distribution.With the optional argument string

alt, the alternative of interest can be selected. Ifaltis`"!="`

or`"<>"`

, the null is tested against the two-sided alternativep1!=p2. Ifaltis`">"`

, the one-sided alternativep1>p2is used. Similarly for`"<"`

, the one-sided alternativep1<p2is used. The default is the two-sided case.The p-value of the test is returned in

pval.If no output argument is given, the p-value of the test is displayed.

— Function File: [`pval`, `chisq`] = **run_test** (`x`)

Perform a chi-square test with 6 degrees of freedom based on the upward runs in the columns of

x. Can be used to test whetherxcontains independent data.The p-value of the test is returned in

pval.If no output argument is given, the p-value is displayed.

— Function File: [`pval`, `b`, `n`] = **sign_test** (`x, y, alt`)

For two matched-pair samples

xandy, perform a sign test of the null hypothesis PROB (x>y) == PROB (x<y) == 1/2. Under the null, the test statisticbroughly follows a binomial distribution with parametersn`= sum (`

x`!=`

y`)`

andp= 1/2.With the optional argument

`alt`

, the alternative of interest can be selected. Ifaltis`"!="`

or`"<>"`

, the null hypothesis is tested against the two-sided alternative PROB (x<y) != 1/2. Ifaltis`">"`

, the one-sided alternative PROB (x>y) > 1/2 ("x is stochastically greater than y") is considered. Similarly for`"<"`

, the one-sided alternative PROB (x>y) < 1/2 ("x is stochastically less than y") is considered. The default is the two-sided case.The p-value of the test is returned in

pval.If no output argument is given, the p-value of the test is displayed.

— Function File: [`pval`, `t`, `df`] = **t_test** (`x, m, alt`)

For a sample

xfrom a normal distribution with unknown mean and variance, perform a t-test of the null hypothesis`mean (`

x`) ==`

m. Under the null, the test statistictfollows a Student distribution withdf`= length (`

x`) - 1`

degrees of freedom.With the optional argument string

alt, the alternative of interest can be selected. Ifaltis`"!="`

or`"<>"`

, the null is tested against the two-sided alternative`mean (`

x`) !=`

m. Ifaltis`">"`

, the one-sided alternative`mean (`

x`) >`

mis considered. Similarly for"<", the one-sided alternative`mean (`

x`) <`

mis considered, The default is the two-sided case.The p-value of the test is returned in

pval.If no output argument is given, the p-value of the test is displayed.

— Function File: [`pval`, `t`, `df`] = **t_test_2** (`x, y, alt`)

For two samples x and y from normal distributions with unknown means and unknown equal variances, perform a two-sample t-test of the null hypothesis of equal means. Under the null, the test statistic

tfollows a Student distribution withdfdegrees of freedom.With the optional argument string

alt, the alternative of interest can be selected. Ifaltis`"!="`

or`"<>"`

, the null is tested against the two-sided alternative`mean (`

x`) != mean (`

y`)`

. Ifaltis`">"`

, the one-sided alternative`mean (`

x`) > mean (`

y`)`

is used. Similarly for`"<"`

, the one-sided alternative`mean (`

x`) < mean (`

y`)`

is used. The default is the two-sided case.The p-value of the test is returned in

pval.If no output argument is given, the p-value of the test is displayed.

— Function File: [`pval`, `t`, `df`] = **t_test_regression** (`y, x, rr, r, alt`)

Perform an t test for the null hypothesis

rr`*`

b`=`

rin a classical normal regression modely`=`

x`*`

b`+`

e. Under the null, the test statistictfollows atdistribution withdfdegrees of freedom.If

ris omitted, a value of 0 is assumed.With the optional argument string

alt, the alternative of interest can be selected. Ifaltis`"!="`

or`"<>"`

, the null is tested against the two-sided alternativerr`*`

b`!=`

r. Ifaltis`">"`

, the one-sided alternativerr`*`

b`>`

ris used. Similarly for"<", the one-sided alternativerr`*`

b`<`

ris used. The default is the two-sided case.The p-value of the test is returned in

pval.If no output argument is given, the p-value of the test is displayed.

— Function File: [`pval`, `z`] = **u_test** (`x, y, alt`)

For two samples

xandy, perform a Mann-Whitney U-test of the null hypothesis PROB (x>y) == 1/2 == PROB (x<y). Under the null, the test statisticzapproximately follows a standard normal distribution. Note that this test is equivalent to the Wilcoxon rank-sum test.With the optional argument string

alt, the alternative of interest can be selected. Ifaltis`"!="`

or`"<>"`

, the null is tested against the two-sided alternative PROB (x>y) != 1/2. Ifaltis`">"`

, the one-sided alternative PROB (x>y) > 1/2 is considered. Similarly for`"<"`

, the one-sided alternative PROB (x>y) < 1/2 is considered, The default is the two-sided case.The p-value of the test is returned in

pval.If no output argument is given, the p-value of the test is displayed.

— Function File: [`pval`, `f`, `df_num`, `df_den`] = **var_test** (`x, y, alt`)

For two samples

xandyfrom normal distributions with unknown means and unknown variances, perform an F-test of the null hypothesis of equal variances. Under the null, the test statistic f follows an F-distribution with df_num and df_den degrees of freedom.With the optional argument string

alt, the alternative of interest can be selected. Ifaltis`"!="`

or`"<>"`

, the null is tested against the two-sided alternative`var (`

x`) != var (`

y`)`

. Ifaltis`">"`

, the one-sided alternative`var (`

x`) > var (`

y`)`

is used. Similarly for "<", the one-sided alternative`var (`

x`) > var (`

y`)`

is used. The default is the two-sided case.The p-value of the test is returned in

pval.If no output argument is given, the p-value of the test is displayed.

— Function File: [`pval`, `t`, `df`] = **welch_test** (`x, y, alt`)

For two samples

xandyfrom normal distributions with unknown means and unknown and not necessarily equal variances, perform a Welch test of the null hypothesis of equal means. Under the null, the test statistic t approximately follows a Student distribution with df degrees of freedom.With the optional argument string

alt, the alternative of interest can be selected. Ifaltis`"!="`

or`"<>"`

, the null is tested against the two-sided alternative`mean (`

x`) !=`

m. Ifaltis`">"`

, the one-sided alternative mean(x) >mis considered. Similarly for`"<"`

, the one-sided alternative mean(x) <mis considered. The default is the two-sided case.The p-value of the test is returned in

pval.If no output argument is given, the p-value of the test is displayed.

— Function File: [`pval`, `z`] = **wilcoxon_test** (`x, y, alt`)

For two matched-pair sample vectors

xandy, perform a Wilcoxon signed-rank test of the null hypothesis PROB (x>y) == 1/2. Under the null, the test statisticzapproximately follows a standard normal distribution.With the optional argument string

alt, the alternative of interest can be selected. Ifaltis`"!="`

or`"<>"`

, the null is tested against the two-sided alternative PROB (x>y) != 1/2. If alt is`">"`

, the one-sided alternative PROB (x>y) > 1/2 is considered. Similarly for`"<"`

, the one-sided alternative PROB (x>y) < 1/2 is considered. The default is the two-sided case.The p-value of the test is returned in

pval.If no output argument is given, the p-value of the test is displayed.

— Function File: [`pval`, `z`] = **z_test** (`x, m, v, alt`)

Perform a Z-test of the null hypothesis

`mean (`

x`) ==`

mfor a samplexfrom a normal distribution with unknown mean and known variancev. Under the null, the test statisticzfollows a standard normal distribution.With the optional argument string

alt, the alternative of interest can be selected. Ifaltis`"!="`

or`"<>"`

, the null is tested against the two-sided alternative`mean (`

x`) !=`

m. Ifaltis`">"`

, the one-sided alternative`mean (`

x`) >`

mis considered. Similarly for`"<"`

, the one-sided alternative`mean (`

x`) <`

mis considered. The default is the two-sided case.The p-value of the test is returned in

pval.If no output argument is given, the p-value of the test is displayed along with some information.

— Function File: [`pval`, `z`] = **z_test_2** (`x, y, v_x, v_y, alt`)

For two samples

xandyfrom normal distributions with unknown means and known variancesv_xandv_y, perform a Z-test of the hypothesis of equal means. Under the null, the test statisticzfollows a standard normal distribution.With the optional argument string

alt, the alternative of interest can be selected. Ifaltis`"!="`

or`"<>"`

, the null is tested against the two-sided alternative`mean (`

x`) != mean (`

y`)`

. If alt is`">"`

, the one-sided alternative`mean (`

x`) > mean (`

y`)`

is used. Similarly for`"<"`

, the one-sided alternative`mean (`

x`) < mean (`

y`)`

is used. The default is the two-sided case.The p-value of the test is returned in

pval.If no output argument is given, the p-value of the test is displayed along with some information.