PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_nonpar_test_sign (g08aa)
Purpose
nag_nonpar_test_sign (g08aa) performs the Sign test on two related samples of size .
Syntax
Description
The Sign test investigates the median difference between pairs of scores from two matched samples of size , denoted by , for . The hypothesis under test, , often called the null hypothesis, is that the medians are the same, and this is to be tested against a one- or two-sided alternative (see below).
nag_nonpar_test_sign (g08aa) computes:
(a) |
the test statistic , which is the number of pairs for which ; |
(b) |
the number of non-tied pairs ; |
(c) |
the lower tail probability corresponding to (adjusted to allow the complement to be used in an upper one tailed or a two tailed test). is the probability of observing a value if , or of observing a value if , given that is true. If , is set to . |
Suppose that a significance test of a chosen size
is to be performed (i.e.,
is the probability of rejecting
when
is true; typically
is a small quantity such as
or
). The returned value of
can be used to perform a significance test on the median difference, against various alternative hypotheses
, as follows
(i) |
: median of median of . is rejected if . |
(ii) |
: median of median of . is rejected if . |
(iii) |
: median of median of . is rejected if . |
References
Siegel S (1956) Non-parametric Statistics for the Behavioral Sciences McGraw–Hill
Parameters
Compulsory Input Parameters
- 1:
– double array
- 2:
– double array
-
and must be set to the th pair of data values, , for .
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the dimension of the arrays
x,
y. (An error is raised if these dimensions are not equal.)
, the size of each sample.
Constraint:
.
Output Parameters
- 1:
– int64int32nag_int scalar
-
The Sign test statistic, .
- 2:
– int64int32nag_int scalar
-
The number of non-tied pairs, .
- 3:
– double scalar
-
The lower tail probability, , corresponding to .
- 4:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
-
-
-
-
, i.e., the samples are identical.
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
Accuracy
The tail probability,
, is computed using the relationship between the binomial and beta distributions. For
,
should be accurate to at least
significant figures, assuming that the machine has a precision of
or more digits. For
,
should be computed with an absolute error of less than
. For further details see
nag_stat_prob_beta (g01ee).
Further Comments
The time taken by nag_nonpar_test_sign (g08aa) is small, and increases with .
Example
This example is taken from page 69 of
Siegel (1956). The data relates to ratings of ‘insight into paternal discipline’ for
sets of parents, recorded on a scale from
to
.
Open in the MATLAB editor:
g08aa_example
function g08aa_example
fprintf('g08aa example results\n\n');
x = [4; 4; 5; 5; 3; 2; 5; 3; 1; 5; 5; 5; 4; 5; 5; 5; 5];
y = [2; 3; 3; 3; 3; 3; 3; 3; 2; 3; 2; 2; 5; 2; 5; 3; 1];
fprintf('Sign test\n\n')
fprintf('Data values\n\n');
fprintf('%3.0f',x);
fprintf('\n')
fprintf('%3.0f',y);
fprintf('\n\n')
[isgn, n1, p, ifail] = g08aa( ...
x, y);
fprintf('Test statistic %5d\n', isgn);
fprintf('Observations %5d\n', n1);
fprintf('Lower tail prob. %5.3f\n', p);
g08aa example results
Sign test
Data values
4 4 5 5 3 2 5 3 1 5 5 5 4 5 5 5 5
2 3 3 3 3 3 3 3 2 3 2 2 5 2 5 3 1
Test statistic 3
Observations 14
Lower tail prob. 0.029
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015