genloq: Substitution of (concentration) values below a limit of...

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/genloq.R

Description

Function genloq uses given (or determines) threshold of the limit of quantification and substitutes string "LoQ" of values below it.

Usage

1
2
3
4
genloq(x, y=NA, input="openair", output=NA, loq=NA, 
       method="mle", distr="lnorm", pollutant=NA, plot=TRUE, 
       ylim=c(NA,NA), columns=2, col.points="black", pch=1, 
       xlab="Date", ylab="Concentration", main=NA)

Arguments

x

a vector of concentration values (of class "numeric" or "character") or data frame of "genasis"/"openair" type with concentration column allowed to be of class "character". See 'Details' for more detailed description of both data types and the exceptions for genloq function.

y

a vector of measurement dates in the case of vector input only.

input

a type of data frame in the case of data frame input. The allowed values are "openair" (default) and "genasis" with an exception of the column with concentration values, which could be of class "character". In case of vector input, this argument is meaningless.

output

a type of output data frame. As in the input argument, both data frames "openair" and "genasis" are available, with the default value equal to input.

loq

a value of the limit of quantification which will be used for all pollutants.

method

method of values below LoQ substitution. Allowed values are "exc" for exclusion, "1.0", "2.0", "sq2" for substitution by constant and "mle" for modified maximum likelihood method. See 'Details' for more detailed description of methods.

distr

if method="mle" (default), specifies if normal distr="norm" or log-normal distr="lnorm" distribution will be used for likelihood maximization.

pollutant

a name(s) of the pollutant(s), for which the LoQs are substituted. Not necessary if only data for one pollutant is available in x. If not specified, results for all pollutants are computed and plots for all pollutants are drawn in a multi-plot arrangement.

plot

logical. Indicates, whether plot should be plotted.

ylim

vector of class "numeric" and length 2 setting the lower and upper border of the plot.

columns

number of columns in the multi-plot arrangement.

col.points

color of over LoQ points inside the plot.

pch

plotting 'character', i.e., symbol to use. For more details see points.

xlab

the x label of the plot.

ylab

the y label of the plot.

main

overall title for the plot.

Details

The genloq function substitutes values below the limit of quantification (LoQ) (equivalently the limit of detection (LoD)) marked as "loq", "LoQ" or "LOQ" in the x. Although both data frames of types "openair" and "genasis" are defined with columns containing concentration values of class "numeric", it is necessary to mark values below LoQ as character string - thus here is an exception from the definition and both data types "openair" and "genasis", as well as vector x could contain concentration values of class "character". See 'Examples' paragraph.

Thus the function recognises three different input formats: Option input="openair" uses "openair" format of data frame with first column of name "date" and class "Date", optional columns of names "date_end", "temp", "wind" and "note" and other columns of class "numeric" or "character" containing concentration values and named by names of the compounds. input="genasis" is used for the data frame with six columns "valu", "comp", "date_start", "date_end", "temp" and "wind" where the first could be both "numeric" or "character" class, fifth and sixth are of class "numeric", second of class "character" and third and fourth columns could be both "character" or "Date" class. The names of columns in input="genasis" are not rigid, only their order is assumed. There is also a possibility to specify x and y as two vectors of equal lenght, first of class "numeric" or "character" containing concentration values, second of class "character" or "Date" containing measurement dates.

The output argument specifies of which type the result will be. Both types of "data.frame" class output="openair" and output="genasis" are available - now without any exceptions with all concentration values of class "numeric", the default value is equal to the input argument, therefore the vector class of output is possible only if x is "numeric" or "character" vector and output is not specified.

There are five available methods of LoQs treatment. The simpliest method method="exc" is not recommended because of high bias and meaningless approach. Standard constant methods method="1.0", method="2.0" and method="sq2" serve for substitution of (concentration) values below LoQ by value of LoQ divided gradually by 1 ,2 and square root of 2. The most recommended is the modified maximum likelihood method method="mle" which will be described later.

Value

a list containing:

res

the data frame (or vector) according to the output argument settings with substituted (or eventually excluded) (concentration) values below limit of quantification.

loq

numeric value of LoQ

Author(s)

Jiri Kalina
kalina@mail.muni.cz

See Also

genoutlier, genhistogram, genpastoact, genanaggr, genplot, genstatistic, gentransform, genwhisker

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## Definition of simple data sources:
c1<-rlnorm(100,0,1)
c2<-"random compound"
c3<-as.Date(as.Date("2013-01-01"):as.Date("2013-04-10"),
            origin="1970-01-01")
c4<-c3+1

# Cuts the values below the 0.5.
c1[which(c1<0.5)]<-"LoQ"

sample_genasis<-data.frame(c1,c2,c3,c4)
sample_openair<-data.frame(c4,c1)
colnames(sample_openair)=c("date",c2)

## Examples of different usages:
genloq(c1,c3,pollutant=c2,method="sq2")
genloq(sample_openair,method="mle")

genasis documentation built on May 1, 2019, 10:16 p.m.

Related to genloq in genasis...