Statistics::ChisqIndep

Statistics::ChisqIndep is a Perl module to perform chi-square test of independence (a.k.a. contingency tables).
Download

Statistics::ChisqIndep Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Yun-Fang Juan , Yahoo! Inc.
  • Publisher web site:
  • http://search.cpan.org/~yunfang/Statistics-ChisqIndep-0.1/ChisqIndep.pm

Statistics::ChisqIndep Tags


Statistics::ChisqIndep Description

Statistics::ChisqIndep is a Perl module to perform chi-square test of independence (a.k.a. contingency tables). Statistics::ChisqIndep is a Perl module to perform chi-square test of independence (a.k.a. contingency tables).Synopsis #example for Statistics::ChisqIndep use strict; use Statistics::ChisqIndep; use POSIX; # input data in the form of the array of array references my @obs = (, ); my $chi = new Statistics::ChisqIndep; $chi->load_data(@obs); # print the summary data along with the contingency table $chi->print_summary(); #print the contingency table only $chi->print_contingency_table(); #the following output is the same as calling the function of print_summary #all of the detailed info such as the expected values, degree of freedoms #and totals are accessible as object globals #check if the load_data() call is successful if($chi->{valid}) { print "Rows: ", $chi->{rows}, "n"; print "Columns: ", $chi->{cols}, "n"; print "Degree of Freedom: ", $chi->{df}, "n"; print "Total Count: ", $chi->{total}, "n"; print "Chi-square Statistic: ", $chi->{chisq_statistic}, "n"; print "p-value: ", $chi->{p_value}, "n"; print "Warning: some of the cell counts might be too low.n" if ($chi->{warning}); #output the contingency table my $rows = $chi->{rows}; # # rows my $cols = $chi->{cols}; # # columns my $obs = $chi->{obs}; # observed values my $exp = $chi->{expected}; # expected values my $rtotals = $chi->{rtotals}; # row totals my $ctotals = $chi->{ctotals}; #column totals my $total = $chi->{total}; # total counts for (my $j = 0; $j < $cols; $j++) { print "t",$j + 1; } print "trtotaln"; for (my $i = 0; $i < $rows; $i ++) { print $i + 1, "t"; for(my $j = 0 ; $j < $cols; $j ++) { #observed values can be accessed #in the following way print $obs->->, "t"; } #row totals can be accessed # in the following way print $rtotals->, "n"; print "t"; for(my $j = 0 ; $j < $cols; $j ++) { #expected values can be accessed #in the following way printf "(%.2f)t", $exp->->; } print "n"; } print "ctotalt"; for (my $j = 0; $j < $cols; $j++) { #column totals can be accessed in the following way print $ctotals->, "t"; } #output total counts print $total, "n"; }This is the module to perform the Pearson's Chi-squared test on contingency tables of 2 dimensions. The users input the observed values in the table form and the module will compute the expected values for each cell based on the independence hypothesis. The module will then compute the chi-square statistic and the corresponding p-value based on the observed and the expected values to test if the 2 dimensions are truly independent.Requirements:· Perl Requirements: · Perl


Statistics::ChisqIndep Related Software