| 1 | package Statistics::DependantTTest; | ||||||||||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 1 | ▶ | use Carp; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 1 | ▶ | use vars qw($VERSION); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 1 | ▶ | use Statistics::PointEstimation; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 1 | ▶ | no strict 'refs'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 1 | $VERSION='0.03'; | |||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | ############## | ||||||||||||||||||||
| 10 | sub new | ||||||||||||||||||||
| 11 | 1 | ▶ | { | ||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||
| 12 | 1 | my $proto = shift; | |||||||||||||||||||
| 13 | 1 | ▶ | my $class = ref($proto) || $proto; | ||||||||||||||||||
|
Condition33%1/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||
| 14 | 1 | my $self= {}; | |||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 1 | $self->{sample_data} = undef; | |||||||||||||||||||
| 17 | 1 | $self->{s} = undef; | |||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | 1 | bless($self,$class); | |||||||||||||||||||
| 22 | 1 | return $self; | |||||||||||||||||||
| 23 | } | ||||||||||||||||||||
| 24 | ############## | ||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | ############## | ||||||||||||||||||||
| 27 | 2 | ▶ | sub load_data { | ||||||||||||||||||
|
Subroutine
load_data: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 28 | 2 | my $self = shift; | |||||||||||||||||||
| 29 | 2 | my $sample_name = shift; | |||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | 2 | my (@sample_data)=@_; | |||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | 2 | my $s= new Statistics::PointEstimation; | |||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | 2 | $s->add_data(\@sample_data); | |||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | 2 | $self->{sample_data}->{$sample_name}=\@sample_data; | |||||||||||||||||||
| 38 | 2 | $self->{s}->{$sample_name}=$s; | |||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | 2 | return $self; | |||||||||||||||||||
| 41 | } # end sub load_data | ||||||||||||||||||||
| 42 | ############## | ||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | ############## | ||||||||||||||||||||
| 45 | 1 | ▶ | sub perform_t_test { | ||||||||||||||||||
|
Subroutine
perform_t_test: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||
| 46 | 1 | my $self=shift; | |||||||||||||||||||
| 47 | 1 | my $first_sample_name = shift; | |||||||||||||||||||
| 48 | 1 | my $second_sample_name = shift; | |||||||||||||||||||
| 49 | 1 | my $s1=$self->{s}->{$first_sample_name}; | |||||||||||||||||||
| 50 | 1 | my $s2=$self->{s}->{$second_sample_name}; | |||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | 1 | ▶ | if(@{$self->{sample_data}->{$first_sample_name}} != @{$self->{sample_data}->{$second_sample_name}}) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 54 | { | ||||||||||||||||||||
| 55 | 0 | croak "The two results sets are of different length.\n For the paired T-test, the two results must be from two identical sets of subjects tested in a reference and test condition.\n"; | |||||||||||||||||||
| 56 | } | ||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | 1 | my $s = new Statistics::PointEstimation; | |||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | 1 | my @sample_difference; | |||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | 1 | my $count=0; | |||||||||||||||||||
| 63 | 1 | ▶ | while ($count < @{$self->{sample_data}->{$first_sample_name}}) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 64 | { | ||||||||||||||||||||
| 65 | 5 | $sample_difference[$count] = ${$self->{sample_data}->{$first_sample_name}}[$count] - ${$self->{sample_data}->{$second_sample_name}}[$count]; | |||||||||||||||||||
| 66 | 5 | $count++; | |||||||||||||||||||
| 67 | } # end while | ||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | 1 | $s->add_data(\@sample_difference); | |||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | 1 | my $t_value = $s->t_statistic(); | |||||||||||||||||||
| 72 | |||||||||||||||||||||
| 73 | 1 | my $deg_freedom = scalar @{$self->{sample_data}->{$first_sample_name}} - 1; | |||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | 1 | return ($t_value, $deg_freedom ); | |||||||||||||||||||
| 76 | } # end sub perform_t_test | ||||||||||||||||||||
| 77 | ############## | ||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | |||||||||||||||||||||
| 80 | 1 | 1; | |||||||||||||||||||
| 81 | __END__ | ||||||||||||||||||||