Skip to contents

Extract the estimated coefficients from an object of class modeler.

Usage

# S3 method for class 'modeler'
coef(x, id = NULL, metadata = FALSE, df = FALSE, ...)

Arguments

x

An object of class modeler, typically the result of calling the modeler() function.

id

An optional unique identifier to filter by a specific group. Default is NULL.

metadata

Logical. If TRUE, metadata is included along with the coefficients. Default is FALSE.

df

Logical. If TRUE, the degrees of freedom for the fitted model are returned alongside the coefficients. Default is FALSE.

...

Additional parameters for future functionality.

Value

A data.frame containing the model's estimated coefficients, standard errors, and optional metadata or degrees of freedom if specified.

Author

Johan Aparicio [aut]

Examples

library(flexFitR)
data(dt_potato)
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(15, 2, 45)
  )
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.002601 0.459153 0.915706 2.206356 3.308233 5.700760 
#> 
#> Optimization Results `head()`:
#>  uid   t1   t2     k    sse
#>    2 35.1 61.1 100.0 5.7008
#>   15 38.4 70.1  99.7 0.9157
#>   45 38.3 64.7 100.0 0.0026
#> 
#> Metrics:
#>  Groups      Timing Convergence Iterations
#>       3 1.4114 secs        100%   349 (id)
#> 
coef(mod_1, id = 2)
#> # A tibble: 3 × 6
#>     uid coefficient solution std.error `t value` `Pr(>|t|)`
#>   <dbl> <chr>          <dbl>     <dbl>     <dbl>      <dbl>
#> 1     2 t1              35.1     0.244      144.   3.04e-10
#> 2     2 t2              61.1     0.387      158.   1.93e-10
#> 3     2 k              100.      0.616      162.   1.69e-10