View source: R/13_inverse_predict.R
| inverse_predict.modeler | R Documentation | 
modeler objectComputes the x-value at which a fitted model reaches a user-specified response value (y-value).
## S3 method for class 'modeler'
inverse_predict(
  object,
  y,
  id = NULL,
  interval = NULL,
  tol = 1e-06,
  resolution = 1000,
  ...
)
| object | A fitted object of class  | 
| y | A numeric scalar giving the target y-value for which to compute the corresponding x. | 
| id | Optional vector of  | 
| interval | Optional numeric vector of length 2 specifying the interval in which to search for the root.
If  | 
| tol | Numerical tolerance passed to  | 
| resolution | Integer. Number of grid points used to scan the interval. | 
| ... | Additional parameters for future functionality. | 
The function uses numeric root-finding to solve f(t, ...params) = y.
If no root is found in the interval, NA is returned.
A tibble with one row per group, containing:
uid – unique identifier of the group,
fn_name – the name of the fitted function,
lower and upper – the search interval used,
y – the predicted y-value (from the function at the root),
x – the x-value at which the function reaches y.
predict.modeler, uniroot
library(flexFitR)
data(dt_potato)
mod_1 <- dt_potato |>
  modeler(
    x = DAP,
    y = Canopy,
    grp = Plot,
    fn = "fn_lin_plat",
    parameters = c(t1 = 45, t2 = 80, k = 0.9),
    subset = c(15, 2, 45)
  )
print(mod_1)
inverse_predict(mod_1, y = 50)
inverse_predict(mod_1, y = 75, interval = c(20, 80))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.