predict_inv {pubh} | R Documentation |
Given y solve for x in a simple linear model.
Description
predict_inv
Calculates the value the predictor x that generates value y with a simple linear model.
Usage
predict_inv(model, y)
Arguments
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. |
Value
The estimated value of the predictor.
Examples
## 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)
[Package pubh version 1.3.2 Index]