| Summary | Package variables | Description | General documentation | Methods |
Rcmd::Normality - Interfaces to tests of normality of R language.
This class is a part of G-language Genome Analysis Environment,
collecting interfaces to tests of normality of R language.
| normtest | Description | Code |
| normtest() | code | next | Top |
Name: normtest() - performs test for normality
Description:
Performs test for normality of the given vector, using
Anderson-Darling test, Kolmogorov-Smirnov Lilliefors test,
or Shapiro-Wilk test.
Anderson-Darling test gives more weight to the tails
of the distribution than Kolmogorov-Smirnov Lilliefors test
or Shapiro-Wilk test.
Kolmogorov-Smirnov Lilliefors test is one of the most widely
used methods for the test of normality, but is known to
perform worse than Anderson-Darling test or Shapiro-Wilk test.
Shapiro-Wilk test is limited to samples less than 5000.
Installation of nortest library for R language is required.
run R as a super user - sudo R - and type the following:
install.packages('nortest'))
Usage:
($statistic, $pvalue) = normtest(@data);
or
($statistic, $pvalue) = normtest(-sampledata=>1);
Options:
-method name of the test
"ad" for Anderson-Darling
"ks" for Kolmogorov-Smirnov Lilliefors (default)
"sw" for Shapiro-Wilk
-sampledata use sample data (default: 0)
References:
Thode Jr., H.C. (2002) Testing for Normality, Marcel Dekker, NewYork
Author:
Kazuharu Arakawa (gaou@sfc.keio.ac.jp) |
| normtest | description | prev | next | Top |
my $rcmd = new Rcmd(); $rcmd->set_mode('tmp'); opt_default(method=>"ks", sampledata=>0); my @args = opt_get(@_); my $sampledata = opt_val("sampledata"); my $method = opt_val("method"); if($sampledata){ $rcmd->exec( 'rnormality<-rnorm(100,mean=5,sd=3)' ); }else{ $rcmd->array('rnormality', @args); if(scalar(@args) > 5000 && $method eq 'sw'){ carp("Shapiro-Wilk test cannot handle samples >5000.\nUsing Kolmogorov-Smirnov Lilliefors instead.\n"); $method = "ks"; } } unless($method eq 'sw'){ my @all_pkg_list= _installed_R_packages(); unless (grep { $_ eq 'nortest' } @all_pkg_list) { warn 'Please install below R package : nortest', "\n"; return -1; } } my @result; if($method eq 'sw'){ @result = $rcmd->exec( 'result = shapiro.test(rnormality)', 'c(as.vector(result$statistic), result$p.value)' ); }elsif($method eq 'ad'){ @result = $rcmd->exec( 'require(nortest)', 'result = ad.test(rnormality)', 'c(as.vector(result$statistic), result$p.value)' ); }else{ unless($method eq 'ks'){ carp("Unknown method specified.\nUsing Kolmogorov-Smirnov Lillifors instead.\n"); } @result = $rcmd->exec( 'require(nortest)', 'result = lillie.test(rnormality)', 'c(as.vector(result$statistic), result$p.value)' ); } return @result;}