models_linear {bioset} | R Documentation |
Use these functions to calculate a linear model from data, plot the model and use it to calculate x-values from the model data and y-values (inverse function).
Those function are intended to be used in set_calc_concentrations /
sets_read to be applied to the calibrators (fit_linear
) and interpolate
concentrations from the raw values (interpolate_linear
). Use plot_linear
to visually inspect goodness of fit.
fit_linear
: Calculate a linear model from x and y.
plot_linear
: Draw the plot for the model that can be calculated with
fit_linear
. Uses ggplot2::ggplot if available.
interpolate_linear
: Inverse fit_linear
using model
and calculate x
values from y values.
fit_linear(x, y) plot_linear(x, y) interpolate_linear(y, model)
x |
The x coordinates of the points. |
y |
The y coordinates of the points. |
model |
The line model. |
fit_linear
: The line model.
plot_linear
: The plot.
interpolate_linear
: The calculated x values.
set_calc_concentrations, sets_read, models_lnln
# generate data x <- c(1, 3, 4, 7) y_known <- c(3.5, 6.5, 8, 12.5) # x is known for these values y_unknown <- c(5, 9.5, 11) # we will calculate x for those model <- fit_linear(x = x, y = y_known) model plot_linear(x = x, y = y_known) interpolate_linear(y = y_unknown, model) rm(x, y_known, y_unknown, model)