NAME
Statistics::Runs - The Runs-test (Wald-Walfowitz or Swed-Eisenhard Test).
VERSION
This is documentation for version 0.01 of Statistics::Sequences::Runs, released 31 July 2006.
SYNOPSIS
use Statistics::Sequences::Runs;
$runs = Statistics::Sequences::Runs->new();
$runs->load(qw/1 0 0 0 1 1 0 1 1 0 0 1 0 0 1 1 1 1 0 1/);
$runs->test()->dump();
DESCRIPTION
The Runs-test nonparametrically assesses the difference between two independent samples, or a difference within a single sample of dichotomous observations.
A run is a sequence of identical events on 1 or more consecutive trials. For example, in a signal-detection test, there'll be a series, over time, of hits (H) and misses (M), which might look like H-H-M-H-M-M-M-M-H. Here, there are 5 runs: 3 of hits, and 2 of misses. This number of runs can be compared with the number expected to occur by chance, given the number of observed hits and misses. More runs than expected generally indicates irregularity, or instability; fewer runs than expected indicates regularity, or stability.
METHODS
Methods are essentially as described in Statistics::Sequences. See this manpage for how to handle non-dichotomous data, e.g., numerical data, or those with more than two categories; the relevant methods are not described here.
new
$run = Statistics::Sequences::Runs->new();
Returns a new Runs object. Expects/accepts no arguments but the classname.
load
$runs->load(@data);
$runs->load(\@data);
$runs->load('sample1' => \@data1, 'sample2' => \@data2)
$runs->load({'sample1' => \@data1, 'sample2' => \@data2})
Loads data anonymously or by name. See load in the Statistics::Sequences manpage.
test
$runs->test();
Performs the runs test on the named samples. If only one sample name is given, the one-sample Runs test is performed, cutting the data at the median, or by the value given as cut. Observations that fall above and below the cut-point then constitute the "groups" to be searched for runs. Otherwise, with two named groups, runs are sought on the basis of the observations belonging to one or the other named group.
dump
$runs->dump(data => '1|0', flag => '1|0', text => '0|1|2');
Print Runs-test results to STDOUT. See dump in the Statistics::Sequences manpage for details.
EXAMPLE
ESP runs
In a run of a classic ESP test, there are 25 trials where the responses are either hits (1) or misses (0) with respect to randomly selected targets, which can be any of 5 events (typically, geometric figures). Classic studies test the significance of the number of hits versus what is theoretically expected (usually, 5 hits in 25). Here we test the significance of the number of runs of hits (and misses) given the number actually produced, firstly by dichotomising the data (which are based on 5, not the required 2, categories).
use Statistics::Sequences::Runs;
# Produce pseudo targets and responses:
my ($i, @targets, @responses);
for ($i = 0; $i < 25; $i++) {
$targets[$i] = (qw/circle plus square star wave/)[int(rand(5))];
$responses[$i] = (qw/circle plus square star wave/)[int(rand(5))];
}
# Do the run thing:
my $runs = Statistics::Sequences::Runs->new();
$runs->load(targets => \@targets, responses => \@responses);
$runs->match(data => [qw/targets responses/]);
$runs->test();
print "The probability of obtaining these $runs->{'observed'} runs is $runs->{'p_value'}\n";
# But what if the responses were actually guessed for the target on the trial one ahead?
$runs->match(data => [qw/targets responses/], lag => 1)->test();
print "With precognitive responses to the target for the next trial,\n
$runs->{'observed'} runs in 24 trials were produced when $runs->{'expected'} were expected,\n
for which the probability is $runs->{'p_value'}\n";
SEE ALSO
Statistics::Sequences for other tests of sequences, and for sharing data between these tests.
AUTHOR/LICENSE
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Copyright (C) 2006 Roderick Garton This module may be modified, used, copied, and redistributed at your own risk. Publicly redistributed modified versions must use a different name.
DISCLAIMER
To the maximum extent permitted by applicable law, the author of this module disclaims all warranties, either express or implied, including but not limited to implied warranties of merchantability and fitness for a particular purpose, with regard to the software and the accompanying documentation.