inverse_predict.modeler {flexFitR} | R Documentation |
Inverse prediction from a modeler
object
Description
Computes the x-value at which a fitted model reaches a user-specified response value (y-value).
Usage
## S3 method for class 'modeler'
inverse_predict(
object,
y,
id = NULL,
interval = NULL,
tol = 1e-06,
resolution = 1000,
...
)
Arguments
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. |
Details
The function uses numeric root-finding to solve f(t, ...params) = y
.
If no root is found in the interval, NA
is returned.
Value
A tibble
with one row per group, containing:
-
uid
– unique identifier of the group, -
fn_name
– the name of the fitted function, -
lower
andupper
– the search interval used, -
y
– the predicted y-value (from the function at the root), -
x
– the x-value at which the function reachesy
.
See Also
Examples
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))