Defines a '`calibration`

' object for the calculation of concentrations
from measurement signals including estimations for the limit of detection
(LOD) and limit of quantification (LOQ) in accordance with DIN 32645 (2008).

## Usage

```
calibration(
formula,
data = NULL,
blanks = NULL,
weights = NULL,
model = "lm",
check_assumptions = TRUE,
...
)
# S3 method for calibration
print(x, ...)
# S3 method for calibration
summary(object, ...)
# S3 method for calibration
plot(x, interval = "conf", level = 0.95, ...)
# S3 method for calibration
as.list(x, which = c("coef", "adj.r.squared", "lod", "loq", "blanks"), ...)
lod(x, ...)
# S3 method for default
lod(x, ...)
# S3 method for calibration
lod(x, blanks = NULL, alpha = 0.01, level = 0.05, ...)
loq(x, ...)
# S3 method for default
loq(x, ...)
# S3 method for calibration
loq(x, blanks = NULL, alpha = 0.01, k = 3, level = 0.05, maxiter = 10, ...)
inv_predict(x, ...)
# S3 method for default
inv_predict(x, ...)
# S3 method for calibration
inv_predict(x, y, below_lod = NULL, method = "analytic", ...)
```

## Arguments

- formula
model formula providing the recorded signal intensities with respect to the nominal/specified analyte concentrations in the form of

`signal ~ concentration`

or`signal ~ concentration - 1`

; model formulas are currently restricted to those forms.- data
an optional data frame containing the variables in the model.

- blanks
a vector of numeric blank values overriding those automatically retrieved from calibration data.

- weights
an optional character string containing one or more model variables, for example, in the form of "

`1/concentration^0.5`

" or "`1/signal`

" which is internally converted to a numeric vector and passed to the fitting process of the selected model; see also`weight_select()`

- model
model class to be used for fitting; currently,

`lm()`

and`rlm()`

are supported.- check_assumptions
automatically check for normality and homoscedasticity of model residuals using

`shapiro.test()`

and`bptest()`

, respectively; only executed if`weights == NULL`

.- ...
further arguments passed to submethods; for instance, the respective model environment such as

`lm()`

,`print()`

, or`plot()`

.- x, object
an object of class '

`calibration`

' with a model formula as shown above.- interval
type of interval plotted (can be abbreviated); see

`predict()`

for details.- level
tolerance/confidence level; see

`predict()`

and`confint()`

for details.- which
character vector indicating the parameters to export; defaults to

`c("coef", "adj.r.squared", "lod", "loq", "blanks")`

.- alpha
numeric; error tolerance for the detection limit (critical value).

- k
numeric; relative uncertainty for the limit of quantification (

`1/beta`

).- maxiter
a positive integer specifying the maximum number of iterations to calculate the LOQ.

- y
numeric; the value to inverse predict.

- below_lod
value to be assigned if inverse prediction is below LOD; defaults to

`"NULL"`

which keeps predicted values untouched. Other options may be`NA`

or`0`

.- method
character indicating the method used for inverse prediction; defaults to

`"analytic"`

.

## Value

`calibration`

returns an object of `class`

'`calibration`

'.

`print()`

calls the function parameters together with the respective LOD
and LOQ.
`summary()`

may be used to retrieve the summary of the underlying model.
`plot()`

plots the respective calibration curve together with the
measurement values.

`as.list()`

returns a named list.

`lod()`

and `loq()`

return a named vector with the LOD and LOQ
together with lower and upper confidence limits.

`inv_predict()`

predicts/calculates analyte concentrations from signal
intensities.

## Details

The LOD is defined as the lowest quantity of a substance that can be
distinguished from the absence of that substance (blank value) within a given
confidence level (`alpha`

). The LOQ is defined as the lowest quantity of
a substance that can be quantified/distinguished from another sample given
with respect to a defined confidence level (`k`

).

If the `data`

supplied to `calibration`

contain more than one blank
value, namely measurements with a nominal/specified concentration of or close
to zero, the LOD and LOQ are calculated from the deviation of the blank
samples. This method is called "blank method" according to DIN 32645 (2008)
and supposed to be more accurate than the so-called "calibration method"
which will be used for the estimation of LOD and LOQ when `data`

does
not contain zero concentration measurements.

## References

Almeida, A.M.D., Castel-Branco, M.M., & Falcao, A.C. (2002). Linear
regression for calibration lines revisited: weighting schemes for
bioanalytical methods. *Journal of Chromatography B*, **774**(2),
215-222. doi:10.1016/S1570-0232(02)00244-1
.

Currie, L.A. (1999). Nomenclature in evaluation of analytical methods
including detection and quantification capabilities: (IUPAC Recommendations
1995). *Analytica Chimica Acta* **391**, 105-126.

DIN 32645 (2008). *Chemical analysis - Decision limit, detection limit
and determination limit under repeatability conditions - Terms, methods,
evaluation*. Technical standard. Deutsches Institut für Normung, Berlin.

Massart, D.L., Vandeginste, B.G., Buydens, L.M.C., Lewi, P.J., &
Smeyers-Verbeke, J. (1997). *Handbook of chemometrics and qualimetrics:
Part A*. Elsevier Science Inc.

## See also

`invest()`

for alternative inverse prediction methods;

Other calibration:
`din32645`

,
`icp`

,
`matrix_effect()`

,
`neitzel2003`

,
`phenolics`

,
`weight_select()`

## Examples

```
data(din32645)
din <- calibration(Area ~ Conc, data = din32645)
print(din)
#>
#> Call:
#> calibration(formula = Area ~ Conc, data = din32645)
#>
#> Coefficients:
#> (Intercept) Conc
#> 2481 9662
#>
#> Adjusted R-squared: 0.983
#> Sum relative error: 0.7978
#>
#> Blanks:
#> [1] 2003 1901 2212 1976 2279 1853 2165 2108 2368 1943
#>
#> Conc lwr upr
#> LOD 0.053 0.036 0.096
#> LOQ 0.212 0.146 0.387
#>
#> Check for normality of residuals:
#>
#> Shapiro-Wilk normality test
#>
#> data: residuals(calibration(formula = Area ~ Conc, data = din32645))
#> W = 0.90059, p-value = 0.2224
#>
#> Check for homoscedasticity of residuals:
#>
#> studentized Breusch-Pagan test
#>
#> data: Area ~ Conc
#> BP = 1.6198, df = 1, p-value = 0.2031
#>
summary(din)
#>
#> Call:
#> calibration(formula = Area ~ Conc, data = din32645)
#>
#> Residuals:
#> Min 1Q Median 3Q Max
#> -223.16 -138.94 -29.16 121.92 327.26
#>
#> Coefficients:
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 2480.9 131.4 18.89 6.39e-08 ***
#> Conc 9661.9 423.4 22.82 1.44e-08 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Residual standard error: 192.3 on 8 degrees of freedom
#> Multiple R-squared: 0.9849, Adjusted R-squared: 0.983
#> F-statistic: 520.7 on 1 and 8 DF, p-value: 1.442e-08
#>
plot(din)
as.list(din)
#> $`(Intercept)`
#> [1] 2480.867
#>
#> $Conc
#> [1] 9661.939
#>
#> $adj.r.squared
#> [1] 0.9829773
#>
#> $lod
#> [1] 0.053
#>
#> $loq
#> [1] 0.212
#>
#> $blank_mean
#> [1] 2080.8
#>
#> $blank_sd
#> [1] 172.2581
#>
lod(din)
#> Conc lwr upr
#> LOD 0.053 0.036 0.096
loq(din)
#> Conc lwr upr
#> LOQ 0.212 0.146 0.387
inv_predict(din, 5000)
#> [1] 0.2607275
```