Mercurial > hg > octave-lojdl
changeset 3454:d8b731d3f7a3
[project @ 2000-01-18 10:13:31 by jwe]
line wrap: on
line diff
--- a/doc/interpreter/stats.txi +++ b/doc/interpreter/stats.txi @@ -11,11 +11,12 @@ @menu * Basic Statistical Functions:: +* Tests:: * Models:: * Distributions:: @end menu -@node Basic Statistical Functions, Models, Statistics, Statistics +@node Basic Statistical Functions, Tests, Statistics, Statistics @section Basic Statistical Functions @DOCSTRING(mean) @@ -81,8 +82,60 @@ @node Tests, Models, Basic Statistical Functions, Statistics @section Tests -@node Models, Distributions, Basic Statistical Functions, Statistics +@DOCSTRING(anova) + +@DOCSTRING(bartlett_test) + +@DOCSTRING(chisquare_test_homogeneity) + +@DOCSTRING(chisquare_test_independence) + +@DOCSTRING(cor_test) + +@DOCSTRING(f_test_regression) + +@DOCSTRING(hotelling_test) + +@DOCSTRING(hotelling_test_2) + +@DOCSTRING(kolmogorov_smirnov_test) + +@DOCSTRING(kolmogorov_smirnov_test_2) + +@DOCSTRING(kruskal_wallis_test) + +@DOCSTRING(manova) + +@DOCSTRING(mcnemar_test) + +@DOCSTRING(prop_test_2) + +@DOCSTRING(run_test) + +@DOCSTRING(sign_test) + +@DOCSTRING(t_test) + +@DOCSTRING(t_test_2) + +@DOCSTRING(t_test_regression) + +@DOCSTRING(u_test) + +@DOCSTRING(var_test) + +@DOCSTRING(welch_test) + +@DOCSTRING(wilcoxon_test) + +@DOCSTRING(z_test) + +@DOCSTRING(z_test_2) + +@node Models, Distributions, Tests, Statistics @section Models +@DOCSTRING(logistic_regression) + @node Distributions, , Models, Statistics @section Distributions
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -21,6 +21,34 @@ * statistics/base/cor.m: Ditto. * statistics/base/cloglog.m: Ditto. * statistics/base/center.m: Ditto. + * statistics/models/logistic_regression.m: Ditto. + * statistics/models/logistic_regression_derivative.m: Ditto. + * statistics/models/logistic_regression_likelihood.m: Ditto. + * statistics/tests/anova.m: Ditto. + * statistics/tests/bartlett_test.m: Ditto. + * statistics/tests/chisquare_test_homogeneity.m: Ditto. + * statistics/tests/chisquare_test_independence.m: Ditto. + * statistics/tests/cor_test.m: Ditto. + * statistics/tests/f_test_regression.m: Ditto. + * statistics/tests/hotelling_test.m: Ditto. + * statistics/tests/hotelling_test_2.m: Ditto. + * statistics/tests/kolmogorov_smirnov_test.m: Ditto. + * statistics/tests/kolmogorov_smirnov_test_2.m: Ditto. + * statistics/tests/kruskal_wallis_test.m: Ditto. + * statistics/tests/manova.m: Ditto. + * statistics/tests/mcnemar_test.m: Ditto. + * statistics/tests/prop_test_2.m: Ditto. + * statistics/tests/run_test.m: Ditto. + * statistics/tests/sign_test.m: Ditto. + * statistics/tests/t_test.m: Ditto. + * statistics/tests/t_test_2.m: Ditto. + * statistics/tests/t_test_regression.m: Ditto. + * statistics/tests/u_test.m: Ditto. + * statistics/tests/var_test.m: Ditto. + * statistics/tests/welch_test.m: Ditto. + * statistics/tests/wilcoxon_test.m: Ditto. + * statistics/tests/z_test.m: Ditto. + * statistics/tests/z_test_2.m: Ditto. 2000-01-17 John W. Eaton <jwe@bevo.che.wisc.edu>
--- a/scripts/statistics/models/logistic_regression.m +++ b/scripts/statistics/models/logistic_regression.m @@ -14,41 +14,60 @@ ## along with this file. If not, write to the Free Software Foundation, ## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -## Performs ordinal logistic regression. +## -*- texinfo -*- +## @deftypefn {Functio File} {[@var{theta}, @var{beta}, @var{dev}, @var{dl}, @var{d2l}, @var{p}] =} logistic_regression (@var{y}, @var{x}, @var{print}, @var{theta}, @var{beta}) +## Perform ordinal logistic regression. ## -## Suppose Y takes values in k ordered categories, and let gamma_i (x) -## be the cumulative probability that Y falls in one of the first i -## categories given the covariate x. Then -## [theta, beta] = -## logistic_regression (y, x) +## Suppose @var{y} takes values in @var{k} ordered categories, and let +## @code{gamma_i (@var{x})} be the cumulative probability that @var{y} +## falls in one of the first @var{i} categories given the covariate +## @var{x}. Then +## +## @example +## [theta, beta] = logistic_regression (y, x) +## @end example +## +## @noindent ## fits the model -## logit (gamma_i (x)) = theta_i - beta' * x, i = 1, ..., k-1. -## The number of ordinal categories, k, is taken to be the number of -## distinct values of round (y) . If k equals 2, y is binary and the -## model is ordinary logistic regression. X is assumed to have full -## column rank. +## +## @example +## logit (gamma_i (x)) = theta_i - beta' * x, i = 1, ..., k-1 +## @end example ## -## theta = logistic_regression (y) +## The number of ordinal categories, @var{k}, is taken to be the number +## of distinct values of @code{round (@var{y})}. If @var{k} equals 2, +## @var{y} is binary and the model is ordinary logistic regression. The +## matrix @var{x} is assumed to have full column rank. +## +## Given @var{y} only, @code{theta = logistic_regression (y)} ## fits the model with baseline logit odds only. ## ## The full form is -## [theta, beta, dev, dl, d2l, gamma] = -## logistic_regression (y, x, print, theta, beta) -## in which all output arguments and all input arguments except y are -## optional. +## +## @example +## [theta, beta, dev, dl, d2l, gamma] +## = logistic_regression (y, x, print, theta, beta) +## @end example +## +## @noindent +## in which all output arguments and all input arguments except @var{y} +## are optional. ## -## print = 1 requests summary information about the fitted model to be -## displayed; print = 2 requests information about convergence at each -## iteration. Other values request no information to be displayed. The -## input arguments `theta' and `beta' give initial estimates for theta -## and beta. +## Stting @var{print} to 1 requests summary information about the fitted +## model to be displayed. Setting @var{print} to 2 requests information +## about convergence at each iteration. Other values request no +## information to be displayed. The input arguments @var{theta} and +## @var{beta} give initial estimates for @var{theta} and @var{beta}. +## +## The returned value @var{dev} holds minus twice the log-likelihood. ## -## `dev' holds minus twice the log-likelihood. +## The returned values @var{dl} and @var{d2l} are the vector of first +## and the matrix of second derivatives of the log-likelihood with +## respect to @var{theta} and @var{beta}. ## -## `dl' and `d2l' are the vector of first and the matrix of second -## derivatives of the log-likelihood with respect to theta and beta. -## -## `p' holds estimates for the conditional distribution of Y given x. +## @var{p} holds estimates for the conditional distribution of @var{y} +## given @var{x}. +## @end deftypefn ## Original for MATLAB written by Gordon K Smyth <gks@maths.uq.oz.au>, ## U of Queensland, Australia, on Nov 19, 1990. Last revision Aug 3, @@ -62,7 +81,7 @@ ## logistic_regression_likelihood. function [theta, beta, dev, dl, d2l, p] ... - = logistic_regression (y, x, print, theta, beta) + = logistic_regression (y, x, print, theta, beta) ## check input y = round (vec (y));
--- a/scripts/statistics/models/logistic_regression_derivatives.m +++ b/scripts/statistics/models/logistic_regression_derivatives.m @@ -14,15 +14,17 @@ ## along with this file. If not, write to the Free Software Foundation, ## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{dl}, @var{d2l}] =} logistic_regression_derivatives (@var{x}, @var{z}, @var{z1}, @var{g}, @var{g1}, @var{p}) ## Called by logistic_regression. Calculates derivates of the ## log-likelihood for ordinal logistic regression model. +## @end deftypefn ## Author: Gordon K. Smyth <gks@maths.uq.oz.au> ## Adapted-By: KH <Kurt.Hornik@ci.tuwien.ac.at> ## Description: Derivates of log-likelihood in logistic regression -function [dl, d2l] ... - = logistic_regression_derivatives (x, z, z1, g, g1, p) +function [dl, d2l] = logistic_regression_derivatives (x, z, z1, g, g1, p) ## first derivative v = g .* (1 - g) ./ p; v1 = g1 .* (1 - g1) ./ p;
--- a/scripts/statistics/models/logistic_regression_likelihood.m +++ b/scripts/statistics/models/logistic_regression_likelihood.m @@ -14,15 +14,17 @@ ## along with this file. If not, write to the Free Software Foundation, ## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{g}, @var{g1}, @var{p}, @var{dev}] =} logistic_regression_likelihood (@var{y}, @var{x}, @var{beta}, @var{z}, @var{z1}) ## Calculates likelihood for the ordinal logistic regression model. ## Called by logistic_regression. +## @end deftypefn ## Author: Gordon K. Smyth <gks@maths.uq.oz.au> ## Adapted-By: KH <Kurt.Hornik@ci.tuwien.ac.at> ## Description: Likelihood in logistic regression -function [g, g1, p, dev] ... - = logistic_regression_likelihood (y, x, beta, z, z1) +function [g, g1, p, dev] = logistic_regression_likelihood (y, x, beta, z, z1) e = exp ([z, x] * beta); e1 = exp ([z1, x] * beta); g = e ./ (1 + e); g1 = e1 ./ (1 + e1);
--- a/scripts/statistics/tests/anova.m +++ b/scripts/statistics/tests/anova.m @@ -14,26 +14,30 @@ ## along with this file. If not, write to the Free Software Foundation, ## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -## Performs a one-way analysis of variance (ANOVA). The goal is to test -## whether the population means of data taken from k different groups -## are all equal. +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{pval}, @var{f}, @var{df_b}, @var{df_w}] =} anova (@var{y}, @var{g}) +## Perform a one-way analysis of variance (ANOVA). The goal is to test +## whether the population means of data taken from @var{k} different +## groups are all equal. ## -## anova (y, g) provides all data in a single vector y; g is the vector -## of corresponding group labels (e.g., numbers from 1 to k). This is -## the general form which does not impose any restriction on the number -## of data in each group or the group labels (other than that they must -## be scalars). +## Data may be given in a single vector @var{y} with groups specified by +## a corresponding vector of group labels @var{g} (e.g., numbers from 1 +## to @var{k}). This is the general form which does not impose any +## restriction on the number of data in each group or the group labels. ## -## anova (y), where y is a matrix, treats each column as a group. This -## form is only appropriate for balanced ANOVA where the numbers of -## samples from each group are all equal. +## If @var{y} is a matrix and @var{g} is omitted, each column of @var{y} +## is 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 f follows an F -## distribution with df_b and df_w degrees of freedom. pval is the -## p-value (1 minus the CDF of this distribution at f) of the test. +## Under the null of constant means, the statistic @var{f} follows an F +## distribution with @var{df_b} and @var{df_w} degrees of freedom. +## +## The p-value (1 minus the CDF of this distribution at @var{f}) is +## returned in @var{pval}. ## ## If no output argument is given, the standard one-way ANOVA table is ## printed. +## @end deftypefn ## Author: KH <Kurt.Hornik@ci.tuwien.ac.at> ## Description: One-way analysis of variance (ANOVA)
--- a/scripts/statistics/tests/bartlett_test.m +++ b/scripts/statistics/tests/bartlett_test.m @@ -14,17 +14,20 @@ ## along with this file. If not, write to the Free Software Foundation, ## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -## usage: [pval, chisq, df] = bartlett_test (x1, ...) -## -## Performs a Bartlett test for the homogeneity of variances in the data -## vectors x1, x2, ..., xk, where k > 1. +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{pval}, @var{chisq}, @var{df}] =} bartlett_test (@var{x1}, @dots{}) +## Perform a Bartlett test for the homogeneity of variances in the data +## vectors @var{x1}, @var{x2}, @dots{}, @var{xk}, where @var{k} > 1. ## -## Under the null of equal variances, the test statistic chisq -## approximately ollows a chi-square distribution with df degrees of -## freedom; pval is the p-value (1 minus the CDF of this distribution at -## chisq) of the test. +## Under the null of equal variances, the test statistic @var{chisq} +## approximately ollows a chi-square distribution with @var{df} degrees of +## freedom. +## +## The p-value (1 minus the CDF of this distribution at @var{chisq}) is +## returned in @var{pval}. ## ## If no output argument is given, the p-value is displayed. +## @end deftypefn ## Author: KH <Kurt.Hornik@ci.tuwien.ac.at> ## Description: Bartlett test for homogeneity of variances
--- a/scripts/statistics/tests/chisquare_test_homogeneity.m +++ b/scripts/statistics/tests/chisquare_test_homogeneity.m @@ -14,19 +14,22 @@ ## along with this file. If not, write to the Free Software Foundation, ## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -## usage: [pval, chisq, df] = chisquare_test_homogeneity (x, y, c) +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{pval}, @var{chisq}, @var{df}] =} chisquare_test_homogeneity (@var{x}, @var{y}, @var{c}) +## Given two samples @var{x} and @var{y}, perform a chisquare test for +## homogeneity of the null hypothesis that @var{x} and @var{y} come from +## the same distribution, based on the partition induced by the +## (strictly increasing) entries of @var{c}. ## -## Given two samples x and y, perform a chisquare test for homogeneity -## of the null hypothesis that x and y come from the same distribution, -## based on the partition induced by the (strictly increasing) entries -## of c. +## For large samples, the test statistic @var{chisq} approximately follows a +## chisquare distribution with @var{df} = @code{length (@var{c})} +## degrees of freedom. ## -## For large samples, the test statistic chisq approximately follows a -## chisquare distribution with df = length(c) degrees pf freedom. pval -## is the p-value (1 minus the CDF of this distribution at chisq) of the -## test. +## The p-value (1 minus the CDF of this distribution at @var{chisq}) is +## returned in @var{pval}. ## ## If no output argument is given, the p-value is displayed. +## @end deftypefn ## Author: KH <Kurt.Hornik@ci.tuwien.ac.at> ## Description: Chi-square test for homogeneity
--- a/scripts/statistics/tests/chisquare_test_independence.m +++ b/scripts/statistics/tests/chisquare_test_independence.m @@ -14,16 +14,18 @@ ## along with this file. If not, write to the Free Software Foundation, ## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -## usage: [pval, chisq, df] = chisquare_test_independence (X) -## +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{pval}, @var{chisq}, @var{df}] =} chisquare_test_independence (@var{x}) ## Perform a chi-square test for indepence based on the contingency -## table X. +## table @var{x}. Under the null hypothesis of independence, +## @var{chisq} approximately has a chi-square distribution with +## @var{df} degrees of freedom. ## -## Under the null hypothesis of independence, chisq approximately has a -## chi-square distribution with df degrees of freedom. pval is the -## p-value (1 minus the CDF of this distribution at chisq) of the test. +## The p-value (1 minus the CDF of this distribution at chisq) of the +## test is returned in @var{pval}. ## ## If no output argument is given, the p-value is displayed. +## @end deftypefn ## Author: KH <Kurt.Hornik@ci.tuwien.ac.at> ## Description: Chi-square test for independence
--- a/scripts/statistics/tests/cor_test.m +++ b/scripts/statistics/tests/cor_test.m @@ -14,34 +14,45 @@ ## along with this file. If not, write to the Free Software Foundation, ## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -## usage: cor_test (X, Y [, ALTERNATIVE [, METHOD]]) -## -## Test whether two samples X and Y come from uncorrelated populations. +## -*- texinfo -*- +## @deftypefn {Function File} {} cor_test (@var{x}, @var{y}, @var{alt}, @var{method}) +## Test whether two samples @var{x} and @var{y} come from uncorrelated +## populations. ## -## The optional argument string ALTERNATIVE describes 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 @var{alt} describes the alternative +## hypothesis, and can be @code{"!="} or @code{"<>"} (non-zero), +## @code{">"} (greater than 0), or @code{"<"} (less than 0). The +## default is the two-sided case. ## -## The optional argument string METHOD specifies on which correlation -## coefficient the test should be based. -## If METHOD is "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. -## If METHOD is "kendall", then Kendall's rank correlation tau is used. -## If METHOD is "spearman", then Spearman's rank correlation rho is used. -## Only the first character is necessary. +## The optional argument string @var{method} specifies on which +## correlation coefficient the test should be based. If @var{method} is +## @code{"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. If @var{method} is +## @code{"kendall"}, then Kendall's rank correlation tau is used. If +## @var{method} is @code{"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 pval is displayed. +## @table @var +## @item pval +## The p-value of the test. +## @item stat +## The value of the test statistic. +## @item dist +## The distribution of the test statistic. +## @item params +## The parameters of the null distribution of the test statistic. +## @item alternative +## The alternative hypothesis. +## @item method +## The method used for testing. +## @end table +## +## If no output argument is given, the p-value is displayed. +## @end deftypefn ## Author: FL <Friedrich.Leisch@ci.tuwien.ac.at> ## Adapted-by: KH <Kurt.Hornik@ci.tuwien.ac.at>
--- a/scripts/statistics/tests/f_test_regression.m +++ b/scripts/statistics/tests/f_test_regression.m @@ -14,18 +14,21 @@ ## along with this file. If not, write to the Free Software Foundation, ## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -## usage: [pval, f, df_num, df_den] = f_test_regression (y, X, R [, r]) -## -## Performs an F test for the null hypothesis R * b = r in a classical +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{pval}, @var{f}, @var{df_num}, @var{df_den}] =} f_test_regression (@var{y}, @var{X}, @var{R}, @var{r}) +## Perform an F test for the null hypothesis R * b = r in a classical ## normal regression model y = X * b + e. ## -## Under the null, the test statistic f follows an F distribution with -## df_num and df_den degrees of freedom; pval is the p-value (1 minus -## the CDF of this distribution at f) of the test. +## Under the null, the test statistic @var{f} follows an F distribution +## with @var{df_num} and @var{df_den} degrees of freedom. ## -## If not given explicitly, r = 0. +## The p-value (1 minus the CDF of this distribution at @var{f}) is +## returned in @var{pval}. +## +## If not given explicitly, @var{r} = 0. ## ## If no output argument is given, the p-value is displayed. +## @end deftypefn ## Author: KH <Kurt.Hornik@ci.tuwien.ac.at> ## Description: Test linear hypotheses in linear regression model
--- a/scripts/statistics/tests/hotelling_test.m +++ b/scripts/statistics/tests/hotelling_test.m @@ -14,19 +14,21 @@ ## along with this file. If not, write to the Free Software Foundation, ## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -## usage: [pval, Tsq] = hotelling_test (x, m) -## -## For a sample x from a multivariate normal distribution with unknown -## mean and covariance matrix, test the null hypothesis that mean (x) == -## m. +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{pval}, @var{Tsq}] =} hotelling_test (@var{x}, @var{m}) +## For a sample @var{x} from a multivariate normal distribution with unknown +## mean and covariance matrix, test the null hypothesis that @code{mean +## (@var{x}) == @var{m}}. ## -## Tsq is Hotelling's T^2. 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. +## Hotelling's T^2 is returned in @var{Tsq}. Under the null, +## @math{(n-p) T^2 / (p(n-1))} has an F distribution with @math{p} and +## @math{n-p} degrees of freedom, where @math{n} and @math{p} are the +## numbers of samples and variables, respectively. ## -## pval is the p-value of the test. +## The p-value of the test is returned in @var{pval}. ## ## If no output argument is given, the p-value of the test is displayed. +## @end deftypefn ## Author: KH <Kurt.Hornik@ci.tuwien.ac.at> ## Description: Test for mean of a multivariate normal
--- a/scripts/statistics/tests/hotelling_test_2.m +++ b/scripts/statistics/tests/hotelling_test_2.m @@ -14,21 +14,28 @@ ## along with this file. If not, write to the Free Software Foundation, ## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -## usage: [pval, Tsq] = hotelling_test_2 (x, y) +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{pval}, @var{Tsq}] =} hotelling_test_2 (@var{x}, @var{y}) +## For two samples @var{x} from multivariate normal distributions with +## the same number of variables (columns), unknown means and unknown +## equal covariance matrices, test the null hypothesis @code{mean +## (@var{x}) == mean (@var{y})}. ## -## For two samples x from 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 @var{Tsq}. Under the null, ## -## Tsq is Hotelling's two-sample T^2. 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. +## @example +## (n_x+n_y-p-1) T^2 / (p(n_x+n_y-2)) +## @end example ## -## pval is the p-value of the test. +## @noindent +## has an F distribution with @math{p} and @math{n_x+n_y-p-1} degrees of +## freedom, where @math{n_x} and @math{n_y} are the sample sizes and +## @math{p} is the number of variables. +## +## The p-value of the test is returned in @var{pval}. ## ## If no output argument is given, the p-value of the test is displayed. +## @end deftypefn ## Author: KH <Kurt.Hornik@ci.tuwien.ac.at> ## Description: Compare means of two multivariate normals
--- a/scripts/statistics/tests/kolmogorov_smirnov_test.m +++ b/scripts/statistics/tests/kolmogorov_smirnov_test.m @@ -14,31 +14,34 @@ ## along with this file. If not, write to the Free Software Foundation, ## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -## usage: -## [pval, ks] = kolmogorov_smirnov_test (x, dist [, params] [, alt]) -## +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{pval}, @var{ks}] =} kolmogorov_smirnov_test (@var{x}, @var{dist}, @var{params}, @var{alt}) +## Perform a Kolmogorov-Smirnov test of the null hypothesis that the +## sample @var{x} comes 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. ## -## Performs a Kolmogorov-Smirnov test of the null hypothesis that the -## sample x comes 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 @var{params} contains a list of parameters of +## @var{dist}. For example, to test whether a sample @var{x} comes from +## a uniform distribution on [2,4], use ## -## The optional argument params contains a list of parameters of dist. -## E.g., to test whether a sample x comes from a uniform distribution on -## [2,4], use `kolmogorov_smirnov_test(x, "uniform", 2, 4)'. +## @example +## kolmogorov_smirnov_test(x, "uniform", 2, 4) +## @end example ## -## With the optional argument string alt, the alternative of interest -## can be selected. If alt is "!=" or "<>", the null is tested against -## the two-sided alternative F != G. In this case, the test statistic -## ks follows a two-sided Kolmogorov-Smirnov distribution. -## If alt is ">", the one-sided alternative F > G is considered, -## similarly for "<". In this case, the test statistic ks has a -## one-sided Kolmogorov-Smirnov distribution. -## The default is the two-sided case. +## With the optional argument string @var{alt}, the alternative of +## interest can be selected. If @var{alt} is @code{"!="} or +## @code{"<>"}, the null is tested against the two-sided alternative F +## != G. In this case, the test statistic @var{ks} follows a two-sided +## Kolmogorov-Smirnov distribution. If @var{alt} is @code{">"}, the +## one-sided alternative F > G is considered, similarly for @code{"<"}. +## In this case, the test statistic @var{ks} has a one-sided +## Kolmogorov-Smirnov distribution. The default is the two-sided case. ## -## pval is the p-value of the test. +## The p-value of the test is returned in @var{pval}. ## ## If no output argument is given, the p-value is displayed. +## @end deftypefn ## Author: KH <Kurt.Hornik@ci.tuwien.ac.at> ## Description: One-sample Kolmogorov-Smirnov test
--- a/scripts/statistics/tests/kolmogorov_smirnov_test_2.m +++ b/scripts/statistics/tests/kolmogorov_smirnov_test_2.m @@ -14,26 +14,27 @@ ## along with this file. If not, write to the Free Software Foundation, ## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -## usage: [pval, ks] = kolmogorov_smirnov_test_2 (x, y [, alt]) -## -## Performs a 2-sample Kolmogorov-Smirnov test of the null hypothesis -## that the samples x and y come from the same (continuous) distribution. -## I.e., if F and G are the CDFs corresponding to the x and y samples, -## respectively, then the null is that F == G. +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{pval}, @var{ks}] =} kolmogorov_smirnov_test_2 (@var{x}, @var{y}, @var{alt}) +## Perform a 2-sample Kolmogorov-Smirnov test of the null hypothesis +## that the samples @var{x} and @var{y} come from the same (continuous) +## distribution. I.e., if F and G are the CDFs corresponding to the +## @var{x} and @var{y} samples, respectively, then the null is that F == +## G. ## -## With the optional argument string alt, the alternative of interest -## can be selected. -## If alt is "!=" or "<>", the null is tested against the two-sided -## alternative F != G. In this case, the test statistic ks follows a -## two-sided Kolmogorov-Smirnov distribution. -## If alt is ">", the one-sided alternative F > G is considered, -## similarly for "<". In this case, the test statistic ks has a -## one-sided Kolmogorov-Smirnov distribution. -## The default is the two-sided case. +## With the optional argument string @var{alt}, the alternative of +## interest can be selected. If @var{alt} is @code{"!="} or +## @code{"<>"}, the null is tested against the two-sided alternative F +## != G. In this case, the test statistic @var{ks} follows a two-sided +## Kolmogorov-Smirnov distribution. If @var{alt} is @code{">"}, the +## one-sided alternative F > G is considered, similarly for @code{"<"}. +## In this case, the test statistic @var{ks} has a one-sided +## Kolmogorov-Smirnov distribution. The default is the two-sided case. ## -## pval is the p-value of the test. +## The p-value of the test is returned in @var{pval}. ## ## If no output argument is given, the p-value is displayed. +## @end deftypefn ## Author: KH <Kurt.Hornik@ci.tuwien.ac.at> ## Description: Two-sample Kolmogorov-Smirnov test
--- a/scripts/statistics/tests/kruskal_wallis_test.m +++ b/scripts/statistics/tests/kruskal_wallis_test.m @@ -14,19 +14,23 @@ ## along with this file. If not, write to the Free Software Foundation, ## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -## usage: [pval, k, df] = kruskal_wallis_test (x1, ...) -## +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{pval}, @var{k}, @var{df}] =} kruskal_wallis_test (@var{x1}, @dots{}) ## Perform a Kruskal-Wallis one-factor "analysis of variance". ## -## Suppose a variable is observed for k > 1 different groups, and let -## x1, ..., xk be the corresponding data vectors. +## Suppose a variable is observed for @var{k} > 1 different groups, and +## let @var{x1}, @dots{}, @var{xk} be 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 k is -## approximately chi-square with df = k - 1 degrees of freedom. pval is -## the p-value (1 minus the CDF of this distribution at k) of this test. +## affected by the group memberships, the test statistic @var{k} is +## approximately chi-square with @var{df} = @var{k} - 1 degrees of +## freedom. ## -## If no output argument is given, the pval is displayed. +## The p-value (1 minus the CDF of this distribution at @var{k}) is +## returned in @var{pval}. +## +## If no output argument is given, the p-value is displayed. +## @end deftypefn ## Author: KH <Kurt.Hornik@ci.tuwien.ac.at> ## Description: Kruskal-Wallis test
--- a/scripts/statistics/tests/manova.m +++ b/scripts/statistics/tests/manova.m @@ -14,21 +14,21 @@ ## along with this file. If not, write to the Free Software Foundation, ## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -## usage: manova (Y, g) -## -## Performs a one-way multivariate analysis of variance (MANOVA). The +## -*- texinfo -*- +## @deftypefn {Function File} {} manova (@var{y}, @var{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 k different groups are all equal. All data are assumed -## drawn independently from p-dimensional normal distributions with the -## same covariance matrix. +## taken from @var{k} different groups are all equal. All data are +## assumed drawn independently from p-dimensional normal distributions +## with the same covariance matrix. ## -## Y is the data matrix. As usual, rows are observations and columns -## are variables. g is the vector of corresponding group labels (e.g., -## numbers from 1 to k), so that necessarily, length (g) must be the -## same as rows (Y). +## The data matrix is given by @var{y}. As usual, rows are observations +## and columns are variables. The vector @var{g} specifies the +## corresponding group labels (e.g., numbers from 1 to @var{k}). ## ## The LR test statistic (Wilks' Lambda) and approximate p-values are ## computed and displayed. +## @end deftypefn ## Three test statistics (Wilks, Hotelling-Lawley, and Pillai-Bartlett) ## and corresponding approximate p-values are calculated and displayed.
--- a/scripts/statistics/tests/mcnemar_test.m +++ b/scripts/statistics/tests/mcnemar_test.m @@ -14,17 +14,20 @@ ## along with this file. If not, write to the Free Software Foundation, ## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -## usage: [pval, chisq, df] = mcnemar_test (x) +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{pval}, @var{chisq}, @var{df}] =} mcnemar_test (@var{x}) +## For a square contingency table @var{x} of 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. ## -## For a square contingency table x of 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, @var{chisq} is approximately distributed as chisquare +## with @var{df} degrees of freedom. ## -## Under the null, chisq is approximately distributed as chisquare with -## df degrees of freedom, and pval is the p-value (1 minus the CDF of -## this distribution at chisq) of the test. +## The p-value (1 minus the CDF of this distribution at @var{chisq}) is +## returned in @var{pval}. ## ## If no output argument is given, the p-value of the test is displayed. +## @end deftypefn ## Author: KH <Kurt.Hornik@ci.tuwien.ac.at> ## Description: McNemar's test for symmetry
--- a/scripts/statistics/tests/prop_test_2.m +++ b/scripts/statistics/tests/prop_test_2.m @@ -14,25 +14,25 @@ ## along with this file. If not, write to the Free Software Foundation, ## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -## usage: [pval, z] = prop_test_2 (x1, n1, x2, n2 [, alt]) +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{pval}, @var{z}] =} prop_test_2 (@var{x1}, @var{n1}, @var{x2}, @var{n2}, @var{alt}) +## If @var{x1} and @var{n1} are the counts of successes and trials in +## one sample, and @var{x2} and @var{n2} those in a second one, test the +## null hypothesis that the success probabilities @var{p1} and @var{p2} +## are the same. Under the null, the test statistic @var{z} +## approximately follows a standard normal distribution. ## -## If x1 and n1 are the counts of successes and trials in one sample, -## and x2 and n2 those in a second one, test the null hypothesis that -## the success probabilities p1 and p2 are the same. -## Under the null, the test statistic z approximately follows a -## standard normal distribution. -## -## With the optional argument string alt, the alternative of interest -## can be selected. -## If alt is "!=" or "<>", the null is tested against the two-sided -## alternative p1 != p2. -## If alt is ">", the one-sided alternative p1 > p2 is used, similarly -## for "<". +## With the optional argument string @var{alt}, the alternative of +## interest can be selected. If @var{alt} is @code{"!="} or +## @code{"<>"}, the null is tested against the two-sided alternative +## @var{p1} != @var{p2}. If @var{alt} is @code{">"}, the one-sided +## alternative @var{p1} > @var{p2} is used, similarly for @code{"<"}. ## The default is the two-sided case. ## -## pval is the p-value of the test. +## The p-value of the test is returned in @var{pval}. ## ## If no output argument is given, the p-value of the test is displayed. +## @end deftypefn ## Author: KH <Kurt.Hornik@ci.tuwien.ac.at> ## Description: Compare two proportions
--- a/scripts/statistics/tests/run_test.m +++ b/scripts/statistics/tests/run_test.m @@ -14,13 +14,16 @@ ## along with this file. If not, write to the Free Software Foundation, ## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -## usage: [pval, chisq] = run_test (x) +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{pval}, @var{chisq}] =} run_test (@var{x}) +## Perform a chi-square test with 6 degrees of freedom based on the +## upward runs in the columns of @var{x}. Can be used to test whether +## @var{x} contains independent data. ## -## Performs a chi-square test with 6 degrees of freedom based on the -## upward runs in the columns of x. Can be used to test whether x -## contains independent data. +## The p-value of the test is returned in @var{pval}. ## -## If no output argument is given, the pval is displayed. +## If no output argument is given, the p-value is displayed. +## @end deftypefn ## Author: FL <Friedrich.Leisch@ci.tuwien.ac.at> ## Description: Run test for independence
--- a/scripts/statistics/tests/sign_test.m +++ b/scripts/statistics/tests/sign_test.m @@ -14,24 +14,26 @@ ## along with this file. If not, write to the Free Software Foundation, ## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -## usage: [pval, b, n] = sign_test (x, y [, alt]) -## -## For two matched-pair samples x and y, perform a sign test of the -## null hypothesis PROB(x > y) == PROB(x < y) == 1/2. -## Under the null, the test statistic b roughly follows a binomial -## distribution with parameters n = sum (x != y) and p = 1/2. +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{pval}, @var{b}, @var{n}] =} sign_test (@var{x}, @var{y}, @var{alt}) +## For two matched-pair samples @var{x} and @var{y}, perform a sign test +## of the null hypothesis PROB (@var{x} > @var{y}) == PROB (@var{x} < +## @var{y}) == 1/2. Under the null, the test statistic @var{b} roughly +## follows a binomial distribution with parameters @code{@var{n} = sum +## (@var{x} != @var{y})} and @var{p} = 1/2. ## -## With the optional argument alt, the alternative of interest can be -## selected. -## If alt is "!=" or "<>", the null hypothesis is tested against the -## two-sided alternative PROB(x < y) != 1/2. -## If alt is ">", the one-sided alternative PROB(x > y) > 1/2 ("x is -## stochastically greater than y") is considered, similarly for "<". +## With the optional argument @code{alt}, the alternative of interest +## can be selected. If @var{alt} is @code{"!="} or @code{"<>"}, the +## null hypothesis is tested against the two-sided alternative PROB +## (@var{x} < @var{y}) != 1/2. If @var{alt} is @code{">"}, the +## one-sided alternative PROB (@var{x} > @var{y}) > 1/2 ("x is +## stochastically greater than y") is considered, similarly for @code{"<"}. ## The default is the two-sided case. ## -## pval is the p-value of the test. +## The p-value of the test is returned in @var{pval}. ## ## If no output argument is given, the p-value of the test is displayed. +## @end deftypefn ## Author: KH <Kurt.Hornik@ci.tuwien.ac.at> ## Description: Sign test
--- a/scripts/statistics/tests/t_test.m +++ b/scripts/statistics/tests/t_test.m @@ -14,24 +14,25 @@ ## along with this file. If not, write to the Free Software Foundation, ## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -## usage: [pval, t, df] = t_test (x, m [, alt]) -## -## For a sample x from a normal distribution with unknown mean and -## variance, perform a t-test of the null hypothesis mean(x) == m. -## Under the null, the test statistic t follows a Student distribution -## with df = length (x) - 1 degrees of freedom. +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{pval}, @var{t}, @var{df}] =} t_test (@var{x}, @var{m}, @var{alt}) +## For a sample @var{x} from a normal distribution with unknown mean and +## variance, perform a t-test of the null hypothesis @code{mean +## (@var{x}) == @var{m}}. Under the null, the test statistic @var{t} +## follows a Student distribution with @code{@var{df} = length (@var{x}) +## - 1} degrees of freedom. ## -## With the optional argument string alt, the alternative of interest -## can be selected. -## If alt is "!=" or "<>", the null is tested against the two-sided -## alternative mean(x) != m. -## If alt is ">", the one-sided alternative mean(x) > m is considered, -## similarly for "<". -## The default is the two-sided case. +## With the optional argument string @var{alt}, the alternative of +## interest can be selected. If @var{alt} is @code{"!="} or +## @code{"<>"}, the null is tested against the two-sided alternative +## @code{mean (@var{x}) != @var{m}}. If @var{alt} is @code{">"}, the +## one-sided alternative @code{mean (@var{x}) > @var{m}} is considered, +## similarly for @var{"<"}. The default is the two-sided case. ## -## pval is the p-value of the test. +## The p-value of the test is returned in @var{pval}. ## ## If no output argument is given, the p-value of the test is displayed. +## @end deftypefn ## Author: KH <Kurt.Hornik@ci.tuwien.ac.at> ## Description: Student's one-sample t test
--- a/scripts/statistics/tests/t_test_2.m +++ b/scripts/statistics/tests/t_test_2.m @@ -14,25 +14,25 @@ ## along with this file. If not, write to the Free Software Foundation, ## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -## usage: [pval, t, df] = t_test_2 (x, y [, alt]) -## +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{pval}, @var{t}, @var{df}] =} t_test_2 (@var{x}, @var{y}, @var{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 t follows a Student distribution -## with df degrees of freedom. +## hypothesis of equal means. Under the null, the test statistic +## @var{t} follows a Student distribution with @var{df} degrees of +## freedom. ## -## With the optional argument string alt, the alternative of interest -## can be selected. -## If alt is "!=" 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 default is the two-sided case. +## With the optional argument string @var{alt}, the alternative of +## interest can be selected. If @var{alt} is @code{"!="} or +## @code{"<>"}, the null is tested against the two-sided alternative +## @code{mean (@var{x}) != mean (@var{y})}. If @var{alt} is @code{">"}, +## the one-sided alternative @code{mean (@var{x}) > mean (@var{y})} is +## used. Similarly for @code{"<"}. The default is the two-sided case. ## -## pval is the p-value of the test. +## The p-value of the test is returned in @var{pval}. ## ## If no output argument is given, the p-value of the test is displayed. +## @end deftypefn ## Author: KH <Kurt.Hornik@ci.tuwien.ac.at> ## Description: Student's two-sample t test
--- a/scripts/statistics/tests/t_test_regression.m +++ b/scripts/statistics/tests/t_test_regression.m @@ -14,26 +14,26 @@ ## along with this file. If not, write to the Free Software Foundation, ## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -## usage: [pval, t, df] = t_test_regression (y, X, R [, r] [, alt]) +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{pval}, @var{t}, @var{df}] =} t_test_regression (@var{y}, @var{x}, @var{R}, @var{r}, @var{alt}) +## Perform an t test for the null hypothesis @code{@var{R} * @var{b} = +## @var{r}} in a classical normal regression model @code{@var{y} = +## @var{X} * @var{b} + @var{e}}. Under the null, the test statistic @var{t} +## follows a @var{t} distribution with @var{df} degrees of freedom. ## -## Performs an t test for the null hypothesis R * b = r in a classical -## normal regression model y = X * b + e. -## Under the null, the test statistic t follows a t distribution with -## df degrees of freedom. -## -## r is taken as 0 if not given explicitly. +## If @var{r} is omitted, a value of 0 is assumed. ## -## With the optional argument string alt, the alternative of interest -## can be selected. -## If alt is "!=" or "<>", the null is tested against the two-sided -## alternative R * b != r. -## If alt is ">", the one-sided alternative R * b > r is used, -## similarly for "<". -## The default is the two-sided case. +## With the optional argument string @var{alt}, the alternative of +## interest can be selected. If @var{alt} is @code{"!="} or +## @code{"<>"}, the null is tested against the two-sided alternative +## @code{@var{R} * @var{b} != @var{r}}. If @var{alt} is @code{">"}, the +## one-sided alternative @code{@var{R} * @var{b} > @var{r}} is used. +## Similarly for @var{"<"}. The default is the two-sided case. ## -## pval is the p-value of the test. +## The p-value of the test is returned in @var{pval}. ## ## If no output argument is given, the p-value of the test is displayed. +## @end deftypefn ## Author: KH <Kurt.Hornik@ci.tuwien.ac.at> ## Description: Test one linear hypothesis in linear regression model
--- a/scripts/statistics/tests/u_test.m +++ b/scripts/statistics/tests/u_test.m @@ -14,25 +14,25 @@ ## along with this file. If not, write to the Free Software Foundation, ## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -## usage: [pval, z] = u_test (x, y [, alt]) -## -## For two samples x and y, perform a Mann-Whitney U-test of the null -## hypothesis PROB(x > y) == 1/2 == PROB(x < y). Under the null, the -## test statistic z approximately follows a standard normal -## distribution. Note that this test is equivalent to the Wilcoxon -## rank-sum test. +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{pval}, @var{z}] =} u_test (@var{x}, @var{y}, @var{alt}) +## For two samples @var{x} and @var{y}, perform a Mann-Whitney U-test of +## the null hypothesis PROB (@var{x} > @var{y}) == 1/2 == PROB (@var{x} +## < @var{y}). Under the null, the test statistic @var{z} approximately +## 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. -## If alt is "!=" 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 default is the two-sided case. +## With the optional argument string @var{alt}, the alternative of +## interest can be selected. If @var{alt} is @code{"!="} or +## @code{"<>"}, the null is tested against the two-sided alternative +## PROB (@var{x} > @var{y}) != 1/2. If @var{alt} is @code{">"}, the +## one-sided alternative PROB (@var{x} > @var{y}) > 1/2 is considered, +## similarly for @code{"<"}. The default is the two-sided case. ## -## pval is the p-value of the test. +## The p-value of the test is returned in @var{pval}. ## ## If no output argument is given, the p-value of the test is displayed. +## @end deftypefn ## This implementation is still incomplete---for small sample sizes, ## the normal approximation is rather bad ...
--- a/scripts/statistics/tests/var_test.m +++ b/scripts/statistics/tests/var_test.m @@ -14,25 +14,24 @@ ## along with this file. If not, write to the Free Software Foundation, ## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -## usage: [pval, f, df_num, df_den] = var_test (x, y [, alt]) -## -## For two samples x and y from 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. +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{pval}, @var{f}, @var{df_num}, @var{df_den}] =} var_test (@var{x}, @var{y}, @var{alt}) +## For two samples @var{x} and @var{y} from 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. -## If alt is "!=" or "<>", the null is tested against the two-sided -## alternative var(x) != var(y). -## If alt is ">", the one-sided alternative var(x) > var(y) is used, -## similarly for "<". -## The default is the two-sided case. +## With the optional argument string @var{alt}, the alternative of +## interest can be selected. If @var{alt} is @code{"!="} or +## @code{"<>"}, the null is tested against the two-sided alternative +## @code{var (@var{x}) != var (@var{y})}. If @var{alt} is @code{">"}, +## the one-sided alternative @code{var (@var{x}) > var (@var{y})} is +## used, similarly for "<". The default is the two-sided case. ## -## pval is the p-value of the test. +## The p-value of the test is returned in @var{pval}. ## ## If no output argument is given, the p-value of the test is displayed. +## @end deftypefn ## Author: KH <Kurt.Hornik@ci.tuwien.ac.at> ## Description: F test to compare two variances
--- a/scripts/statistics/tests/welch_test.m +++ b/scripts/statistics/tests/welch_test.m @@ -14,25 +14,25 @@ ## along with this file. If not, write to the Free Software Foundation, ## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -## usage: [pval, t, df] = welch_test (x, y [, alt]) -## -## For two samples x and y from normal distributions with unknown means -## and unknown and not necessarily equal variances, perform a Welch test -## of the null hypothesis of equal means. +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{pval}, @var{t}, @var{df}] =} welch_test (@var{x}, @var{y}, @var{alt}) +## For two samples @var{x} and @var{y} from 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. -## If alt is "!=" or "<>", the null is tested against the two-sided -## alternative mean(x) != m. -## If alt is ">", the one-sided alternative mean(x) > m is considered, -## similarly for "<". -## The default is the two-sided case. +## With the optional argument string @var{alt}, the alternative of +## interest can be selected. If @var{alt} is @code{"!="} or +## @code{"<>"}, the null is tested against the two-sided alternative +## @code{mean (@var{x}) != @var{m}}. If @var{alt} is @code{">"}, the +## one-sided alternative mean(x) > m is considered, similarly for +## @code{"<"}. The default is the two-sided case. ## -## pval is the p-value of the test. +## The p-value of the test is returned in @var{pval}. ## ## If no output argument is given, the p-value of the test is displayed. +## @end deftypefn ## Author: KH <Kurt.Hornik@ci.tuwien.ac.at> ## Description: Welch two-sample t test
--- a/scripts/statistics/tests/wilcoxon_test.m +++ b/scripts/statistics/tests/wilcoxon_test.m @@ -14,24 +14,24 @@ ## along with this file. If not, write to the Free Software Foundation, ## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -## usage: [pval, z] = wilcoxon_test (x, y [, alt]) -## -## For two matched-pair sample vectors x and y, perform a Wilcoxon -## signed-rank test of the null hypothesis PROB(x > y) == 1/2. -## Under the null, the test statistic z approximately follows a -## standard normal distribution. +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{pval}, @var{z}] =} wilcoxon_test (@var{x}, @var{y}, @var{alt}) +## For two matched-pair sample vectors @var{x} and @var{y}, perform a +## Wilcoxon signed-rank test of the null hypothesis PROB (@var{x} > +## @var{y}) == 1/2. Under the null, the test statistic @var{z} +## approximately follows a standard normal distribution. ## -## With the optional argument string alt, the alternative of interest -## can be selected. -## If alt is "!=" 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 default is the two-sided case. +## With the optional argument string @var{alt}, the alternative of +## interest can be selected. If @var{alt} is @code{"!="} or +## @code{"<>"}, the null is tested against the two-sided alternative +## PROB (@var{x} > @var{y}) != 1/2. If alt is @code{">"}, the one-sided +## alternative PROB (@var{x} > @var{y}) > 1/2 is considered, similarly +## for @code{"<"}. The default is the two-sided case. ## -## pval is the p-value of the test. +## The p-value of the test is returned in @var{pval}. ## ## If no output argument is given, the p-value of the test is displayed. +## @end deftypefn ## Author: KH <Kurt.Hornik@ci.tuwien.ac.at> ## Description: Wilcoxon signed-rank test
--- a/scripts/statistics/tests/z_test.m +++ b/scripts/statistics/tests/z_test.m @@ -14,25 +14,25 @@ ## along with this file. If not, write to the Free Software Foundation, ## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -## usage: [pval, z] = z_test (x, m, v [, alt]) -## -## Perform a Z-test of the null hypothesis mean(x) == m for a sample x -## from a normal distribution with unknown mean and known variance v. -## Under the null, the test statistic z follows a standard normal -## distribution. +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{pval}, @var{z}] =} z_test (@var{x}, @var{m}, @var{v}, @var{alt}) +## Perform a Z-test of the null hypothesis @code{mean (@var{x}) == +## @var{m}} for a sample @var{x} from a normal distribution with unknown +## mean and known variance @var{v}. Under the null, the test statistic +## @var{z} follows a standard normal distribution. ## -## With the optional argument string alt, the alternative of interest -## can be selected. -## If alt is "!=" or "<>", the null is tested against the two-sided -## alternative mean(x) != m. -## If alt is ">", the one-sided alternative mean(x) > m is considered, -## similarly for "<". -## The default is the two-sided case. +## With the optional argument string @var{alt}, the alternative of +## interest can be selected. If @var{alt} is @code{"!="} or +## @code{"<>"}, the null is tested against the two-sided alternative +## @code{mean (@var{x}) != @var{m}}. If @var{alt} is @code{">"}, the +## one-sided alternative @code{mean (@var{x}) > @var{m}} is considered, +## similarly for @code{"<"}. The default is the two-sided case. ## -## pval is the p-value of the test. +## The p-value of the test is returned in @var{pval}. ## ## If no output argument is given, the p-value of the test is displayed ## along with some information. +## @end deftypefn ## Author: KH <Kurt.Hornik@ci.tuwien.ac.at> ## Description: Test for mean of a normal sample with known variance
--- a/scripts/statistics/tests/z_test_2.m +++ b/scripts/statistics/tests/z_test_2.m @@ -14,26 +14,25 @@ ## along with this file. If not, write to the Free Software Foundation, ## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -## usage: [pval, z] = z_test_2 (x, y, v_x, v_y [, alt]) -## -## For two samples x and y from normal distributions with unknown -## means and known variances v_x and v_y, perform a Z-test of the -## hypothesis of equal means. -## Under the null, the test statistic z follows a standard normal -## distribution. +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{pval}, @var{z}] =} z_test_2 (@var{x}, @var{y}, @var{v_x}, @var{v_y}, @var{alt}) +## For two samples @var{x} and @var{y} from normal distributions with +## unknown means and known variances @var{v_x} and @var{v_y}, perform a +## Z-test of the hypothesis of equal means. Under the null, the test +## statistic @var{z} follows a standard normal distribution. ## -## With the optional argument string alt, the alternative of interest -## can be selected. -## If alt is "!=" 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 default is the two-sided case. +## With the optional argument string @var{alt}, the alternative of +## interest can be selected. If @var{alt} is @code{"!="} or +## @code{"<>"}, the null is tested against the two-sided alternative +## @code{mean (@var{x}) != mean (@var{y})}. If alt is @code{">"}, the +## one-sided alternative @code{mean (@var{x}) > mean (@var{y})} is used, +## similarly for @code{"<"}. The default is the two-sided case. ## -## pval is the p-value of the test. +## The p-value of the test is returned in @var{pval}. ## ## If no output argument is given, the p-value of the test is displayed ## along with some information. +## @end deftypefn ## Author: KH <Kurt.Hornik@ci.tuwien.ac.at> ## Description: Compare means of two normal samples with known variances