This class of objects is returned by functions that perform hypothesis tests (e.g., the R function t.test, the EnvStats function kendallSeasonalTrendTest, etc.). Objects of class "htest" are lists that contain information about the null and alternative hypotheses, the estimated distribution parameters, the test statistic, the p-value, and (optionally) confidence intervals for distribution parameters.

Details

Objects of S3 class "htest" are returned by any of the EnvStats functions that perform hypothesis tests as listed here: Hypothesis Tests.

(Note that functions that perform goodness-of-fit tests return objects of class "gof" or
"gofTwoSample".)

Objects of class "htest" generated by EnvStats functions may contain additional components called estimation.method (method used to estimate the population parameter(s)), sample.size, and bad.obs (number of missing (NA), undefined (NaN), or infinite (Inf, -Inf) values removed prior to performing the hypothesis test), and interval (a list with information about a confidence, prediction, or tolerance interval).

Methods

Generic functions that have methods for objects of class "htest" include:
print.

Value

Required Components
The following components must be included in a legitimate list of class "htest".

null.value

numeric vector containing the value(s) of the population parameter(s) specified by the null hypothesis. This vector has a names attribute describing its elements.

alternative

character string indicating the alternative hypothesis (the value of the input argument alternative). Possible values are "greater", "less", or "two-sided".

method

character string giving the name of the test used.

estimate

numeric vector containing the value(s) of the estimated population parameter(s) involved in the null hypothesis. This vector has a names attribute describing its element(s).

data.name

character string containing the actual name(s) of the input data.

statistic

numeric scalar containing the value of the test statistic, with a names attribute indicating the null distribution.

parameters

numeric vector containing the parameter(s) associated with the null distribution of the test statistic. This vector has a names attribute describing its element(s).

p.value

numeric scalar containing the p-value for the test under the null hypothesis.

Optional Components
The following component may optionally be included in an object of of class "htest" generated by R functions that test hypotheses:

conf.int

numeric vector of length 2 containing lower and upper confidence limits for the estimated population parameter. This vector has an attribute called "conf.level" that is a numeric scalar indicating the confidence level associated with the confidence interval.

The following components may be included in objects of class "htest" generated by EnvStats functions:

sample.size

numeric scalar containing the number of non-missing observations in the sample used for the hypothesis test.

estimation.method

character string containing the method used to compute the estimated distribution parameter(s). The value of this component will depend on the available estimation methods (see Distribution.df).

bad.obs

the number of missing (NA), undefined (NaN) and/or infinite (Inf, -Inf) values that were removed from the data object prior to performing the hypothesis test.

interval

a list containing information about a confidence, prediction, or tolerance interval.

Note

Since objects of class "htest" are lists, you may extract their components with the $ and [[ operators.

Author

Steven P. Millard (EnvStats@ProbStatInfo.com)

Examples

  # Create an object of class "htest", then print it out. 
  #------------------------------------------------------

  htest.obj <- chenTTest(EPA.02d.Ex.9.mg.per.L.vec, mu = 30)

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

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

  names(htest.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" 
 
  htest.obj 
#> $statistic
#>        t 
#> 1.574075 
#> 
#> $parameters
#> df 
#> 59 
#> 
#> $p.value
#>          z 
#> 0.05773508 
#> 
#> $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] "print.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

  #==========

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

  htest.obj$statistic
#>        t 
#> 1.574075 
  #       t 
  #1.574075

  #==========

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