as.lcens: Left-censored Data Conversion

as.lcensR Documentation

Left-censored Data Conversion

Description

Converts data to a left-censored data (lcens) object: various methods.

Usage

as.lcens(values, detlim, censor.codes)

## S4 method for signature 'lcens,missing,missing'
as.lcens(values, detlim, censor.codes)

## S4 method for signature 'numeric,missing,missing'
as.lcens(values, detlim, censor.codes)

## S4 method for signature 'numeric,numeric,missing'
as.lcens(values, detlim, censor.codes)

## S4 method for signature 'numeric,numeric,logical'
as.lcens(values, detlim, censor.codes)

## S4 method for signature 'numeric,numeric,character'
as.lcens(values, detlim, censor.codes)

## S4 method for signature 'numeric,missing,logical'
as.lcens(values, detlim, censor.codes)

## S4 method for signature 'numeric,missing,character'
as.lcens(values, detlim, censor.codes)

## S4 method for signature 'qw,missing,missing'
as.lcens(values, detlim, censor.codes)

## S4 method for signature 'qw,numeric,missing'
as.lcens(values, detlim, censor.codes)

## S4 method for signature 'character,missing,missing'
as.lcens(values, detlim, censor.codes)

Arguments

values

numeric values representing "raw" values. Missing values are permitted. A vector of character strings is allowed when the remark code is combined with the value; blank values are treated as missing values, any other value is converted to a missing value with a warning. See Examples.

detlim

the corresponding detection limit of the sensor. Missing values are permitted. Detection limits are required for each non-missing value in values; they will be imputed if missing. The imputation scheme is fairly sophisticated, see Lorenz (in preparation) for details, so it is better to set to missing, rather than provide an arbitrary detection limit.

censor.codes

optional codes indicating a left-censored value. If class "logical," then TRUE indicates left-censored. If class "character," then "<" indicates left-censored and anything other than "" or " " generates a warning.

Value

An S4 object of class "lcens." These objects are the basis for the analysis of left-censored data.

Note

All methods force values to be no less than the corresponding detlim. All values that are less than detlim are treated as left-censored values at detlim. This ensures unbiased analytical results.

References

Lorenz, D.L., in preparation

See Also

as.mcens

Examples


## The first value is censored at 2
as.lcens(c(1,3), 2)
## Set the first value to censored at that level and the detection limit is
# carried forward
as.lcens(c(1,3), censor.codes=c("<", ""))
# For combined remark and values:
as.lcens(c("<1", "1", "<1", "1", "2"))


USGS-R/smwrQW documentation built on Oct. 11, 2022, 6:13 a.m.