htestCensored.object.Rd
This class of objects is returned by EnvStats functions that perform
hypothesis tests based on censored data.
Objects of class "htestCensored"
are lists that contain information about
the null and alternative hypotheses, the censoring side, the censoring levels,
the percentage of observations that are censored,
the estimated distribution parameters (if applicable), the test statistic,
the p-value, and (optionally, if applicable)
confidence intervals for distribution parameters.
Objects of S3 class "htestCensored"
are returned by
the functions listed in the section Hypothesis Tests
in the help file
EnvStats Functions for Censored Data.
Currently, the only function listed is
twoSampleLinearRankTestCensored
.
Generic functions that have methods for objects of class
"htestCensored"
include: print
.
Required Components
The following components must be included in a legitimate list of
class "htestCensored"
.
numeric scalar containing the value of the test statistic, with a
names
attribute indicating the null distribution.
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).
numeric scalar containing the p-value for the test under the null hypothesis.
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.
character string indicating the alternative hypothesis (the value of the input
argument alternative
). Possible values are "greater"
, "less"
,
or "two-sided"
.
character string giving the name of the test used.
numeric scalar containing the number of non-missing observations in the sample used for the hypothesis test.
character string containing the actual name(s) of the input data.
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.
character string indicating whether the data are left- or right-censored.
character string indicating the name of the data object used to identify which values are censored.
numeric scalar or vector indicating the censoring level(s).
numeric scalar indicating the percent of non-missing observations that are censored.
Optional Components
The following component may optionally be included in an object of
of class "htestCensored"
:
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).
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
).
a list containing information about a confidence, prediction, or tolerance interval.
Since objects of class "htestCensored"
are lists, you may extract
their components with the $
and [[
operators.
# Create an object of class "htestCensored", then print it out.
#--------------------------------------------------------------
htestCensored.obj <- with(EPA.09.Ex.16.5.PCE.df,
twoSampleLinearRankTestCensored(
x = PCE.ppb[Well.type == "Compliance"],
x.censored = Censored[Well.type == "Compliance"],
y = PCE.ppb[Well.type == "Background"],
y.censored = Censored[Well.type == "Background"],
test = "tarone-ware", alternative = "greater"))
mode(htestCensored.obj)
#> [1] "list"
#[1] "list"
class(htestCensored.obj)
#> [1] "htestCensored"
#[1] "htest"
names(htestCensored.obj)
#> [1] "statistic" "parameters" "p.value"
#> [4] "estimate" "null.value" "alternative"
#> [7] "method" "estimation.method" "sample.size"
#> [10] "data.name" "bad.obs" "censoring.side"
#> [13] "censoring.name" "censoring.levels" "percent.censored"
# [1] "statistic" "parameters" "p.value"
# [4] "estimate" "null.value" "alternative"
# [7] "method" "estimation.method" "sample.size"
#[10] "data.name" "bad.obs" "censoring.side"
#[13] "censoring.name" "censoring.levels" "percent.censored"
htestCensored.obj
#>
#> Results of Hypothesis Test
#> Based on Censored Data
#> --------------------------
#>
#> Null Hypothesis: Fy(t) = Fx(t)
#>
#> Alternative Hypothesis: Fy(t) > Fx(t) for at least one t
#>
#> Test Name: Two-Sample Linear Rank Test:
#> Tarone-Ware Test
#> with Hypergeometric Variance
#>
#> Censoring Side: left
#>
#> Censoring Level(s): x = 5
#> y = 2 4 5
#>
#> Data: x = PCE.ppb[Well.type == "Compliance"]
#> y = PCE.ppb[Well.type == "Background"]
#>
#> Censoring Variable: x = Censored[Well.type == "Compliance"]
#> y = Censored[Well.type == "Background"]
#>
#> Sample Sizes: nx = 8
#> ny = 6
#>
#> Percent Censored: x = 12.5%
#> y = 50.0%
#>
#> Test Statistics: nu = 8.458912
#> var.nu = 20.912407
#> z = 1.849748
#>
#> P-value: 0.03217495
#>
#Results of Hypothesis Test
#Based on Censored Data
#--------------------------
#
#Null Hypothesis: Fy(t) = Fx(t)
#
#Alternative Hypothesis: Fy(t) > Fx(t) for at least one t
#
#Test Name: Two-Sample Linear Rank Test:
# Tarone-Ware Test
# with Hypergeometric Variance
#
#Censoring Side: left
#
#Data: x = PCE.ppb[Well.type == "Compliance"]
# y = PCE.ppb[Well.type == "Background"]
#
#Censoring Variable: x = Censored[Well.type == "Compliance"]
# y = Censored[Well.type == "Background"]
#
#Sample Sizes: nx = 8
# ny = 6
#
#Percent Censored: x = 12.5%
# y = 50.0%
#
#Test Statistics: nu = 8.458912
# var.nu = 20.912407
# z = 1.849748
#
#P-value: 0.03217495
#==========
# Extract the test statistics
#----------------------------
htestCensored.obj$statistic
#> nu var.nu z
#> 8.458912 20.912407 1.849748
# nu var.nu z
# 8.458912 20.912407 1.849748
#==========
# Clean up
#---------
rm(htestCensored.obj)