Hi! I am trying to use the Perl module on t-test in a subroutine for working on my genetics data sets (not class work though) and am not able to direct the output to the OUTFILE. it prints to the console.
Here are my two arrays and here is how i am calling the subroutine from within the program. also i have included the subroutine that i am using.
print FILEW2 &t_test(@C, @B), "\n";
sub t_test{
my (@C) = @_;
my (@B) = @_;
my ($result);
my ($ttest);
use Statistics:ointEstimation;
use Statistics::TTest;
$ttest = new Statistics::TTest;
$ttest->set_significance(90);
$ttest->load_data(\@C,\@B);
$ttest->output_t_test();
$ttest->set_significance(99);
$ttest->print_t_test(); #list out t-test related data
#the following thes same as calling output_t_test()
my $s1=$ttest->{s1}; #sample 1 a Statistics:ointEstimation object
my $s2=$ttest->{s2}; #sample 2 a Statistics:ointEstimation object
print "*****************************************************\n\n";
$s1->output_confidence_interval('1');
$s2->output_confidence_interval('2');
print "\t F-statistic=",$ttest->f_statistic()," , cutoff F-statistic=",$ttest->f_cutoff(),
" with alpha level=",$ttest->alpha*2," and df =(",$ttest->df1,",",$ttest->df2,")\t";
if($ttest->{equal_variance})
{ print "\tequal variance assumption is accepted(not rejected) since F-statistic < cutoff F-statistic\t";}
else
{ print "\tequal variance assumption is rejected since F-statistic > cutoff F-statistic\t";}
print "\tdegree of freedom=",$ttest->df," , t-statistic=T=",$ttest->t_statistic," Prob >|T|=",$ttest->{t_prob},"\t";
print "\tthe null hypothesis (the 2 samples have the same mean) is ",$ttest->null_hypothesis(),
" since the alpha level is ",$ttest->alpha()*2,"\t";
print "\there difference of the mean=",$ttest->mean_difference(),", standard error=",$ttest->standard_error(),"\t";
print "\t the estimate of the difference of the mean is ", $ttest->mean_difference()," +/- ",$ttest->delta(),"\t",
" or (",$ttest->lower_clm()," to ",$ttest->upper_clm," ) with ",$ttest->significance," % of confidence\n";
print "*****************************************************\n\n";
}
Any help is appreciated.
Thanks!
Here are my two arrays and here is how i am calling the subroutine from within the program. also i have included the subroutine that i am using.
print FILEW2 &t_test(@C, @B), "\n";
sub t_test{
my (@C) = @_;
my (@B) = @_;
my ($result);
my ($ttest);
use Statistics:ointEstimation;
use Statistics::TTest;
$ttest = new Statistics::TTest;
$ttest->set_significance(90);
$ttest->load_data(\@C,\@B);
$ttest->output_t_test();
$ttest->set_significance(99);
$ttest->print_t_test(); #list out t-test related data
#the following thes same as calling output_t_test()
my $s1=$ttest->{s1}; #sample 1 a Statistics:ointEstimation object
my $s2=$ttest->{s2}; #sample 2 a Statistics:ointEstimation object
print "*****************************************************\n\n";
$s1->output_confidence_interval('1');
$s2->output_confidence_interval('2');
print "\t F-statistic=",$ttest->f_statistic()," , cutoff F-statistic=",$ttest->f_cutoff(),
" with alpha level=",$ttest->alpha*2," and df =(",$ttest->df1,",",$ttest->df2,")\t";
if($ttest->{equal_variance})
{ print "\tequal variance assumption is accepted(not rejected) since F-statistic < cutoff F-statistic\t";}
else
{ print "\tequal variance assumption is rejected since F-statistic > cutoff F-statistic\t";}
print "\tdegree of freedom=",$ttest->df," , t-statistic=T=",$ttest->t_statistic," Prob >|T|=",$ttest->{t_prob},"\t";
print "\tthe null hypothesis (the 2 samples have the same mean) is ",$ttest->null_hypothesis(),
" since the alpha level is ",$ttest->alpha()*2,"\t";
print "\there difference of the mean=",$ttest->mean_difference(),", standard error=",$ttest->standard_error(),"\t";
print "\t the estimate of the difference of the mean is ", $ttest->mean_difference()," +/- ",$ttest->delta(),"\t",
" or (",$ttest->lower_clm()," to ",$ttest->upper_clm," ) with ",$ttest->significance," % of confidence\n";
print "*****************************************************\n\n";
}
Any help is appreciated.
Thanks!