plot.permutationTest {EnvStats}R Documentation

Plot Results of Permutation Test

Description

Plot the results of calling functions that return an object of class "permutationTest". Currently, the EnvStats functions that perform permutation tests and produce objects of class
"permutationTest" are: oneSamplePermutationTest, twoSamplePermutationTestLocation, and
twoSamplePermutationTestProportion.

The function plot.permutationTest is automatically called by plot when given an object of class "permutationTest".

Usage

## S3 method for class 'permutationTest'
plot(x, hist.col = "cyan", stat.col = "black", 
  stat.lwd = 3 * par("cex"), stat.lty = 1, cex.main = par("cex"), 
  digits = .Options$digits, main = NULL, xlab = NULL, ylab = NULL, 
  xlim = NULL, ylim = NULL, ...) 

Arguments

x

an object of class "permutationTest". See permutationTest.object for details.

hist.col

a character string or numeric scalar determining the color of the histogram used to display the permutation distribution. The default value is hist.col="cyan". See the entry for col in the R help file for par for more information.

stat.col

a character string or numeric scalar determining the color of the line indicating the value of the observed test statistic. The default value is stat.col="black". See the entry for col in the R help file for par for more information.

stat.lwd

numeric scalar determining the width of the line indicating the value of the observed test statistic. The default value is stat.lwd=3*par("cex"). See the entry for lwd in the R help file for par for more information.

stat.lty

numeric scalar determining the line type used to display the value of the observed test statistic. The default value is stat.lty=1. See the entry for lty in the R help file for par for more information.

digits

scalar indicating how many significant digits to print for the distribution parameters. The default value is .Options$digits (i.e., the current setting of options("digits")).

cex.main, main, xlab, ylab, xlim, ylim, ...

graphics parameters. See the help file for par.

Details

Produces a plot displaying the permutation distribution (exact=TRUE) or a sample of the permutation distribution (exact=FALSE), and a line indicating the observed value of the test statistic. The title in the plot includes information on the data used, null hypothesis, and p-value.

The function plot.permutationTest is a method for the generic function plot for the class "permutationTest" (see permutationTest.object). It can be invoked by calling plot and giving it an object of class "permutationTest" as the first argument, or by calling
plot.permutationTest directly, regardless of the class of the object given as the first argument to plot.permutationTest.

Value

plot.permutationTest invisibly returns the first argument, x.

Author(s)

Steven P. Millard (EnvStats@ProbStatInfo.com)

References

Chambers, J. M. and Hastie, T. J. (1992). Statistical Models in S. Wadsworth & Brooks/Cole.

See Also

permutationTest.object, print.permutationTest, oneSamplePermutationTest,
twoSamplePermutationTestLocation, twoSamplePermutationTestProportion, Hypothesis Tests, plot.

Examples

  # Create an object of class "permutationTest", then print it and plot it.
  # (Note:  the call to set.seed() allows you to reproduce this example.) 
  #------------------------------------------------------------------------

  set.seed(23) 

  dat <- rlogis(10, location = 7, scale = 2) 

  permutationTest.obj <- oneSamplePermutationTest(dat, mu = 5, 
    alternative = "greater", exact = TRUE) 

  mode(permutationTest.obj) 
  #[1] "list" 

  class(permutationTest.obj) 
  #[1] "permutationTest" 

  names(permutationTest.obj) 
  # [1] "statistic"         "parameters"        "p.value"          
  # [4] "estimate"          "null.value"        "alternative"      
  # [7] "method"            "estimation.method" "sample.size"      
  #[10] "data.name"         "bad.obs"           "stat.dist"        
  #[13] "exact" 

  #==========

  # Print the results of the test 
  #------------------------------
  permutationTest.obj 

  #Results of Hypothesis Test
  #--------------------------
  #
  #Null Hypothesis:                 Mean (Median) = 5
  #
  #Alternative Hypothesis:          True Mean (Median) is greater than 5
  #
  #Test Name:                       One-Sample Permutation Test
  #                                 (Exact)
  #
  #Estimated Parameter(s):          Mean = 9.977294
  #
  #Data:                            dat
  #
  #Sample Size:                     10
  #
  #Test Statistic:                  Sum(x - 5) = 49.77294
  #
  #P-value:                         0.001953125

  #==========

  # Plot the results of the test 
  #-----------------------------
  dev.new()
  plot(permutationTest.obj)

  #==========

  # Extract the test statistic
  #---------------------------

  permutationTest.obj$statistic
  #Sum(x - 5) 
  #  49.77294

  #==========

  # Clean up
  #---------
  rm(permutationTest.obj)
  graphics.off()

[Package EnvStats version 2.8.1 Index]