View source: R/misc_functions.R
predict_inv | R Documentation |
predict_inv
Calculates the value the predictor x that generates value y with a simple linear model.
predict_inv(model, y)
model |
A simple linear model object (class lm). |
y |
A numerical scalar, the value of the outcome for which we want to calculate the predictor x. |
The estimated value of the predictor.
## Spectrophotometry example. Titration curve for riboflavin (nmol/ml). The sample has an absorbance
## of 1.15. Aim is to estimate the concentration of riboflavin in the sample.
Riboflavin <- seq(0, 80, 10)
OD <- 0.0125 * Riboflavin + rnorm(9, 0.6, 0.03)
titration <- data.frame(Riboflavin, OD)
require(sjlabelled, quietly = TRUE)
titration <- titration |>
var_labels(
Riboflavin = "Riboflavin (nmol/ml)",
OD = "Optical density"
)
titration |>
gf_point(OD ~ Riboflavin) |>
gf_smooth(col = "indianred3", se = TRUE, lwd = 0.5, method = "loess")
## Model with intercept different from zero:
model <- lm(OD ~ Riboflavin, data = titration)
glm_coef(model)
predict_inv(model, 1.15)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.