View source: R/elco_xrf_correct_elements.R
elco_xrf_correct_elements | R Documentation |
elco_xrf_correct_elements
is a heuristic function to correct measured element contents of samples
during XRF analysis. Elements for which to perform a correction can be selected. Only batch processing of
files is possible.
The correction is based on a reference calibration data set where five different samples have been measured
with four different masses (500 mg, the current reference with which the instrument is calibrated, 300, 250, and 200 mg).
For each measured element and measurement, the ratio of the element content measured with mass x and the element content
measured with reference mass (500 mg) are divided. Deviations from 1 are due to measurement noise and effects of
mass differences on the recorded signal. The correction targets the latter, but also propagates uncertainty about the
former. The computed ratios are modeled with a linear mixed model, where there is a random intercept for each sample and
the sample mass is treated as factor. Sample mass is treated as factor because the variance is not homogeneous between
different masses (a future version might include a procedure where the variance is also modeled in dependence of the sample mass).
A consequence is that the correction procedure currently can only be applied to values measured with sample masses
as used in the calibration data set.
The regression models assume a Gamma distribution since all computed ratios are ≥0. The models are fit with
rstanarm()
(rstanarm::stan_glmer()
) using default
priors. From the models' predictive distributions, the predicted correction factors are sampled and its mean and
standard deviation stored.
During correction, the measured value to correct and a sample mass are given. elco_xrf_correct_elements
searches the respective correction factor and its standard deviation and multiplies it with the
measured value. The quantities::quantities()
package is used to propagate the uncertainty in the
correction factor into the corrected value.
elco_xrf_correct_elements( x, element = NULL, sample_mass, xrf_calibration = NULL )
x |
An object of class |
element |
A character vector representing the chemical elements for which to correct the mass fraction
values. This must be one in |
sample_mass |
A vector of class |
xrf_calibration |
A data frame which stores correction factors for combinations of chemical elements and sample masses, with a row for each element and sample mass and three columns:
Alternatively, |
x
with corrected element content values.
Currently, the calibration procedure is rather crude and not based on a large amount of samples. This causes relative large uncertainties.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.