Create several plots for an object of class modeler
Usage
# S3 method for class 'modeler'
plot(
x,
id = NULL,
type = 1,
label_size = 4,
base_size = 14,
color = "red",
parm = NULL,
n_points = 2000,
title = NULL,
add_ci = TRUE,
add_ribbon = FALSE,
color_ribbon = "blue",
...
)
Arguments
- x
An object of class
modeler
, typically the result of callingmodeler()
.- id
An optional group ID to filter the data for plotting, useful for avoiding overcrowded plots.
- type
Numeric value (1-6) to specify the type of plot to generate. Default is 1.
type = 1
Plot of raw data with fitted curves.
type = 2
Plot of coefficients with confidence intervals.
type = 3
Plot of fitted curves, colored by group.
type = 4
Plot of fitted curves with confidence intervals.
type = 5
Plot of first derivative with confidence intervals.
type = 6
Plot of second derivative with confidence intervals.
- label_size
Numeric value for the size of labels. Default is 4.
- base_size
Numeric value for the base font size in pts. Default is 14.
- color
Character string specifying the color for the fitted line when
type = 1
. Default is "red".- parm
Character vector specifying the parameters to plot for
type = 2
. IfNULL
, all parameters are included.- n_points
Numeric value specifying the number of points for interpolation along the x-axis. Default is 2000.
- title
Optional character string to add a title to the plot.
- add_ci
Logical value indicating whether to add confidence intervals for
type = 4, 5, 6
. Default isTRUE
.- add_ribbon
Logical value indicating whether to add a ribbon for confidence intervals in
type = 4, 5, 6
. Default isFALSE
.- color_ribbon
Character string specifying the color of the ribbon. Default is "blue".
- ...
Additional graphical parameters for future extensions.
Examples
library(flexFitR)
data(dt_potato)
# Example 1
mod_1 <- dt_potato |>
modeler(
x = DAP,
y = Canopy,
grp = Plot,
fn = "fn_linear_sat",
parameters = c(t1 = 45, t2 = 80, k = 0.9),
subset = c(1:3)
)
print(mod_1)
#>
#> Call:
#> Canopy ~ fn_linear_sat(DAP, t1, t2, k)
#>
#> Sum of Squares Error:
#> Min. 1st Qu. Median Mean 3rd Qu. Max.
#> 0.4489 2.1038 3.7587 3.3028 4.7297 5.7008
#>
#> Optimization Results `head()`:
#> uid t1 t2 k sse
#> 1 38.5 61.7 99.8 0.449
#> 2 35.1 61.1 100.0 5.701
#> 3 33.7 60.0 100.0 3.759
#>
#> Metrics:
#> Groups Timing Convergence Iterations
#> 3 1.4471 secs 100% 502.33 (id)
#>
plot(mod_1, id = 1:2)
plot(mod_1, id = 1:3, type = 2, label_size = 10)