pubh (version 1.1.16)

predict_inv: 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

Run this code
# NOT RUN {
## 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)
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') %>%
  axis_labs()

## Model with intercept different from zero:
model <- lm(OD ~ Riboflavin, data = titration)
glm_coef(model)
predict_inv(model, 1.15)
# }

Run the code above in your browser using DataLab