These classes of objects are returned by functions that perform hypothesis tests
(e.g., the R function t.test returns an object of class "htest",
while the EnvStats functions quantileTest and
kendallSeasonalTrendTest return objects of class "htestEnvStats").
Objects of class "htest" and "htestEnvStats" 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 "htestEnvStats" returned by EnvStats functions
that perform hypothesis tests include: chenTTest kendallTrendTest kendallSeasonalTrendTest quantileTest serialCorrelationTest signTest twoSampleLinearRankTest varTest varGroupTest zTestGevdShape
These functions are listed in the help file Hypothesis Tests,
along with other functions that perform hypothesis tests that return objects of different classes
(e.g., the function link{oneSamplePermutationTest} returns an object of class
"permutationTest").
Note that functions that perform goodness-of-fit tests
return objects of class "gof" or
"gofTwoSample".
Objects of class "htestEnvStats" 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
"htestEnvStats" include: print. Objects of class "htest"
use the standard R printing methods.
Value
Required Components
The following components must be included in a legitimate list of
class "htest" or "htestEnvStats".
- null.value
numeric vector containing the value(s) of the population parameter(s) specified by the null hypothesis. This vector has a
namesattribute 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
namesattribute 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
namesattribute indicating the null distribution.- parameters
numeric vector containing the parameter(s) associated with the null distribution of the test statistic. This vector has a
namesattribute 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 "htestEnvStats"
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" and "htestEnvStats" are lists, you may extract
their components with the $ and [[ operators.
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
#>
#> 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
#>
#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
#---------------------------
htestEnvStats.obj$statistic
#> t
#> 1.574075
# t
#1.574075
#==========
#============================================================================
# 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.htestEnvStats() 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.htestEnvStats(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)