Print objects of class "htest" or "htestEnvStats", respectively, by simple print methods.

The functions print.htest and print.htestEnvStats are identical, and are a modification of the R function print.htest.

The function print.htestEnvStats formats and prints the results of performing a hypothesis test that was performed using one of the functions listed in the help file for htestEnvStats.object. This method is automatically called by the EnvStats generic function print when given an object of class "htestEnvStats".

The function print.htest formats and prints the results of performing a hypothesis test that was performed using a function that returns an object of class "htest". Because of the design of R, the EnvStats method print.htest is NOT automatically called when the user types a command at the command prompt that returns an object of class "htest". Instead, the EnvStats print function must be explicitly called to invoke print.htest. See the EXAMPLES section below.

# S3 method for class 'htest'
print(x, ...)
  # S3 method for class 'htestEnvStats'
print(x, ...)

Arguments

x

an object of class "htest" or "htestEnvStats". See htest.object and
htestEnvStats.object for details.

...

arguments that can be supplied to the format function.

Details

The function print.htest is the "htest" method for the EnvStats generic function print, and the function print.htestEnvStats is the "htestEnvStats" method for the EnvStats generic function print. These functions print null and alternative hypotheses, name of the test, estimated population parameter(s) involved in the null hypothesis, estimation method (if present), data name, sample size (if present), number of missing observations removed prior to performing the test (if present), value of the test statistic, parameters associated with the null distribution of the test statistic, p-value associated with the test statistic, and confidence interval for the population parameter (if present).

Value

Invisibly returns the input x.

References

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

Author

Steven P. Millard (EnvStats@ProbStatInfo.com)

Examples

  # Create an object of class "htestEnvStats", then print it out. 
  #--------------------------------------------------------------
  htestEnvStats.obj <- chenTTest(EPA.02d.Ex.9.mg.per.L.vec, mu = 30)

  mode(htestEnvStats.obj) 
#> [1] "list"
  #[1] "list" 

  class(htestEnvStats.obj) 
#> [1] "htestEnvStats"
  #[1] "htestEnvStats" 

  names(htestEnvStats.obj) 
#>  [1] "statistic"   "parameters"  "p.value"     "estimate"    "null.value" 
#>  [6] "alternative" "method"      "sample.size" "data.name"   "bad.obs"    
#> [11] "interval"   
  # [1] "statistic"   "parameters"  "p.value"     "estimate"   
  # [5] "null.value"  "alternative" "method"      "sample.size"
  # [9] "data.name"   "bad.obs"     "interval" 
 
  htestEnvStats.obj 
#> $statistic
#>        t 
#> 1.574075 
#> 
#> $parameters
#> df 
#> 59 
#> 
#> $p.value
#>               z               t Avg. of z and t 
#>      0.05773508      0.06040889      0.05907199 
#> 
#> $estimate
#>      mean        sd      skew 
#> 34.566667 27.330598  2.365778 
#> 
#> $null.value
#> mean 
#>   30 
#> 
#> $alternative
#> [1] "greater"
#> 
#> $method
#> [1] "One-sample t-Test\n                                 Modified for\n                                 Positively-Skewed Distributions\n                                 (Chen, 1995)"
#> 
#> $sample.size
#> [1] 60
#> 
#> $data.name
#> [1] "EPA.02d.Ex.9.mg.per.L.vec"
#> 
#> $bad.obs
#> [1] 0
#> 
#> $interval
#> $name
#> [1] "Confidence"
#> 
#> $parameter
#> [1] "mean"
#> 
#> $limits
#>   LCL   UCL 
#> 29.82   Inf 
#> 
#> $type
#> [1] "Lower"
#> 
#> $method
#> [1] "Based on z"
#> 
#> $conf.level
#> [1] 0.95
#> 
#> $sample.size
#> [1] 60
#> 
#> $dof
#> [1] 59
#> 
#> attr(,"class")
#> [1] "intervalEstimate"
#> 
#> attr(,"class")
#> [1] "htestEnvStats"
  
  #Results of Hypothesis Test
  #--------------------------
  #
  #Null Hypothesis:                 mean = 30
  #
  #Alternative Hypothesis:          True mean is greater than 30
  #
  #Test Name:                       One-sample t-Test
  #                                 Modified for
  #                                 Positively-Skewed Distributions
  #                                 (Chen, 1995)
  #
  #Estimated Parameter(s):          mean = 34.566667
  #                                 sd   = 27.330598
  #                                 skew =  2.365778
  #
  #Data:                            EPA.02d.Ex.9.mg.per.L.vec
  #
  #Sample Size:                     60
  #
  #Test Statistic:                  t = 1.574075
  #
  #Test Statistic Parameter:        df = 59
  #
  #P-values:                        z               = 0.05773508
  #                                 t               = 0.06040889
  #                                 Avg. of z and t = 0.05907199
  #
  #Confidence Interval for:         mean
  #
  #Confidence Interval Method:      Based on z
  #
  #Confidence Interval Type:        Lower
  #
  #Confidence Level:                95%
  #
  #Confidence Interval:             LCL = 29.82
  #                                 UCL =   Inf

  #============================================================================

  # Now create an object of class "htest" and note the difference in how it is 
  # printed out depending on whether or not you explicitly use the print() command.
  #--------------------------------------------------------------------------------

  htest.obj <- t.test(EPA.02d.Ex.9.mg.per.L.vec, mu = 30, alternative = "greater")

  class(htest.obj) 
#> [1] "htest"
  #[1] "htest" 

  names(htest.obj) 
#>  [1] "statistic"   "parameter"   "p.value"     "conf.int"    "estimate"   
#>  [6] "null.value"  "stderr"      "alternative" "method"      "data.name"  
  # [1] "statistic"   "parameter"   "p.value"     "conf.int"    "estimate"   
  # [6] "null.value"  "stderr"      "alternative" "method"      "data.name"

  htest.obj
#> 
#> 	One Sample t-test
#> 
#> data:  EPA.02d.Ex.9.mg.per.L.vec
#> t = 1.2943, df = 59, p-value = 0.1003
#> alternative hypothesis: true mean is greater than 30
#> 95 percent confidence interval:
#>  28.67044      Inf
#> sample estimates:
#> mean of x 
#>  34.56667 
#> 

  #        One Sample t-test
  #
  #data:  EPA.02d.Ex.9.mg.per.L.vec
  #t = 1.2943, df = 59, p-value = 0.1003
  #alternative hypothesis: true mean is greater than 30
  #95 percent confidence interval:
  # 28.67044      Inf
  #sample estimates:
  #mean of x 
  # 34.56667

  print(htest.obj)
#> 
#> Results of Hypothesis Test
#> --------------------------
#> 
#> Null Hypothesis:                 mean = 30
#> 
#> Alternative Hypothesis:          True mean is greater than 30
#> 
#> Test Name:                       One Sample t-test
#> 
#> Estimated Parameter(s):          mean of x = 34.56667
#> 
#> Data:                            EPA.02d.Ex.9.mg.per.L.vec
#> 
#> Test Statistic:                  t = 1.294273
#> 
#> Test Statistic Parameter:        df = 59
#> 
#> P-value:                         0.1003072
#> 
#> 95% Confidence Interval:         LCL = 28.67044
#>                                  UCL =      Inf
#> 

  #Results of Hypothesis Test
  #--------------------------
  #
  #Null Hypothesis:                 mean = 30
  #
  #Alternative Hypothesis:          True mean is greater than 30
  #
  #Test Name:                       One Sample t-test
  #
  #Estimated Parameter(s):          mean of x = 34.56667
  #
  #Data:                            EPA.02d.Ex.9.mg.per.L.vec
  #
  #Test Statistic:                  t = 1.294273
  #
  #Test Statistic Parameter:        df = 59
  #
  #P-value:                         0.1003072
  #
  #95% Confidence Interval:         LCL = 28.67044
  #                                 UCL =      Inf

  #==========

  # Clean up
  #---------
  rm(htestEnvStats.obj, htest.obj)