diff --git a/docs/articles/canopy-model.html b/docs/articles/canopy-model.html index 6b5fc85..973c2a9 100644 --- a/docs/articles/canopy-model.html +++ b/docs/articles/canopy-model.html @@ -301,8 +301,8 @@

Fitting Models#> 195 38.7 60.0 91.7 390 #> #> Metrics: -#> Groups Timing Convergence Iterations -#> 2 0.866 secs 100% 547 (id) +#> Groups Timing Convergence Iterations +#> 2 0.8015 secs 100% 547 (id)
 plot(mod_1, id = c(195, 40))

plot fit

diff --git a/docs/articles/how_to_start.html b/docs/articles/how_to_start.html index 44b781a..0515c30 100644 --- a/docs/articles/how_to_start.html +++ b/docs/articles/how_to_start.html @@ -146,7 +146,7 @@

1. Simple linear regression#> #> Metrics: #> Groups Timing Convergence Iterations -#> 1 0.4098 secs 100% 259 (id) +#> 1 0.3676 secs 100% 259 (id)

Once the model is fitted, we can examine the output, extract the estimated parameters, make some plots, and predict new x values.

@@ -288,7 +288,7 @@ 

2. Piece-wise regression#> #> Metrics: #> Groups Timing Convergence Iterations -#> 1 0.4163 secs 100% 511 (id)

+#> 1 0.3951 secs 100% 511 (id)

After fitting the model, we can examine the results, plot the fitted curve, extract the coefficients and their associated p-values, obtain the variance-covariance matrix, and make predictions for unknown values @@ -358,7 +358,7 @@

Providing Initial values#> #> Metrics: #> Groups Timing Convergence Iterations -#> 1 0.4248 secs 100% 567 (id) +#> 1 0.4101 secs 100% 567 (id) coef(mod_2) #> # A tibble: 3 × 6 #> uid coefficient solution std.error `t value` `Pr(>|t|)` @@ -396,7 +396,7 @@

Fixing parameters#> #> Metrics: #> Groups Timing Convergence Iterations -#> 1 0.3857 secs 100% 321 (id) +#> 1 0.3723 secs 100% 321 (id) coef(mod_3) #> # A tibble: 2 × 6 #> uid coefficient solution std.error `t value` `Pr(>|t|)` diff --git a/docs/articles/plotting.html b/docs/articles/plotting.html index a0f63ab..fd708f1 100644 --- a/docs/articles/plotting.html +++ b/docs/articles/plotting.html @@ -126,13 +126,13 @@

Expectation function and modeling#> #> Metrics: #> Groups Timing Convergence Iterations -#> 1 0.3862 secs 100% 334 (id) +#> 1 0.3787 secs 100% 334 (id)

Plotting predictions and derivatives

-a <- plot(mod, color = "blue", title = "Raw - data")
+a <- plot(mod, color = "blue", title = "Raw data")
 b <- plot(mod, type = 4, n_points = 200, color = "black")
 c <- plot(mod, type = 5, n_points = 200, color = "black")
 d <- plot(mod, type = 6, n_points = 200, color = "black")
diff --git a/docs/articles/plotting_files/figure-html/unnamed-chunk-4-1.png b/docs/articles/plotting_files/figure-html/unnamed-chunk-4-1.png
index 4e746c2..aba67c5 100644
Binary files a/docs/articles/plotting_files/figure-html/unnamed-chunk-4-1.png and b/docs/articles/plotting_files/figure-html/unnamed-chunk-4-1.png differ
diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml
index 2b7212a..82dfedf 100644
--- a/docs/pkgdown.yml
+++ b/docs/pkgdown.yml
@@ -7,7 +7,7 @@ articles:
   how_to_start: how_to_start.html
   maturity-model: maturity-model.html
   plotting: plotting.html
-last_built: 2024-09-23T19:17Z
+last_built: 2024-09-23T19:56Z
 urls:
   reference: https://apariciojohan.github.io/flexFitR/reference
   article: https://apariciojohan.github.io/flexFitR/articles
diff --git a/docs/reference/coef.modeler.html b/docs/reference/coef.modeler.html
index 4d7d40b..ce772a2 100644
--- a/docs/reference/coef.modeler.html
+++ b/docs/reference/coef.modeler.html
@@ -124,7 +124,7 @@ 

Examples#> #> Metrics: #> Groups Timing Convergence Iterations -#> 3 1.8005 secs 100% 414 (id) +#> 3 1.8156 secs 100% 414 (id) #> coef(mod_1, id = 2) #> # A tibble: 3 × 6 diff --git a/docs/reference/confint.modeler.html b/docs/reference/confint.modeler.html index 2aa0189..0c9ebd0 100644 --- a/docs/reference/confint.modeler.html +++ b/docs/reference/confint.modeler.html @@ -123,7 +123,7 @@

Examples#> #> Metrics: #> Groups Timing Convergence Iterations -#> 3 2.5273 secs 100% 410 (id) +#> 3 2.7826 secs 100% 410 (id) #> confint(mod_1) #> # A tibble: 9 × 6 diff --git a/docs/reference/metrics.html b/docs/reference/metrics.html index 6a5e4aa..3cb6e51 100644 --- a/docs/reference/metrics.html +++ b/docs/reference/metrics.html @@ -124,8 +124,8 @@

Examples#> 2 35.2 60.7 100.0 7.014 #> #> Metrics: -#> Groups Timing Convergence Iterations -#> 2 0.953 secs 100% 469 (id) +#> Groups Timing Convergence Iterations +#> 2 1.4931 secs 100% 469 (id) #> metrics(mod_1) #> # A tibble: 2 × 8 diff --git a/docs/reference/modeler.html b/docs/reference/modeler.html index 95c130c..6339ed4 100644 --- a/docs/reference/modeler.html +++ b/docs/reference/modeler.html @@ -235,7 +235,7 @@

Examples#> #> Metrics: #> Groups Timing Convergence Iterations -#> 1 0.9123 secs 100% 901 (id) +#> 1 1.5053 secs 100% 901 (id) #> # Example 2 mod_2 <- dt_potato |> @@ -265,8 +265,8 @@

Examples#> 195 38.7 62 100 1.88e-18 #> #> Metrics: -#> Groups Timing Convergence Iterations -#> 1 0.608 secs 100% 349 (id) +#> Groups Timing Convergence Iterations +#> 1 0.8373 secs 100% 349 (id) #>

diff --git a/docs/reference/plot.modeler.html b/docs/reference/plot.modeler.html index e68ab43..242f094 100644 --- a/docs/reference/plot.modeler.html +++ b/docs/reference/plot.modeler.html @@ -191,7 +191,7 @@

Examples#> #> Metrics: #> Groups Timing Convergence Iterations -#> 3 1.5726 secs 100% 499.67 (id) +#> 3 1.8776 secs 100% 499.67 (id) #> plot(mod_1, id = 1:2) diff --git a/docs/reference/predict.modeler.html b/docs/reference/predict.modeler.html index da84d07..f8360df 100644 --- a/docs/reference/predict.modeler.html +++ b/docs/reference/predict.modeler.html @@ -153,7 +153,7 @@

Examples#> #> Metrics: #> Groups Timing Convergence Iterations -#> 3 1.4683 secs 100% 414 (id) +#> 3 2.1496 secs 100% 414 (id) #> # Point Prediction predict(mod_1, x = 45, type = "point", id = 2) diff --git a/docs/reference/print.modeler.html b/docs/reference/print.modeler.html index b3cb0e2..6c0b588 100644 --- a/docs/reference/print.modeler.html +++ b/docs/reference/print.modeler.html @@ -115,7 +115,7 @@

Examples#> #> Metrics: #> Groups Timing Convergence Iterations -#> 5 2.3402 secs 100% 435.2 (id) +#> 5 3.4596 secs 100% 435.2 (id) #> diff --git a/docs/reference/vcov.modeler.html b/docs/reference/vcov.modeler.html index fac5b3a..96e9cdd 100644 --- a/docs/reference/vcov.modeler.html +++ b/docs/reference/vcov.modeler.html @@ -115,7 +115,7 @@

Examples#> #> Metrics: #> Groups Timing Convergence Iterations -#> 3 1.4468 secs 100% 414 (id) +#> 3 1.8317 secs 100% 414 (id) #> vcov(mod_1) #> $`2` diff --git a/docs/search.json b/docs/search.json index 63c7559..28860ec 100644 --- a/docs/search.json +++ b/docs/search.json @@ -1 +1 @@ -[{"path":"https://apariciojohan.github.io/flexFitR/articles/canopy-model.html","id":"loading-libraries","dir":"Articles","previous_headings":"","what":"Loading libraries","title":"Modelling Emergence and Maximun Canopy","text":"","code":"library(flexFitR) library(dplyr) library(kableExtra) library(ggpubr) library(purrr)"},{"path":"https://apariciojohan.github.io/flexFitR/articles/canopy-model.html","id":"exploring-data-explorer","dir":"Articles","previous_headings":"","what":"Exploring data explorer()","title":"Modelling Emergence and Maximun Canopy","text":"","code":"data(dt_potato) explorer <- explorer(dt_potato, x = DAP, y = Canopy, id = Plot) names(explorer) #> [1] \"summ_vars\" \"summ_metadata\" \"locals_min_max\" \"dt_long\" #> [5] \"metadata\""},{"path":"https://apariciojohan.github.io/flexFitR/articles/canopy-model.html","id":"data-exploration","dir":"Articles","previous_headings":"","what":"Data exploration","title":"Modelling Emergence and Maximun Canopy","text":"","code":"p1 <- plot(explorer, type = \"evolution\", return_gg = TRUE) p2 <- plot(explorer, type = \"x_by_var\", return_gg = TRUE) ggarrange(p1, p2)"},{"path":"https://apariciojohan.github.io/flexFitR/articles/canopy-model.html","id":"target-function","dir":"Articles","previous_headings":"","what":"Target Function","title":"Modelling Emergence and Maximun Canopy","text":"fn_piwise() \\[\\begin{equation} f(t; t_1, t_2, k) = \\begin{cases} 0 & \\text{} t < t_1 \\\\ \\dfrac{k}{t_2 - t_1} \\cdot (t - t_1) & \\text{} t_1 \\leq t \\leq t_2 \\\\ k & \\text{} t > t_2 \\end{cases} \\end{equation}\\]","code":""},{"path":"https://apariciojohan.github.io/flexFitR/articles/canopy-model.html","id":"fitting-models","dir":"Articles","previous_headings":"","what":"Fitting Models","title":"Modelling Emergence and Maximun Canopy","text":"","code":"mod_1 <- dt_potato |> modeler( x = DAP, y = Canopy, grp = Plot, fn = \"fn_piwise\", parameters = c(t1 = 45, t2 = 80, k = 0.9), subset = c(195, 40), add_zero = TRUE ) mod_1 #> #> Call: #> Canopy ~ fn_piwise(x, t1, t2, k) #> #> Sum of Squares Error: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> 390.5 1004.2 1618.0 1618.0 2231.8 2845.5 #> #> Optimization Results `head()`: #> uid t1 t2 k sse #> 40 34.8 53.7 72.5 2846 #> 195 38.7 60.0 91.7 390 #> #> Metrics: #> Groups Timing Convergence Iterations #> 2 0.866 secs 100% 547 (id) plot(mod_1, id = c(195, 40)) kable(mod_1$param)"},{"path":"https://apariciojohan.github.io/flexFitR/articles/canopy-model.html","id":"providing-different-initial-values","dir":"Articles","previous_headings":"","what":"Providing different initial values","title":"Modelling Emergence and Maximun Canopy","text":"","code":"initials <- data.frame( uid = c(195, 40), t1 = c(40, 60), t2 = c(70, 80), k = c(100, 100) ) kable(initials) mod_2 <- dt_potato |> modeler( x = DAP, y = Canopy, grp = Plot, fn = \"fn_piwise\", parameters = c(t1 = 45, t2 = 80, k = 0.9), initial_vals = initials, subset = c(195, 40), add_zero = TRUE ) plot(mod_2, id = c(195, 40)) kable(mod_2$param)"},{"path":"https://apariciojohan.github.io/flexFitR/articles/canopy-model.html","id":"fixing-some-parameters-of-the-model","dir":"Articles","previous_headings":"","what":"Fixing some parameters of the model","title":"Modelling Emergence and Maximun Canopy","text":"","code":"fixed_params <- data.frame(uid = c(195, 40), k = c(100, 100)) kable(fixed_params) mod_3 <- dt_potato |> modeler( x = DAP, y = Canopy, grp = Plot, fn = \"fn_piwise\", parameters = c(t1 = 45, t2 = 80, k = 0.9), fixed_params = fixed_params, subset = c(195, 40), add_zero = TRUE ) plot(mod_3, id = c(195, 40)) kable(mod_3$param)"},{"path":"https://apariciojohan.github.io/flexFitR/articles/canopy-model.html","id":"correcting-maximun-value","dir":"Articles","previous_headings":"","what":"Correcting Maximun value","title":"Modelling Emergence and Maximun Canopy","text":"","code":"mod_4 <- dt_potato |> modeler( x = DAP, y = Canopy, grp = Plot, fn = \"fn_piwise\", parameters = c(t1 = 45, t2 = 80, k = 0.9), fixed_params = fixed_params, subset = c(195, 40), add_zero = TRUE, max_as_last = TRUE ) plot(mod_4, id = c(195, 40)) kable(mod_4$param)"},{"path":"https://apariciojohan.github.io/flexFitR/articles/canopy-model.html","id":"comparing-models","dir":"Articles","previous_headings":"","what":"Comparing Models","title":"Modelling Emergence and Maximun Canopy","text":"","code":"rbind.data.frame( mutate(mod_1$param, mod = \"1\"), mutate(mod_2$param, mod = \"2\"), mutate(mod_3$param, mod = \"3\"), mutate(mod_4$param, mod = \"4\") ) |> filter(uid %in% 40) |> kable()"},{"path":"https://apariciojohan.github.io/flexFitR/articles/height-model.html","id":"loading-libraries","dir":"Articles","previous_headings":"","what":"Loading libraries","title":"Modelling Plant Height","text":"","code":"library(flexFitR) library(dplyr) library(kableExtra) library(ggpubr) library(purrr)"},{"path":"https://apariciojohan.github.io/flexFitR/articles/height-model.html","id":"exploring-data-explorer","dir":"Articles","previous_headings":"","what":"Exploring data explorer()","title":"Modelling Plant Height","text":"","code":"data(dt_chips) results <- explorer(dt_chips, x = DAP, y = c(PH, Canopy), id = Plot) names(results) #> [1] \"summ_vars\" \"summ_metadata\" \"locals_min_max\" \"dt_long\" #> [5] \"metadata\""},{"path":"https://apariciojohan.github.io/flexFitR/articles/height-model.html","id":"data-exploration","dir":"Articles","previous_headings":"","what":"Data exploration","title":"Modelling Plant Height","text":"","code":"p1 <- plot(results, type = \"evolution\", return_gg = TRUE) p2 <- plot(results, type = \"x_by_var\", return_gg = TRUE) ggarrange(p1, p2, nrow = 2)"},{"path":"https://apariciojohan.github.io/flexFitR/articles/height-model.html","id":"estimating-days-to-emergence","dir":"Articles","previous_headings":"","what":"Estimating days to emergence","title":"Modelling Plant Height","text":"\\[\\begin{equation} f(t; t_1, t_2, k) = \\begin{cases} 0 & \\text{} t < t_1 \\\\ \\dfrac{k}{t_2 - t_1} \\cdot (t - t_1) & \\text{} t_1 \\leq t \\leq t_2 \\\\ k & \\text{} t > t_2 \\end{cases} \\end{equation}\\]","code":""},{"path":"https://apariciojohan.github.io/flexFitR/articles/height-model.html","id":"fitting-models-for-canopy","dir":"Articles","previous_headings":"","what":"Fitting models for canopy","title":"Modelling Plant Height","text":"","code":"fixed_params <- results |> pluck(\"dt_long\") |> filter(var %in% \"Canopy\" & uid %in% c(195, 40)) |> group_by(uid) |> summarise(k = max(y), .groups = \"drop\") mod_1 <- dt_chips |> modeler( x = DAP, y = Canopy, grp = Plot, fn = \"fn_piwise\", parameters = c(t1 = 45, t2 = 80, k = 0.9), fixed_params = fixed_params, subset = c(195, 40), add_zero = TRUE, max_as_last = TRUE ) plot(mod_1, id = c(195, 40)) kable(mod_1$param)"},{"path":"https://apariciojohan.github.io/flexFitR/articles/height-model.html","id":"target-function-for-plant-height","dir":"Articles","previous_headings":"","what":"Target function for plant height","title":"Modelling Plant Height","text":"fn_exp2_exp() \\[\\begin{equation} f(t; t_1, t_2, \\alpha, \\beta) = \\begin{cases} 0 & \\text{} t < t_1 \\\\ e^{\\alpha \\cdot (t - t_1)^2} - 1 & \\text{} t_1 \\leq t \\leq t_2 \\\\ \\left(e^{\\alpha \\cdot (t_2 - t_1)^2} - 1\\right) \\cdot e^{\\beta \\cdot (t - t_2)} & \\text{} t > t_2 \\end{cases} \\end{equation}\\]","code":""},{"path":"https://apariciojohan.github.io/flexFitR/articles/height-model.html","id":"fixing-parameters-and-providing-initial-values","dir":"Articles","previous_headings":"","what":"Fixing parameters and providing initial values","title":"Modelling Plant Height","text":"","code":"fixed_params <- mod_1 |> pluck(\"param\") |> select(uid, t1) kable(fixed_params) initials <- mod_1 |> pluck(\"param\") |> select(uid, t1, t2) |> mutate(alpha = 1 / 600, beta = -1 / 30) kable(initials)"},{"path":"https://apariciojohan.github.io/flexFitR/articles/height-model.html","id":"fitting-models-for-plant-height","dir":"Articles","previous_headings":"","what":"Fitting models for plant height","title":"Modelling Plant Height","text":"Using t1 previous model fixed parameter using t2 initial parameter per plot.","code":"mod_2 <- dt_chips |> modeler( x = DAP, y = PH, grp = Plot, fn = \"fn_exp2_exp\", initial_vals = initials, fixed_params = fixed_params, subset = c(195, 40), add_zero = TRUE ) plot(mod_2, id = c(195, 40)) kable(mod_2$param)"},{"path":"https://apariciojohan.github.io/flexFitR/articles/how_to_start.html","id":"getting-started","dir":"Articles","previous_headings":"","what":"Getting started","title":"How to start","text":"basic idea vignette illustrate users use flexFitR package. ’ll start basic example: simple linear regression. Although example primary focus package, serve demonstrate use.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/articles/how_to_start.html","id":"simple-linear-regression","dir":"Articles","previous_headings":"","what":"1. Simple linear regression","title":"How to start","text":"example, ’ll work small dataset consisting 6 observations, X independent variable Y dependent variable. First, define objective function. case, function fn_lm represent linear regression, b intercept m slope regression. plot_fn function, integrated package, allows us plot function parameters provided. useful visualizing shape function fitting model data. fit model, use modeler function. function, pass x independent variable, y dependent variable, vector parameters assign initial values coefficient b coefficient m. model fitted, can examine output, extract estimated parameters, make plots, predict new x values. order get coefficients variance-covariance matrix make use coef vcov function, takes model object argument. Finally, can make predictions using predict function, takes fitted model object X value want make prediction. can compare lm function R, give results similar obtained package.","code":"library(flexFitR) library(dplyr) dt <- data.frame(X = 1:6, Y = c(12, 16, 44, 50, 95, 100)) plot(explorer(dt, X, Y), type = \"xy\") fn_lm <- function(x, b, m) { y <- b + m * x return(y) } plot_fn(fn = \"fn_lm\", params = c(b = 10, m = 5)) mod <- dt |> modeler( x = X, y = Y, fn = \"fn_lm\", parameters = c(b = -5, m = 10) ) mod #> #> Call: #> Y ~ fn_lm(x, b, m) #> #> Residuals: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> -12.5905 -6.0762 -0.3476 0.0000 6.1952 12.8952 #> #> Optimization Results `head()`: #> uid b m sse #> 1 -15.5 19.5 449 #> #> Metrics: #> Groups Timing Convergence Iterations #> 1 0.4098 secs 100% 259 (id) plot(mod) coef(mod) #> # A tibble: 2 × 6 #> uid coefficient solution std.error `t value` `Pr(>|t|)` #> #> 1 1 b -15.5 9.86 -1.57 0.192 #> 2 1 m 19.5 2.53 7.71 0.00152 vcov(mod) #> $`1` #> b m #> b 97.21937 -22.435238 #> m -22.43524 6.410068 predict(mod, x = 4.5) #> # A tibble: 1 × 4 #> uid x_new predicted.value std.error #> #> 1 1 4.5 72.3 5.01"},{"path":"https://apariciojohan.github.io/flexFitR/articles/how_to_start.html","id":"comparison-with-lm","dir":"Articles","previous_headings":"1. Simple linear regression","what":"Comparison with lm","title":"How to start","text":"previous example fairly simple, can consider complex scenario need fit just one function, hundreds functions several groups. can achieved using group_by argument modeler function. Additionally, can parallelize processes setting parallel argument TRUE defining number cores use. ’s important note depending functions defined user, parameters may need constrained, required greater less zero. cases, certain parameters might need fixed known values. complex situations, many curves fit working complex functions—whether non linear regressions specific parameter constraints cases parameters fixed group—modeler offers extensive flexibility.","code":"mo <- lm(Y ~ X, data = dt) mo #> #> Call: #> lm(formula = Y ~ X, data = dt) #> #> Coefficients: #> (Intercept) X #> -15.47 19.51 summary(mo)$coefficients #> Estimate Std. Error t value Pr(>|t|) #> (Intercept) -15.46667 9.859988 -1.568629 0.191812151 #> X 19.51429 2.531811 7.707639 0.001524882 vcov(mo) #> (Intercept) X #> (Intercept) 97.21937 -22.435238 #> X -22.43524 6.410068 predict(mo, newdata = data.frame(X = 4.5), se.fit = TRUE) #> $fit #> 1 #> 72.34762 #> #> $se.fit #> [1] 5.010599 #> #> $df #> [1] 4 #> #> $residual.scale #> [1] 10.59133"},{"path":"https://apariciojohan.github.io/flexFitR/articles/how_to_start.html","id":"piece-wise-regression","dir":"Articles","previous_headings":"","what":"2. Piece-wise regression","title":"How to start","text":"following example, although still simple, represents slightly complex function greater number parameters. case, piece-wise regression, parameterized t1, t2, k, defined following expression: fitting model, let’s take look example dataset. can make plot piecewise function fit model using modeler function. fitting model, can examine results, plot fitted curve, extract coefficients associated p-values, obtain variance-covariance matrix, make predictions unknown values x. Finally, illustrate provide different initial values function dealing multiple groups, also show fix parameters objective function.","code":"fun <- function(t, t1 = 45, t2 = 80, k = 0.9) { if (t < t1) { y <- 0 } else if (t >= t1 && t <= t2) { y <- k / (t2 - t1) * (t - t1) } else { y <- k } return(y) } dt <- data.frame( time = c(0, 29, 36, 42, 56, 76, 92, 100, 108), variable = c(0, 0, 0.67, 15.11, 77.38, 99.81, 99.81, 99.81, 99.81) ) plot(explorer(dt, time, variable), type = \"xy\") plot_fn(fn = \"fun\", params = c(t1 = 25, t2 = 70, k = 90)) mod_1 <- dt |> modeler( x = time, y = variable, fn = \"fun\", parameters = c(t1 = 45, t2 = 80, k = 90) ) mod_1 #> #> Call: #> variable ~ fun(x, t1, t2, k) #> #> Residuals: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> 0.00000 0.00000 0.00000 0.07444 0.00000 0.67000 #> #> Optimization Results `head()`: #> uid t1 t2 k sse #> 1 38.6 61 99.8 0.449 #> #> Metrics: #> Groups Timing Convergence Iterations #> 1 0.4163 secs 100% 511 (id) plot(mod_1) # Coefficients coef(mod_1) #> # A tibble: 3 × 6 #> uid coefficient solution std.error `t value` `Pr(>|t|)` #> #> 1 1 t1 38.6 0.0779 496. 4.54e-15 #> 2 1 t2 61.0 0.0918 665. 7.82e-16 #> 3 1 k 99.8 0.137 730. 4.47e-16 # Variance-Covariance Matrix vcov(mod_1) #> $`1` #> t1 t2 k #> t1 6.061705e-03 -0.002940001 1.877072e-07 #> t2 -2.940001e-03 0.008431400 4.204939e-03 #> k 1.877072e-07 0.004204939 1.870426e-02 # Making predictions predict(mod_1, x = 45) #> # A tibble: 1 × 4 #> uid x_new predicted.value std.error #> #> 1 1 45 28.5 0.223"},{"path":"https://apariciojohan.github.io/flexFitR/articles/how_to_start.html","id":"providing-initial-values","dir":"Articles","previous_headings":"2. Piece-wise regression","what":"Providing Initial values","title":"How to start","text":"example, don’t grouping variable. However, default, function assigns unique identifier (uid) dataset. , need specify uid = 1 initial values fixed parameters. one group, need modify parameters argument accordingly. approach primarily illustrative purposes.","code":"init <- data.frame(uid = 1, t1 = 20, t2 = 30, k = 0.8) mod_2 <- dt |> modeler( x = time, y = variable, fn = \"fun\", parameters = c(t1 = 45, t2 = 80, k = 90), initial_vals = init ) mod_2 #> #> Call: #> variable ~ fun(x, t1, t2, k) #> #> Residuals: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> 0.00000 0.00000 0.00000 0.07444 0.00000 0.67000 #> #> Optimization Results `head()`: #> uid t1 t2 k sse #> 1 38.6 61 99.8 0.449 #> #> Metrics: #> Groups Timing Convergence Iterations #> 1 0.4248 secs 100% 567 (id) coef(mod_2) #> # A tibble: 3 × 6 #> uid coefficient solution std.error `t value` `Pr(>|t|)` #> #> 1 1 t1 38.6 0.0779 496. 4.54e-15 #> 2 1 t2 61.0 0.0918 665. 7.82e-16 #> 3 1 k 99.8 0.137 730. 4.47e-16"},{"path":"https://apariciojohan.github.io/flexFitR/articles/how_to_start.html","id":"fixing-parameters","dir":"Articles","previous_headings":"2. Piece-wise regression","what":"Fixing parameters","title":"How to start","text":"vignette provided basic introduction using flexFitR package, starting simple examples linear regression piecewise regression. goal demonstrate fundamental features flexibility package. However, complex situations can arise working high-throughput phenotypic (HTP) data, involve multiple groups, parameter constraints, advanced modeling scenarios. complex situations illustrated vignettes, use real HTP data showcase full capabilities flexFitR package.","code":"fix <- data.frame(uid = 1, k = 98) mod_3 <- dt |> modeler( x = time, y = variable, fn = \"fun\", parameters = c(t1 = 45, t2 = 80, k = 90), fixed_params = fix ) mod_3 #> #> Call: #> variable ~ fun(x, t1, t2, k) #> #> Residuals: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> 0.0000 0.0000 0.6700 0.8789 1.8100 1.8100 #> #> Optimization Results `head()`: #> uid t1 t2 sse k #> 1 38.6 60.6 13.6 98 #> #> Metrics: #> Groups Timing Convergence Iterations #> 1 0.3857 secs 100% 321 (id) coef(mod_3) #> # A tibble: 2 × 6 #> uid coefficient solution std.error `t value` `Pr(>|t|)` #> #> 1 1 t1 38.6 0.396 97.5 3.15e-12 #> 2 1 t2 60.6 0.429 141. 2.34e-13 plot(mod_3) rbind(metrics(mod_1), metrics(mod_2), metrics(mod_3)) #> # A tibble: 3 × 8 #> uid var SSE MAE MSE RMSE r_squared n #> #> 1 1 variable 0.449 0.0744 0.0499 0.223 1.00 9 #> 2 1 variable 0.449 0.0744 0.0499 0.223 1.00 9 #> 3 1 variable 13.6 0.879 1.51 1.23 0.999 9"},{"path":"https://apariciojohan.github.io/flexFitR/articles/maturity-model.html","id":"loading-libraries","dir":"Articles","previous_headings":"","what":"Loading libraries","title":"Modelling Maturity","text":"","code":"library(flexFitR) library(dplyr) library(kableExtra) library(ggpubr) library(purrr)"},{"path":"https://apariciojohan.github.io/flexFitR/articles/maturity-model.html","id":"exploring-data-explorer","dir":"Articles","previous_headings":"","what":"Exploring data explorer()","title":"Modelling Maturity","text":"","code":"data(dt_potato) results <- explorer(dt_potato, x = DAP, y = c(Canopy, GLI_2), id = Plot) names(results) #> [1] \"summ_vars\" \"summ_metadata\" \"locals_min_max\" \"dt_long\" #> [5] \"metadata\""},{"path":"https://apariciojohan.github.io/flexFitR/articles/maturity-model.html","id":"data-exploration","dir":"Articles","previous_headings":"","what":"Data exploration","title":"Modelling Maturity","text":"","code":"p1 <- plot(results, type = \"evolution\", return_gg = TRUE) p2 <- plot(results, type = \"x_by_var\", return_gg = TRUE) ggarrange(p1, p2, nrow = 2)"},{"path":"https://apariciojohan.github.io/flexFitR/articles/maturity-model.html","id":"target-function-for-maturity","dir":"Articles","previous_headings":"","what":"Target function for maturity","title":"Modelling Maturity","text":"fn_lin_pl_lin() \\[\\begin{equation} f(t; t_1, t_2, t_3, k, \\beta) = \\begin{cases} 0 & \\text{} t < t_1 \\\\ \\dfrac{k}{t_2 - t_1} \\cdot (t - t_1) & \\text{} t_1 \\leq t \\leq t_2 \\\\ k & \\text{} t_2 \\leq t \\leq t_3 \\\\ k + \\beta \\cdot (t - t_3) & \\text{} t > t_3 \\end{cases} \\end{equation}\\]","code":""},{"path":"https://apariciojohan.github.io/flexFitR/articles/maturity-model.html","id":"fitting-models-for-maturity","dir":"Articles","previous_headings":"","what":"Fitting models for maturity","title":"Modelling Maturity","text":"","code":"mod_1 <- dt_potato |> modeler( x = DAP, y = GLI_2, grp = Plot, fn = \"fn_lin_pl_lin\", parameters = c(t1 = 38.7, t2 = 62, t3 = 90, k = 0.32, beta = -0.01), subset = c(195, 40), add_zero = TRUE ) plot(mod_1, id = c(195, 40)) kable(mod_1$param)"},{"path":"https://apariciojohan.github.io/flexFitR/articles/maturity-model.html","id":"providing-initial-parameters-from-the-canopy-model","dir":"Articles","previous_headings":"","what":"Providing initial parameters from the canopy model","title":"Modelling Maturity","text":"","code":"fixed_params <- results |> pluck(\"dt_long\") |> filter(var %in% \"Canopy\" & uid %in% c(195, 40)) |> group_by(uid) |> summarise(k = max(y), .groups = \"drop\") mod_2 <- dt_potato |> modeler( x = DAP, y = Canopy, grp = Plot, fn = \"fn_piwise\", parameters = c(t1 = 45, t2 = 80, k = 0.9), fixed_params = fixed_params, subset = c(195, 40), add_zero = TRUE, max_as_last = TRUE ) plot(mod_2, id = c(195, 40)) kable(mod_2$param)"},{"path":"https://apariciojohan.github.io/flexFitR/articles/maturity-model.html","id":"passing-initial-values","dir":"Articles","previous_headings":"","what":"Passing initial values","title":"Modelling Maturity","text":"","code":"initials <- mod_2 |> pluck(\"param\") |> select(uid, t1, t2) |> mutate(t3 = 100, k = 0.32, beta = -0.01) kable(initials) mod_3 <- dt_potato |> modeler( x = DAP, y = GLI_2, grp = Plot, fn = \"fn_lin_pl_lin\", initial_vals = initials, subset = c(195, 40), add_zero = TRUE ) plot(mod_3, id = c(195, 40)) kable(mod_3$param)"},{"path":"https://apariciojohan.github.io/flexFitR/articles/maturity-model.html","id":"adding-constrains-to-the-optimization","dir":"Articles","previous_headings":"","what":"Adding constrains to the optimization","title":"Modelling Maturity","text":"","code":"mod_4 <- dt_potato |> modeler( x = DAP, y = GLI_2, grp = Plot, fn = \"fn_lin_pl_lin2\", parameters = c(t1 = 38.7, t2 = 62, dt = 28, k = 0.32, beta = -0.01), lower = c(-Inf, -Inf, 0, -Inf, -Inf), upper = c(Inf, Inf, Inf, Inf, 0), method = c(\"nlminb\", \"L-BFGS-B\"), subset = c(195, 40), add_zero = TRUE ) plot(mod_4, id = c(195, 40)) kable(mod_4$param)"},{"path":"https://apariciojohan.github.io/flexFitR/articles/plotting.html","id":"example-dataset-and-loading-libraries","dir":"Articles","previous_headings":"","what":"Example dataset and loading libraries","title":"Plotting Options","text":"","code":"library(flexFitR) library(dplyr) library(ggpubr) set.seed(10) dt <- data.frame( time = c(0, 29, 36, 42, 56, 76, 92, 100, 108), variable = c(0, 0, 0.67, 15.11, 77.38, 99.81, 99.81, 99.81, 99.81) ) |> mutate(variable = variable + rnorm(n = n(), mean = 5, sd = 6))"},{"path":"https://apariciojohan.github.io/flexFitR/articles/plotting.html","id":"expectation-function-and-modeling","dir":"Articles","previous_headings":"","what":"Expectation function and modeling","title":"Plotting Options","text":"","code":"fn <- function(t, t0, t1, t2) t0 / (1 + exp((t1 - t) / t2)) mod <- dt |> modeler( x = time, y = variable, fn = \"fn\", parameters = c(t0 = 100, t1 = 50, t2 = 5) ) mod #> #> Call: #> variable ~ fn(x, t0, t1, t2) #> #> Residuals: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> -6.1496 -2.9462 2.1181 0.4716 3.2479 6.7654 #> #> Optimization Results `head()`: #> uid t0 t1 t2 sse #> 1 101 49.2 4.01 169 #> #> Metrics: #> Groups Timing Convergence Iterations #> 1 0.3862 secs 100% 334 (id)"},{"path":"https://apariciojohan.github.io/flexFitR/articles/plotting.html","id":"plotting-predictions-and-derivatives","dir":"Articles","previous_headings":"","what":"Plotting predictions and derivatives","title":"Plotting Options","text":"","code":"a <- plot(mod, color = \"blue\", title = \"Raw - data\") b <- plot(mod, type = 4, n_points = 200, color = \"black\") c <- plot(mod, type = 5, n_points = 200, color = \"black\") d <- plot(mod, type = 6, n_points = 200, color = \"black\") ggarrange(a, b, c, d)"},{"path":"https://apariciojohan.github.io/flexFitR/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Johan Aparicio. Author, maintainer. Jeffrey Endelman. Author. University Wisconsin Madison. Copyright holder.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Aparicio J, Endelman J (2024). flexFitR: Flexible Non-Linear Least Square Modelling. R package version 0.1.0, https://github.com/AparicioJohan/flexFitR, https://apariciojohan.github.io/flexFitR/.","code":"@Manual{, title = {flexFitR: Flexible Non-Linear Least Square Modelling}, author = {Johan Aparicio and Jeffrey Endelman}, year = {2024}, note = {R package version 0.1.0, https://github.com/AparicioJohan/flexFitR}, url = {https://apariciojohan.github.io/flexFitR/}, }"},{"path":[]},{"path":"https://apariciojohan.github.io/flexFitR/CODE_OF_CONDUCT.html","id":"our-pledge","dir":"","previous_headings":"","what":"Our Pledge","title":"Contributor Covenant Code of Conduct","text":"members, contributors, leaders pledge make participation community harassment-free experience everyone, regardless age, body size, visible invisible disability, ethnicity, sex characteristics, gender identity expression, level experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, sexual identity orientation. pledge act interact ways contribute open, welcoming, diverse, inclusive, healthy community.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/CODE_OF_CONDUCT.html","id":"our-standards","dir":"","previous_headings":"","what":"Our Standards","title":"Contributor Covenant Code of Conduct","text":"Examples behavior contributes positive environment community include: Demonstrating empathy kindness toward people respectful differing opinions, viewpoints, experiences Giving gracefully accepting constructive feedback Accepting responsibility apologizing affected mistakes, learning experience Focusing best just us individuals, overall community Examples unacceptable behavior include: use sexualized language imagery, sexual attention advances kind Trolling, insulting derogatory comments, personal political attacks Public private harassment Publishing others’ private information, physical email address, without explicit permission conduct reasonably considered inappropriate professional setting","code":""},{"path":"https://apariciojohan.github.io/flexFitR/CODE_OF_CONDUCT.html","id":"enforcement-responsibilities","dir":"","previous_headings":"","what":"Enforcement Responsibilities","title":"Contributor Covenant Code of Conduct","text":"Community leaders responsible clarifying enforcing standards acceptable behavior take appropriate fair corrective action response behavior deem inappropriate, threatening, offensive, harmful. Community leaders right responsibility remove, edit, reject comments, commits, code, wiki edits, issues, contributions aligned Code Conduct, communicate reasons moderation decisions appropriate.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/CODE_OF_CONDUCT.html","id":"scope","dir":"","previous_headings":"","what":"Scope","title":"Contributor Covenant Code of Conduct","text":"Code Conduct applies within community spaces, also applies individual officially representing community public spaces. Examples representing community include using official e-mail address, posting via official social media account, acting appointed representative online offline event.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/CODE_OF_CONDUCT.html","id":"enforcement","dir":"","previous_headings":"","what":"Enforcement","title":"Contributor Covenant Code of Conduct","text":"Instances abusive, harassing, otherwise unacceptable behavior may reported community leaders responsible enforcement johanstevenapa@gmail.com. complaints reviewed investigated promptly fairly. community leaders obligated respect privacy security reporter incident.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/CODE_OF_CONDUCT.html","id":"enforcement-guidelines","dir":"","previous_headings":"","what":"Enforcement Guidelines","title":"Contributor Covenant Code of Conduct","text":"Community leaders follow Community Impact Guidelines determining consequences action deem violation Code Conduct:","code":""},{"path":"https://apariciojohan.github.io/flexFitR/CODE_OF_CONDUCT.html","id":"id_1-correction","dir":"","previous_headings":"Enforcement Guidelines","what":"1. Correction","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Use inappropriate language behavior deemed unprofessional unwelcome community. Consequence: private, written warning community leaders, providing clarity around nature violation explanation behavior inappropriate. public apology may requested.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/CODE_OF_CONDUCT.html","id":"id_2-warning","dir":"","previous_headings":"Enforcement Guidelines","what":"2. Warning","title":"Contributor Covenant Code of Conduct","text":"Community Impact: violation single incident series actions. Consequence: warning consequences continued behavior. interaction people involved, including unsolicited interaction enforcing Code Conduct, specified period time. includes avoiding interactions community spaces well external channels like social media. Violating terms may lead temporary permanent ban.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/CODE_OF_CONDUCT.html","id":"id_3-temporary-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"3. Temporary Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: serious violation community standards, including sustained inappropriate behavior. Consequence: temporary ban sort interaction public communication community specified period time. public private interaction people involved, including unsolicited interaction enforcing Code Conduct, allowed period. Violating terms may lead permanent ban.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/CODE_OF_CONDUCT.html","id":"id_4-permanent-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"4. Permanent Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Demonstrating pattern violation community standards, including sustained inappropriate behavior, harassment individual, aggression toward disparagement classes individuals. Consequence: permanent ban sort public interaction within community.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/CODE_OF_CONDUCT.html","id":"attribution","dir":"","previous_headings":"","what":"Attribution","title":"Contributor Covenant Code of Conduct","text":"Code Conduct adapted Contributor Covenant, version 2.1, available https://www.contributor-covenant.org/version/2/1/code_of_conduct.html. Community Impact Guidelines inspired [Mozilla’s code conduct enforcement ladder][https://github.com/mozilla/inclusion]. answers common questions code conduct, see FAQ https://www.contributor-covenant.org/faq. Translations available https://www.contributor-covenant.org/translations.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/index.html","id":"flexfitr-","dir":"","previous_headings":"","what":"Flexible Non-Linear Least Square Modelling","title":"Flexible Non-Linear Least Square Modelling","text":"flexFitR R package designed efficient modeling analysis large complex datasets. offers powerful tools parameter estimation, model fitting, visualization, leveraging {optimx} package optimization future package parallel processing.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Flexible Non-Linear Least Square Modelling","text":"can install development version flexFitR GitHub :","code":"# install.packages(\"devtools\") devtools::install_github(\"AparicioJohan/flexFitR\")"},{"path":"https://apariciojohan.github.io/flexFitR/index.html","id":"features","dir":"","previous_headings":"","what":"Features","title":"Flexible Non-Linear Least Square Modelling","text":"Parameter Estimation: Utilizes {optimx} derivative-free algorithms solve estimate parameters given function. Parallelization: Implements parallel processing using future package, enabling efficient fitting hundreds curves simultaneously. Visualization Tools: Provides variety plots visualize model fits, correlations, predictions, . Statistical Rigor: Offers standard errors p-values coefficients, supporting robust conclusions interpretations. Prediction: Facilitates prediction non-observed data points. Flexibility: Allows users fix certain parameters model specify different initial values per grouping factor. Custom Modeling Functions: Equipped built-modeling functions common analysis tasks, also permitting users supply custom functions.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/index.html","id":"example","dir":"","previous_headings":"","what":"Example","title":"Flexible Non-Linear Least Square Modelling","text":"’s simple example get started flexFitR. example demonstrates fitting piecewise regression model:","code":"library(flexFitR) dt <- data.frame( time = c(0, 29, 36, 42, 56, 76, 92, 100, 108), variable = c(0, 0, 0.67, 15.11, 77.38, 99.81, 99.81, 99.81, 99.81) ) plot(explorer(dt, time, variable), type = \"xy\") fun <- function(t, t1 = 45, t2 = 80, k = 0.9) { if (t < t1) { y <- 0 } else if (t >= t1 && t <= t2) { y <- k / (t2 - t1) * (t - t1) } else { y <- k } return(y) } # Fitting piecewise regression mod_1 <- dt |> modeler( x = time, y = variable, fn = \"fun\", parameters = c(t1 = 45, t2 = 80, k = 90) ) print(mod_1) Call: variable ~ fun(x, t1, t2, k) Residuals: Min. 1st Qu. Median Mean 3rd Qu. Max. 0.00000 0.00000 0.00000 0.07444 0.00000 0.67000 Optimization Results `head()`: uid t1 t2 k sse 1 38.6 61 99.8 0.449 Metrics: Groups Timing Convergence Iterations 1 0.4068 secs 100% 511 (id) # Auto plot plot(mod_1) # Coefficients coef(mod_1) # A tibble: 3 × 6 uid coefficient solution std.error `t value` `Pr(>|t|)` 1 1 t1 38.6 0.0779 496. 4.54e-15 2 1 t2 61.0 0.0918 665. 7.82e-16 3 1 k 99.8 0.137 730. 4.47e-16 # Variance-Covariance Matrix vcov(mod_1) $`1` t1 t2 k t1 6.061705e-03 -0.002940001 1.877072e-07 t2 -2.940001e-03 0.008431400 4.204939e-03 k 1.877072e-07 0.004204939 1.870426e-02 # Making predictions predict(mod_1, x = 45) # A tibble: 1 × 4 uid x_new predicted.value std.error 1 1 45 28.5 0.223"},{"path":"https://apariciojohan.github.io/flexFitR/index.html","id":"documentation","dir":"","previous_headings":"","what":"Documentation","title":"Flexible Non-Linear Least Square Modelling","text":"detailed documentation examples, visit flexFitR Vignette 1: start Vignette 2: Modeling Canopy Vignette 3: Modeling Plant Height Vignette 4: Modeling VIs","code":""},{"path":"https://apariciojohan.github.io/flexFitR/index.html","id":"contributing","dir":"","previous_headings":"","what":"Contributing","title":"Flexible Non-Linear Least Square Modelling","text":"Contributions flexFitR welcome! ’d like contribute, please fork repository submit pull request. significant changes, please open issue first discuss ideas.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/index.html","id":"code-of-conduct","dir":"","previous_headings":"","what":"Code of Conduct","title":"Flexible Non-Linear Least Square Modelling","text":"Please note flexFitR project released Contributor Code Conduct. contributing project, agree abide terms.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/index.html","id":"license","dir":"","previous_headings":"","what":"License","title":"Flexible Non-Linear Least Square Modelling","text":"flexFitR licensed MIT License. See LICENSE file details.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2024 flexFitR authors Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/anova.modeler.html","id":null,"dir":"Reference","previous_headings":"","what":"Extra sum-of-squares F-test for objects of class modeler — anova.modeler","title":"Extra sum-of-squares F-test for objects of class modeler — anova.modeler","text":"anova objects class modeler","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/anova.modeler.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Extra sum-of-squares F-test for objects of class modeler — anova.modeler","text":"","code":"# S3 method for class 'modeler' anova(reduced_model, full_model = NULL, ...)"},{"path":"https://apariciojohan.github.io/flexFitR/reference/anova.modeler.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Extra sum-of-squares F-test for objects of class modeler — anova.modeler","text":"reduced_model object class `modeler` reduced number parameters. full_model object class `modeler` number parameters. ... parameters. future improvements.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/anova.modeler.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Extra sum-of-squares F-test for objects of class modeler — anova.modeler","text":"tibble columns giving F test p values.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/anova.modeler.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Extra sum-of-squares F-test for objects of class modeler — anova.modeler","text":"Johan Aparicio [aut]","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/anova.modeler.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Extra sum-of-squares F-test for objects of class modeler — anova.modeler","text":"","code":"library(flexFitR) dt <- data.frame(X = 1:6, Y = c(12, 16, 44, 50, 95, 100)) mo_1 <- modeler(dt, X, Y, fn = \"fn_lin\", param = c(m = 10, b = -5)) #> Loading required package: foreach #> Loading required package: future plot(mo_1) mo_2 <- modeler(dt, X, Y, fn = \"fn_quad\", param = c(a = 1, b = 10, c = 5)) plot(mo_2) anova(mo_1, mo_2) #> # A tibble: 1 × 9 #> uid RSS_reduced RSS_full n df1 df2 F `Pr(>F)` . #> #> 1 1 449. 385. 6 1 3 0.494 0.533 ns"},{"path":"https://apariciojohan.github.io/flexFitR/reference/coef.modeler.html","id":null,"dir":"Reference","previous_headings":"","what":"Coefficients of an object of class modeler — coef.modeler","title":"Coefficients of an object of class modeler — coef.modeler","text":"Coefficients object class modeler","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/coef.modeler.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Coefficients of an object of class modeler — coef.modeler","text":"","code":"# S3 method for class 'modeler' coef(x, id = NULL, metadata = FALSE, df = FALSE, ...)"},{"path":"https://apariciojohan.github.io/flexFitR/reference/coef.modeler.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Coefficients of an object of class modeler — coef.modeler","text":"x object inheriting class modeler resulting executing function modeler() id unique identifier filter . NULL default. metadata TRUE FALSE. Whether bring metadata calculating coefficients. df TRUE FALSE. Whether return degrees freedom calculating coefficients. FALSE default. ... parameters. future improvements.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/coef.modeler.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Coefficients of an object of class modeler — coef.modeler","text":"data.frame object coefficients standard errors.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/coef.modeler.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Coefficients of an object of class modeler — coef.modeler","text":"Johan Aparicio [aut]","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/coef.modeler.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Coefficients of an object of class modeler — coef.modeler","text":"","code":"library(flexFitR) data(dt_potato) explorer <- explorer(dt_potato, x = DAP, y = c(Canopy, GLI_2), id = Plot) mod_1 <- dt_potato |> modeler( x = DAP, y = Canopy, grp = Plot, fn = \"fn_piwise\", parameters = c(t1 = 45, t2 = 80, k = 0.9), subset = c(15, 2, 45), add_zero = TRUE, max_as_last = TRUE ) print(mod_1) #> #> Call: #> Canopy ~ fn_piwise(x, t1, t2, k) #> #> Sum of Squares Error: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> 0.002601 0.504829 1.007057 2.674719 4.010777 7.014498 #> #> Optimization Results `head()`: #> uid t1 t2 k sse #> 2 35.2 60.7 100.0 7.0145 #> 15 38.5 69.4 99.8 1.0071 #> 45 38.3 64.5 100.0 0.0026 #> #> Metrics: #> Groups Timing Convergence Iterations #> 3 1.8005 secs 100% 414 (id) #> coef(mod_1, id = 2) #> # A tibble: 3 × 6 #> uid coefficient solution std.error `t value` `Pr(>|t|)` #> #> 1 2 t1 35.2 0.239 147. 6.57e-12 #> 2 2 t2 60.7 0.371 164. 3.53e-12 #> 3 2 k 100. 0.541 185. 1.68e-12"},{"path":"https://apariciojohan.github.io/flexFitR/reference/confint.modeler.html","id":null,"dir":"Reference","previous_headings":"","what":"Confidence Intervals for an object of class modeler — confint.modeler","title":"Confidence Intervals for an object of class modeler — confint.modeler","text":"confint object class modeler","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/confint.modeler.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Confidence Intervals for an object of class modeler — confint.modeler","text":"","code":"# S3 method for class 'modeler' confint(x, parm = NULL, level = 0.95, id = NULL, ...)"},{"path":"https://apariciojohan.github.io/flexFitR/reference/confint.modeler.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Confidence Intervals for an object of class modeler — confint.modeler","text":"x object inheriting class modeler resulting executing function modeler() parm specification parameters given confidence intervals, must vector names. missing, parameters considered. level confidence level required. Default 0.95. id unique identifier filter . NULL default. ... parameters. future improvements.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/confint.modeler.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Confidence Intervals for an object of class modeler — confint.modeler","text":"tibble columns giving lower upper confidence limits parameter.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/confint.modeler.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Confidence Intervals for an object of class modeler — confint.modeler","text":"Johan Aparicio [aut]","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/confint.modeler.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Confidence Intervals for an object of class modeler — confint.modeler","text":"","code":"library(flexFitR) data(dt_potato) mod_1 <- dt_potato |> modeler( x = DAP, y = Canopy, grp = Plot, fn = \"fn_piwise\", parameters = c(t1 = 45, t2 = 80, k = 0.9), subset = c(15, 35, 45), add_zero = TRUE, max_as_last = TRUE ) print(mod_1) #> #> Call: #> Canopy ~ fn_piwise(x, t1, t2, k) #> #> Sum of Squares Error: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> 0.002601 0.504829 1.007057 0.968957 1.452134 1.897212 #> #> Optimization Results `head()`: #> uid t1 t2 k sse #> 15 38.5 69.4 99.8 1.0071 #> 35 52.2 61.4 100.0 1.8972 #> 45 38.3 64.5 100.0 0.0026 #> #> Metrics: #> Groups Timing Convergence Iterations #> 3 2.5273 secs 100% 410 (id) #> confint(mod_1) #> # A tibble: 9 × 6 #> uid coefficient solution std.error ci_lower ci_upper #> #> 1 15 t1 38.5 0.162 38.1 38.8 #> 2 15 t2 69.4 0.283 68.7 70.1 #> 3 15 k 99.8 0.205 99.3 100. #> 4 35 t1 52.2 2.00 47.3 57.1 #> 5 35 t2 61.4 2.87 54.4 68.5 #> 6 35 k 100. 0.281 99.3 101. #> 7 45 t1 38.3 0.00704 38.3 38.3 #> 8 45 t2 64.5 0.00972 64.4 64.5 #> 9 45 k 100. 0.0104 100. 100."},{"path":"https://apariciojohan.github.io/flexFitR/reference/dot-fitter_curve.html","id":null,"dir":"Reference","previous_headings":"","what":"General-purpose optimization — .fitter_curve","title":"General-purpose optimization — .fitter_curve","text":"function .fitter_curve used internally find parameters requested.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/dot-fitter_curve.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"General-purpose optimization — .fitter_curve","text":"","code":".fitter_curve(data, id, fn, method, lower, upper, control, .keep)"},{"path":"https://apariciojohan.github.io/flexFitR/reference/dot-fitter_curve.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"General-purpose optimization — .fitter_curve","text":"data nested data.frame columns . id optional vector IDs filter data. Default NULL, meaning ids used. fn string specifying name function used curve fitting. Default \"fn_piwise\". method character vector specifying optimization methods used. See optimx package available methods. Default c(\"subplex\", \"pracmanm\", \"anms\"). lower Numeric vector specifying lower bounds parameters. Default -Inf parameters. upper Numeric vector specifying upper bounds parameters. Default Inf parameters. control list control parameters passed optimization function. example, list(maxit = 500).","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/dot-fitter_curve.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"General-purpose optimization — .fitter_curve","text":"","code":"library(flexFitR) data(dt_potato) explorer <- explorer(dt_potato, x = DAP, y = c(Canopy, GLI_2), id = Plot) mod_1 <- dt_potato |> modeler( x = DAP, y = GLI_2, grp = Plot, fn = \"fn_lin_pl_lin\", parameters = c(t1 = 38.7, t2 = 62, t3 = 90, k = 0.32, beta = -0.01), subset = 195, add_zero = TRUE )"},{"path":"https://apariciojohan.github.io/flexFitR/reference/dt_chips.html","id":null,"dir":"Reference","previous_headings":"","what":"Drone Data in Potato 2022 — dt_chips","title":"Drone Data in Potato 2022 — dt_chips","text":"Vegetative indices biomass related traits potato trial arranged p-rep design.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/dt_chips.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Drone Data in Potato 2022 — dt_chips","text":"","code":"dt_chips"},{"path":"https://apariciojohan.github.io/flexFitR/reference/dt_chips.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Drone Data in Potato 2022 — dt_chips","text":"tibble 1568 rows 17 variables: Trial chr trial name DAP dbl denoting Days planting Plot dbl denoting unique plot id Row dbl denoting row coordinate Range dbl denoting range coordinate Gen chr denoting genotype id Yield dbl Total Yield measured end season VineMaturity dbl VineMaturity measure season Red - Canopy dbl denoting drone-derived traits","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/dt_chips.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Drone Data in Potato 2022 — dt_chips","text":"UW - Potato Breeding Program","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/dt_potato.html","id":null,"dir":"Reference","previous_headings":"","what":"Drone Data in Potato 2020 — dt_potato","title":"Drone Data in Potato 2020 — dt_potato","text":"Vegetative indices biomass related traits potato trial arranged p-rep design.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/dt_potato.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Drone Data in Potato 2020 — dt_potato","text":"","code":"dt_potato"},{"path":"https://apariciojohan.github.io/flexFitR/reference/dt_potato.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Drone Data in Potato 2020 — dt_potato","text":"tibble 1372 rows 17 variables: Trial chr trial name DAP dbl denoting Days planting Plot dbl denoting unique plot id Row dbl denoting row coordinate Range dbl denoting range coordinate Gen chr denoting genotype id Yield dbl Total Yield measured end season VineMaturity dbl VineMaturity measure season Red - Canopy dbl denoting drone-derived traits","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/dt_potato.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Drone Data in Potato 2020 — dt_potato","text":"UW - Potato Breeding Program","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/explorer.html","id":null,"dir":"Reference","previous_headings":"","what":"Explore Data — explorer","title":"Explore Data — explorer","text":"Explores data data frame wide format.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/explorer.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Explore Data — explorer","text":"","code":"explorer(data, x, y, id, metadata)"},{"path":"https://apariciojohan.github.io/flexFitR/reference/explorer.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Explore Data — explorer","text":"data data.frame wide format containing data. x name column `data` contains x points. y names columns `data` contain variables analyzed. id names columns `data` contains grouping variable. metadata names columns `data` keep across analysis.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/explorer.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Explore Data — explorer","text":"object class explorer, list containing following elements: summ_vars data.frame containing summary statistics trait x point, including minimum, mean, median, maximum, standard deviation, coefficient variation, number non-missing values, percentage missing values, percentage negative values. summ_metadata data.frame summarizing metadata. locals_min_max data.frame containing local minima maxima mean y values x. dt_long data.frame long format, columns uid, metadata, var, x, y metadata character vector names variables keep across.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/explorer.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Explore Data — explorer","text":"function helps explore dataset analyzed modeler().","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/explorer.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Explore Data — explorer","text":"","code":"library(flexFitR) data(dt_potato) results <- dt_potato |> explorer( x = DAP, y = c(Canopy, PH), id = Plot, metadata = c(Gen, Row, Range) ) names(results) #> [1] \"summ_vars\" \"summ_metadata\" \"locals_min_max\" \"dt_long\" #> [5] \"metadata\" head(results$summ_vars) #> # A tibble: 6 × 12 #> var x Min Mean Median Max SD CV n miss `miss%` #> #> 1 Canopy 29 0 0 0 0 0 NaN 196 0 0 #> 2 Canopy 36 0 2.95 1.84 15.1 3.22 1.09 196 0 0 #> 3 Canopy 42 0.763 23.4 22.9 46.2 9.31 0.398 196 0 0 #> 4 Canopy 56 33.4 75.8 75.2 98.9 12.4 0.164 196 0 0 #> 5 Canopy 76 89.1 99.7 100 100 1.04 0.0104 196 0 0 #> 6 Canopy 92 62.5 97.0 98.4 100. 4.36 0.0449 196 0 0 #> # ℹ 1 more variable: `neg%` plot(results, label_size = 4, signif = TRUE, n_row = 2) # New data format head(results$dt_long) #> # A tibble: 6 × 7 #> uid Gen Row Range var x y #> #> 1 1 W17037-24 1 1 Canopy 29 0 #> 2 1 W17037-24 1 1 PH 29 NA #> 3 1 W17037-24 1 1 Canopy 36 0.67 #> 4 1 W17037-24 1 1 PH 36 0.0154 #> 5 1 W17037-24 1 1 Canopy 42 15.1 #> 6 1 W17037-24 1 1 PH 42 0.0173"},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp1_exp.html","id":null,"dir":"Reference","previous_headings":"","what":"Exponential Exponential Function 1 — fn_exp1_exp","title":"Exponential Exponential Function 1 — fn_exp1_exp","text":"Computes value based exponential growth curve exponential decay model time.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp1_exp.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Exponential Exponential Function 1 — fn_exp1_exp","text":"","code":"fn_exp1_exp(t, t1, t2, alpha, beta)"},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp1_exp.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Exponential Exponential Function 1 — fn_exp1_exp","text":"t Numeric. time value. t1 Numeric. lower threshold time. Assumed known. t2 Numeric. upper threshold time. alpha Numeric. parameter first exponential term. Must greater 0. beta Numeric. parameter second exponential term. Must less 0.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp1_exp.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Exponential Exponential Function 1 — fn_exp1_exp","text":"numeric value based double exponential model. t less t1, function returns 0. t t1 t2 (inclusive), function returns exp(alpha * (t - t1)) - 1. t greater t2, function returns (exp(alpha * (t2 - t1)) - 1) * exp(beta * (t - t2)).","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp1_exp.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Exponential Exponential Function 1 — fn_exp1_exp","text":"$$ f(t; t_1, t_2, \\alpha, \\beta) = \\begin{cases} 0 & \\text{} t < t_1 \\\\ e^{\\alpha \\cdot (t - t_1)} - 1 & \\text{} t_1 \\leq t \\leq t_2 \\\\ \\left(e^{\\alpha \\cdot (t_2 - t_1)} - 1\\right) \\cdot e^{\\beta \\cdot (t - t_2)} & \\text{} t > t_2 \\end{cases} $$","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp1_exp.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Exponential Exponential Function 1 — fn_exp1_exp","text":"","code":"library(flexFitR) plot_fn( fn = \"fn_exp1_exp\", params = c(t1 = 35, t2 = 55, alpha = 1 / 20, beta = -1 / 30), interval = c(0, 108), n_points = 2000, auc_label_size = 3, y_auc_label = 0.2 )"},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp1_lin.html","id":null,"dir":"Reference","previous_headings":"","what":"Exponential Linear Function 1 — fn_exp1_lin","title":"Exponential Linear Function 1 — fn_exp1_lin","text":"Computes value based exponential growth curve linear decay model time.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp1_lin.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Exponential Linear Function 1 — fn_exp1_lin","text":"","code":"fn_exp1_lin(t, t1, t2, alpha, beta)"},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp1_lin.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Exponential Linear Function 1 — fn_exp1_lin","text":"t Numeric. time value. t1 Numeric. lower threshold time. Assumed known. t2 Numeric. upper threshold time. alpha Numeric. parameter exponential term. Must greater 0. beta Numeric. parameter linear term. Must less 0.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp1_lin.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Exponential Linear Function 1 — fn_exp1_lin","text":"numeric value based exponential linear model. t less t1, function returns 0. t t1 t2 (inclusive), function returns exp(alpha * (t - t1)) - 1. t greater t2, function returns beta * (t - t2) + (exp(alpha * (t2 - t1)) - 1).","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp1_lin.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Exponential Linear Function 1 — fn_exp1_lin","text":"$$ f(t; t_1, t_2, \\alpha, \\beta) = \\begin{cases} 0 & \\text{} t < t_1 \\\\ e^{\\alpha \\cdot (t - t_1)} - 1 & \\text{} t_1 \\leq t \\leq t_2 \\\\ \\beta \\cdot (t - t_2) + \\left(e^{\\alpha \\cdot (t_2 - t_1)} - 1\\right) & \\text{} t > t_2 \\end{cases} $$","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp1_lin.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Exponential Linear Function 1 — fn_exp1_lin","text":"","code":"library(flexFitR) plot_fn( fn = \"fn_exp1_lin\", params = c(t1 = 35, t2 = 55, alpha = 1 / 20, beta = -1 / 40), interval = c(0, 108), n_points = 2000, auc_label_size = 3 )"},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp2_exp.html","id":null,"dir":"Reference","previous_headings":"","what":"Exponential Exponential Function 2 — fn_exp2_exp","title":"Exponential Exponential Function 2 — fn_exp2_exp","text":"Computes value based exponential growth curve exponential decay model time.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp2_exp.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Exponential Exponential Function 2 — fn_exp2_exp","text":"","code":"fn_exp2_exp(t, t1, t2, alpha, beta)"},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp2_exp.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Exponential Exponential Function 2 — fn_exp2_exp","text":"t Numeric. time value. t1 Numeric. lower threshold time. Assumed known. t2 Numeric. upper threshold time. alpha Numeric. parameter first exponential term. Must greater 0. beta Numeric. parameter second exponential term. Must less 0.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp2_exp.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Exponential Exponential Function 2 — fn_exp2_exp","text":"numeric value based double exponential model. t less t1, function returns 0. t t1 t2 (inclusive), function returns exp(alpha * (t - t1)^2) - 1. t greater t2, function returns (exp(alpha * (t2 - t1)^2) - 1) * exp(beta * (t - t2)).","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp2_exp.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Exponential Exponential Function 2 — fn_exp2_exp","text":"$$ f(t; t_1, t_2, \\alpha, \\beta) = \\begin{cases} 0 & \\text{} t < t_1 \\\\ e^{\\alpha \\cdot (t - t_1)^2} - 1 & \\text{} t_1 \\leq t \\leq t_2 \\\\ \\left(e^{\\alpha \\cdot (t_2 - t_1)^2} - 1\\right) \\cdot e^{\\beta \\cdot (t - t_2)} & \\text{} t > t_2 \\end{cases} $$","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp2_exp.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Exponential Exponential Function 2 — fn_exp2_exp","text":"","code":"library(flexFitR) plot_fn( fn = \"fn_exp2_exp\", params = c(t1 = 35, t2 = 55, alpha = 1 / 600, beta = -1 / 30), interval = c(0, 108), n_points = 2000, auc_label_size = 3, y_auc_label = 0.15 )"},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp2_lin.html","id":null,"dir":"Reference","previous_headings":"","what":"Exponential Linear Function 2 — fn_exp2_lin","title":"Exponential Linear Function 2 — fn_exp2_lin","text":"Computes value based exponential growth curve linear decay model time.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp2_lin.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Exponential Linear Function 2 — fn_exp2_lin","text":"","code":"fn_exp2_lin(t, t1, t2, alpha, beta)"},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp2_lin.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Exponential Linear Function 2 — fn_exp2_lin","text":"t Numeric. time value. t1 Numeric. lower threshold time. Assumed known. t2 Numeric. upper threshold time. alpha Numeric. parameter exponential term. Must greater 0. beta Numeric. parameter linear term. Must less 0.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp2_lin.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Exponential Linear Function 2 — fn_exp2_lin","text":"numeric value based exponential linear model. t less t1, function returns 0. t t1 t2 (inclusive), function returns exp(alpha * (t - t1)^2) - 1. t greater t2, function returns beta * (t - t2) + (exp(alpha * (t2 - t1)^2) - 1).","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp2_lin.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Exponential Linear Function 2 — fn_exp2_lin","text":"$$ f(t; t_1, t_2, \\alpha, \\beta) = \\begin{cases} 0 & \\text{} t < t_1 \\\\ e^{\\alpha \\cdot (t - t_1)^2} - 1 & \\text{} t_1 \\leq t \\leq t_2 \\\\ \\beta \\cdot (t - t_2) + \\left(e^{\\alpha \\cdot (t_2 - t_1)^2} - 1\\right) & \\text{} t > t_2 \\end{cases} $$","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp2_lin.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Exponential Linear Function 2 — fn_exp2_lin","text":"","code":"library(flexFitR) plot_fn( fn = \"fn_exp2_lin\", params = c(t1 = 35, t2 = 55, alpha = 1 / 600, beta = -1 / 80), interval = c(0, 108), n_points = 2000, auc_label_size = 3 )"},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin.html","id":null,"dir":"Reference","previous_headings":"","what":"Linear Function — fn_lin","title":"Linear Function — fn_lin","text":"Computes value based linear function.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Linear Function — fn_lin","text":"","code":"fn_lin(t, m, b)"},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Linear Function — fn_lin","text":"t Numeric value. m Numeric value slope coefficient. b Numeric value intercept coefficient.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Linear Function — fn_lin","text":"numeric value based linear function.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Linear Function — fn_lin","text":"$$ f(t; m, b) = m \\cdot t + b $$","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Linear Function — fn_lin","text":"","code":"library(flexFitR) plot_fn( fn = \"fn_lin\", params = c(m = 2, b = 10), interval = c(0, 108), n_points = 2000 )"},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin_pl_lin.html","id":null,"dir":"Reference","previous_headings":"","what":"Linear Plateau Linear — fn_lin_pl_lin","title":"Linear Plateau Linear — fn_lin_pl_lin","text":"Linear Plateau Linear","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin_pl_lin.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Linear Plateau Linear — fn_lin_pl_lin","text":"","code":"fn_lin_pl_lin(t, t1, t2, t3, k, beta)"},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin_pl_lin.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Linear Plateau Linear — fn_lin_pl_lin","text":"t Numeric. time value. t1 Numeric. lower threshold time. Default 45. t2 Numeric. upper threshold time plateau. Default 80. t3 Numeric. lower threshold time plateau. Default 45. k Numeric. maximum value function. Default 0.9. beta Numeric. Slope linear decay.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin_pl_lin.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Linear Plateau Linear — fn_lin_pl_lin","text":"numeric value based linear plateau linear model.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin_pl_lin.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Linear Plateau Linear — fn_lin_pl_lin","text":"$$ f(t; t_1, t_2, t_3, k, \\beta) = \\begin{cases} 0 & \\text{} t < t_1 \\\\ \\dfrac{k}{t_2 - t_1} \\cdot (t - t_1) & \\text{} t_1 \\leq t \\leq t_2 \\\\ k & \\text{} t_2 \\leq t \\leq t_3 \\\\ k + \\beta \\cdot (t - t_3) & \\text{} t > t_3 \\end{cases} $$","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin_pl_lin.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Linear Plateau Linear — fn_lin_pl_lin","text":"","code":"library(flexFitR) plot_fn( fn = \"fn_lin_pl_lin\", params = c(t1 = 38.7, t2 = 62, t3 = 90, k = 0.32, beta = -0.01), interval = c(0, 108), n_points = 2000, auc_label_size = 3 )"},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin_pl_lin2.html","id":null,"dir":"Reference","previous_headings":"","what":"Linear Plateau Linear with Constrains — fn_lin_pl_lin2","title":"Linear Plateau Linear with Constrains — fn_lin_pl_lin2","text":"Linear Plateau Linear Constrains","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin_pl_lin2.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Linear Plateau Linear with Constrains — fn_lin_pl_lin2","text":"","code":"fn_lin_pl_lin2(t, t1, t2, dt, k, beta)"},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin_pl_lin2.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Linear Plateau Linear with Constrains — fn_lin_pl_lin2","text":"t Numeric. time value. t1 Numeric. lower threshold time. t2 Numeric. upper threshold time plateau. dt Numeric. dt = t3 - t2. k Numeric. maximum value function. beta Numeric. Slope linear decay.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin_pl_lin2.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Linear Plateau Linear with Constrains — fn_lin_pl_lin2","text":"numeric value based linear plateau linear model.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin_pl_lin2.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Linear Plateau Linear with Constrains — fn_lin_pl_lin2","text":"$$ f(t; t_1, t_2, dt, k, \\beta) = \\begin{cases} 0 & \\text{} t < t_1 \\\\ \\dfrac{k}{t_2 - t_1} \\cdot (t - t_1) & \\text{} t_1 \\leq t \\leq t_2 \\\\ k & \\text{} t_2 \\leq t \\leq (t_2 + dt) \\\\ k + \\beta \\cdot (t - (t_2 + dt)) & \\text{} t > (t_2 + dt) \\end{cases} $$","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin_pl_lin2.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Linear Plateau Linear with Constrains — fn_lin_pl_lin2","text":"","code":"library(flexFitR) plot_fn( fn = \"fn_lin_pl_lin2\", params = c(t1 = 38.7, t2 = 62, dt = 28, k = 0.32, beta = -0.01), interval = c(0, 108), n_points = 2000, auc_label_size = 3 )"},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin_pl_lin3.html","id":null,"dir":"Reference","previous_headings":"","what":"Linear Plateau Linear Constrains — fn_lin_pl_lin3","title":"Linear Plateau Linear Constrains — fn_lin_pl_lin3","text":"Linear Plateau Linear Constrains","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin_pl_lin3.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Linear Plateau Linear Constrains — fn_lin_pl_lin3","text":"","code":"fn_lin_pl_lin3(t, t1, t2, t3, k, beta)"},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin_pl_lin3.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Linear Plateau Linear Constrains — fn_lin_pl_lin3","text":"t Numeric. time value. t1 Numeric. lower threshold time. Default 45. t2 Numeric. upper threshold time plateau. Default 80. t3 Numeric. lower threshold time plateau. Default 45. k Numeric. maximum value function. Default 0.9. beta Numeric. Slope linear decay.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin_pl_lin3.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Linear Plateau Linear Constrains — fn_lin_pl_lin3","text":"numeric value based linear plateau linear model.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin_pl_lin3.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Linear Plateau Linear Constrains — fn_lin_pl_lin3","text":"$$ f(t; t_1, t_2, t_3, k, \\beta) = \\begin{cases} 0 & \\text{} t < t_1 \\\\ \\dfrac{k}{t_2 - t_1} \\cdot (t - t_1) & \\text{} t_1 \\leq t \\leq t_2 \\\\ k & \\text{} t_2 \\leq t \\leq t_3 \\\\ k + \\beta \\cdot (t - t_3) & \\text{} t > t_3 \\end{cases} $$","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin_pl_lin3.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Linear Plateau Linear Constrains — fn_lin_pl_lin3","text":"","code":"library(flexFitR) plot_fn( fn = \"fn_lin_pl_lin3\", params = c(t1 = 38.7, t2 = 62, t3 = 90, k = 0.32, beta = -0.01), interval = c(0, 108), n_points = 2000, auc_label_size = 3 )"},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_piwise.html","id":null,"dir":"Reference","previous_headings":"","what":"Piecewise Linear Regression — fn_piwise","title":"Piecewise Linear Regression — fn_piwise","text":"Computes value based linear growth curve reaching plateau time.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_piwise.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Piecewise Linear Regression — fn_piwise","text":"","code":"fn_piwise(t, t1 = 45, t2 = 80, k = 0.9)"},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_piwise.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Piecewise Linear Regression — fn_piwise","text":"t Numeric. time value. t1 Numeric. lower threshold time. Default 45. t2 Numeric. upper threshold time. Default 80. k Numeric. maximum value function. Default 0.9. Assumed known.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_piwise.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Piecewise Linear Regression — fn_piwise","text":"numeric value based threshold model. t less t1, function returns 0. t t1 t2 (inclusive), function returns value 0 k linear trend. t greater t2, function returns k.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_piwise.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Piecewise Linear Regression — fn_piwise","text":"$$ f(t; t_1, t_2, k) = \\begin{cases} 0 & \\text{} t < t_1 \\\\ \\dfrac{k}{t_2 - t_1} \\cdot (t - t_1) & \\text{} t_1 \\leq t \\leq t_2 \\\\ k & \\text{} t > t_2 \\end{cases} $$","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_piwise.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Piecewise Linear Regression — fn_piwise","text":"","code":"library(flexFitR) plot_fn( fn = \"fn_piwise\", params = c(t1 = 34.9, t2 = 61.8, k = 100), interval = c(0, 108), n_points = 2000, auc_label_size = 3 )"},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_quad.html","id":null,"dir":"Reference","previous_headings":"","what":"Quadratic Function — fn_quad","title":"Quadratic Function — fn_quad","text":"Computes value based quadratic function..","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_quad.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Quadratic Function — fn_quad","text":"","code":"fn_quad(t, a, b, c)"},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_quad.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Quadratic Function — fn_quad","text":"t Numeric value. Numeric value coefficient . b Numeric value coefficient b. c Numeric value coefficient c.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_quad.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Quadratic Function — fn_quad","text":"numeric value based linear function.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_quad.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Quadratic Function — fn_quad","text":"$$ f(t; , b, c) = \\cdot t^2 + b \\cdot t + c $$","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_quad.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Quadratic Function — fn_quad","text":"","code":"library(flexFitR) plot_fn(fn = \"fn_quad\", params = c(a = 1, b = 10, c = 5))"},{"path":"https://apariciojohan.github.io/flexFitR/reference/goodness_of_fit.html","id":null,"dir":"Reference","previous_headings":"","what":"Akaike's An Information Criterion for an object of class modeler — goodness_of_fit","title":"Akaike's An Information Criterion for an object of class modeler — goodness_of_fit","text":"Generic function calculating Akaike's ‘Information Criterion’ fitted model object class modeler.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/goodness_of_fit.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Akaike's An Information Criterion for an object of class modeler — goodness_of_fit","text":"","code":"# S3 method for class 'modeler' AIC(object, ..., k = 2) # S3 method for class 'modeler' BIC(object, ...)"},{"path":"https://apariciojohan.github.io/flexFitR/reference/goodness_of_fit.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Akaike's An Information Criterion for an object of class modeler — goodness_of_fit","text":"object object inheriting class modeler resulting executing function modeler() ... parameters. future improvements. k Numeric, penalty per parameter used; default k = 2 classical AIC.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/goodness_of_fit.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Akaike's An Information Criterion for an object of class modeler — goodness_of_fit","text":"tibble columns giving corresponding AIC BIC.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/goodness_of_fit.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Akaike's An Information Criterion for an object of class modeler — goodness_of_fit","text":"Johan Aparicio [aut]","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/goodness_of_fit.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Akaike's An Information Criterion for an object of class modeler — goodness_of_fit","text":"","code":"library(flexFitR) dt <- data.frame(X = 1:6, Y = c(12, 16, 44, 50, 95, 100)) mo_1 <- modeler(dt, X, Y, fn = \"fn_lin\", param = c(m = 10, b = -5)) mo_2 <- modeler(dt, X, Y, fn = \"fn_quad\", param = c(a = 1, b = 10, c = 5)) AIC(mo_1) #> uid logLik df nobs p AIC #> 1 1 -21.45745 3 6 2 48.9149 AIC(mo_2) #> uid logLik df nobs p AIC #> 1 1 -21.00014 4 6 3 50.00028"},{"path":"https://apariciojohan.github.io/flexFitR/reference/logLik.modeler.html","id":null,"dir":"Reference","previous_headings":"","what":"Extract Log-Likelihood for an object of class modeler — logLik.modeler","title":"Extract Log-Likelihood for an object of class modeler — logLik.modeler","text":"logLik object class modeler","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/logLik.modeler.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Extract Log-Likelihood for an object of class modeler — logLik.modeler","text":"","code":"# S3 method for class 'modeler' logLik(object, ...)"},{"path":"https://apariciojohan.github.io/flexFitR/reference/logLik.modeler.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Extract Log-Likelihood for an object of class modeler — logLik.modeler","text":"object object inheriting class modeler resulting executing function modeler() ... parameters. future improvements.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/logLik.modeler.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Extract Log-Likelihood for an object of class modeler — logLik.modeler","text":"tibble columns Log-Likelihood fitted models.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/logLik.modeler.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Extract Log-Likelihood for an object of class modeler — logLik.modeler","text":"Johan Aparicio [aut]","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/logLik.modeler.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Extract Log-Likelihood for an object of class modeler — logLik.modeler","text":"","code":"library(flexFitR) dt <- data.frame(X = 1:6, Y = c(12, 16, 44, 50, 95, 100)) mo_1 <- modeler(dt, X, Y, fn = \"fn_lin\", param = c(m = 10, b = -5)) plot(mo_1) logLik(mo_1) #> uid logLik df nobs p #> 1 1 -21.45745 3 6 2"},{"path":"https://apariciojohan.github.io/flexFitR/reference/metrics.html","id":null,"dir":"Reference","previous_headings":"","what":"Metrics for modeler — metrics","title":"Metrics for modeler — metrics","text":"Computes various performance metrics modeler object. function calculates Sum Squared Errors (SSE), Mean Absolute Error (MAE), Mean Squared Error (MSE), Root Mean Squared Error (RMSE), Coefficient Determination (R-squared).","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/metrics.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Metrics for modeler — metrics","text":"","code":"metrics(x, by_grp = TRUE)"},{"path":"https://apariciojohan.github.io/flexFitR/reference/metrics.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Metrics for modeler — metrics","text":"x object class `modeler` containing necessary data compute metrics. by_grp Return metrics id? TRUE default.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/metrics.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Metrics for modeler — metrics","text":"data frame containing calculated metrics grouped uid, metadata, variables.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/metrics.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Metrics for modeler — metrics","text":"Sum Squared Errors (SSE): $$SSE = \\sum_{=1}^{n} (y_i - \\hat{y}_i)^2$$Mean Absolute Error (MAE): $$MAE = \\frac{1}{n} \\sum_{=1}^{n} |y_i - \\hat{y}_i|$$Mean Squared Error (MSE): $$MSE = \\frac{1}{n} \\sum_{=1}^{n} (y_i - \\hat{y}_i)^2$$Root Mean Squared Error (RMSE): $$RMSE = \\sqrt{\\frac{1}{n} \\sum_{=1}^{n} (y_i - \\hat{y}_i)^2}$$Coefficient Determination (R-squared): $$R^2 = 1 - \\frac{\\sum_{=1}^{n} (y_i - \\hat{y}_i)^2}{\\sum_{=1}^{n} (y_i - \\bar{y})^2}$$","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/metrics.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Metrics for modeler — metrics","text":"","code":"library(flexFitR) data(dt_potato) explorer <- explorer(dt_potato, x = DAP, y = c(Canopy, PH), id = Plot) mod_1 <- dt_potato |> modeler( x = DAP, y = Canopy, grp = Plot, fn = \"fn_piwise\", parameters = c(t1 = 45, t2 = 80, k = 0.9), subset = c(1:2), add_zero = TRUE, max_as_last = TRUE ) plot(mod_1, id = c(1:2)) print(mod_1) #> #> Call: #> Canopy ~ fn_piwise(x, t1, t2, k) #> #> Sum of Squares Error: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> 0.4489 2.0903 3.7317 3.7317 5.3731 7.0145 #> #> Optimization Results `head()`: #> uid t1 t2 k sse #> 1 38.6 61.0 99.8 0.449 #> 2 35.2 60.7 100.0 7.014 #> #> Metrics: #> Groups Timing Convergence Iterations #> 2 0.953 secs 100% 469 (id) #> metrics(mod_1) #> # A tibble: 2 × 8 #> uid var SSE MAE MSE RMSE r_squared n #> #> 1 1 Canopy 0.449 0.0744 0.0499 0.223 1.00 9 #> 2 2 Canopy 7.01 0.468 0.779 0.883 1.00 9"},{"path":"https://apariciojohan.github.io/flexFitR/reference/modeler.html","id":null,"dir":"Reference","previous_headings":"","what":"Modeler — modeler","title":"Modeler — modeler","text":"General-purpose optimization techniques non-linear least squares problems.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/modeler.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Modeler — modeler","text":"","code":"modeler( data, x, y, grp, keep, fn = \"fn_piwise\", parameters = NULL, lower = -Inf, upper = Inf, initial_vals = NULL, fixed_params = NULL, method = c(\"subplex\", \"pracmanm\", \"anms\"), return_method = FALSE, subset = NULL, add_zero = FALSE, check_negative = FALSE, max_as_last = FALSE, progress = FALSE, parallel = FALSE, workers = max(1, parallel::detectCores(), na.rm = TRUE), control = list() )"},{"path":"https://apariciojohan.github.io/flexFitR/reference/modeler.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Modeler — modeler","text":"data data.frame wide format. x name column `data` contains x points. y name column `data` contain variable analyzed. Must match var data. grp names columns `data` contains grouping variable. (Optional). keep names columns `data` keep across analysis. fn string specifying name function used curve fitting. Default \"fn_piwise\". parameters named numeric vector specifying initial values parameters optimized. Default NULL. lower Numeric vector specifying lower bounds parameters. Default -Inf parameters. upper Numeric vector specifying upper bounds parameters. Default Inf parameters. initial_vals data frame columns uid, initial parameter values group id. Used providing specific initial values per group id. fixed_params data frame columns uid, fixed parameter values group id. Used fixing certain parameters optimization. method character vector specifying optimization methods used. Check `optimx::checkallsolvers()` available methods. Default c(\"subplex\", \"pracmanm\", \"anms\"). return_method Logical. TRUE, includes optimization method used result. Default FALSE. subset optional vector levels `grp` filter data. Default NULL, meaning groups used. add_zero Logical. TRUE, adds zero value series start. Default FALSE. check_negative Logical. TRUE, converts negative values data zero. Default FALSE. max_as_last Logical. TRUE, appends maximum value reaching maximum. Default FALSE. progress Logical. TRUE progress bar displayed. Default FALSE. Try running function: progressr::handlers(\"progress\", \"beepr\"). parallel Logical. TRUE model fit performed parallel. Default FALSE. workers number parallel processes use. `parallel::detectCores()` control list control parameters passed optimization function. example: list(maxit = 500).","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/modeler.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Modeler — modeler","text":"object class modeler, list containing following elements: param data frame containing optimized parameters related information. dt data frame data used fitted values. fn call used fitting models. metrics Metrics summary models. execution Execution time. response Response variable. keep Metadata keep across. fun Name function. parallel List returning parallel workers. fit List fitted models.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/modeler.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Modeler — modeler","text":"","code":"library(flexFitR) data(dt_potato) explorer <- explorer(dt_potato, x = DAP, y = c(Canopy, GLI_2), id = Plot) # Example 1 mod_1 <- dt_potato |> modeler( x = DAP, y = GLI_2, grp = Plot, fn = \"fn_lin_pl_lin\", parameters = c(t1 = 38.7, t2 = 62, t3 = 90, k = 0.32, beta = -0.01), subset = 195, add_zero = TRUE ) plot(mod_1, id = 195) print(mod_1) #> #> Call: #> GLI_2 ~ fn_lin_pl_lin(x, t1, t2, t3, k, beta) #> #> Residuals: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> -0.011076 -0.002262 0.000000 -0.001676 0.000000 0.002262 #> #> Optimization Results `head()`: #> uid t1 t2 t3 k beta sse #> 195 39.6 68.3 93.3 0.323 -0.01 0.000149 #> #> Metrics: #> Groups Timing Convergence Iterations #> 1 0.9123 secs 100% 901 (id) #> # Example 2 mod_2 <- dt_potato |> modeler( x = DAP, y = Canopy, grp = Plot, fn = \"fn_piwise\", parameters = c(t1 = 45, t2 = 80, k = 0.9), subset = 195, add_zero = TRUE, max_as_last = TRUE ) plot(mod_2, id = 195) print(mod_2) #> #> Call: #> Canopy ~ fn_piwise(x, t1, t2, k) #> #> Residuals: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> -1.340e-09 0.000e+00 0.000e+00 -9.481e-11 1.391e-10 1.391e-10 #> #> Optimization Results `head()`: #> uid t1 t2 k sse #> 195 38.7 62 100 1.88e-18 #> #> Metrics: #> Groups Timing Convergence Iterations #> 1 0.608 secs 100% 349 (id) #>"},{"path":"https://apariciojohan.github.io/flexFitR/reference/plot.explorer.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot an object of class explorer — plot.explorer","title":"Plot an object of class explorer — plot.explorer","text":"Creates various plots object class explorer. Depending specified type, function can generate plots show correlations variables x, correlations x values variable, evolution variables x.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/plot.explorer.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot an object of class explorer — plot.explorer","text":"","code":"# S3 method for class 'explorer' plot( x, type = \"var_by_x\", label_size = 4, signif = FALSE, method = \"pearson\", filter_var = NULL, id = NULL, n_row = NULL, n_col = NULL, base_size = 13, return_gg = FALSE, add_avg = FALSE, ... )"},{"path":"https://apariciojohan.github.io/flexFitR/reference/plot.explorer.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot an object of class explorer — plot.explorer","text":"x object inheriting class explorer, resulting executing function explorer(). type Character string number specifying type plot generate. Available options : \"var_by_x\" 1 Plots correlations variables x (default). \"x_by_var\" 2 Plots correlations x points variable (y). \"evolution\" 3 Plot evolution variables (y) x. \"xy\" 4 Scatterplot (x, y) label_size Numeric. Size labels plot. Default 4. works type 1 2. signif Logical. TRUE, adds p-values correlation plot labels. Default FALSE. works type 1 2. method Character string specifying method correlation calculation. Available options \"pearson\" (default), \"spearman\", \"kendall\". works type 1 2. filter_var Character vector specifying variables exclude plot. id Optional unique identifier filter evolution type plot. Default NULL. works type 3. n_row Integer specifying number rows use facet_wrap(). Default NULL. works type 1 2. n_col Integer specifying number columns use facet_wrap(). Default NULL. works type 1 2. base_size Numeric. Base font size plot. Default 13. return_gg Logical. TRUE, returns ggplot object instead printing . Default FALSE. add_avg Logical. TRUE, returns evolution plot average trend across groups. Default FALSE. ... graphical parameters future improvements.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/plot.explorer.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot an object of class explorer — plot.explorer","text":"ggplot object invisible data.frame containing correlation table type \"var_by_x\" \"x_by_var\".","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/plot.explorer.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot an object of class explorer — plot.explorer","text":"","code":"library(flexFitR) data(dt_potato) dt_potato <- dt_potato results <- explorer(dt_potato, x = DAP, y = c(Canopy, PH), id = Plot) table <- plot(results, label_size = 4, signif = TRUE, n_row = 2) table #> # A tibble: 7 × 7 #> x col row corr p.value n signi #> #> 1 36 Canopy PH 0.46 8.23e-11 176 *** #> 2 42 Canopy PH 0.67 8.55e-27 196 *** #> 3 56 Canopy PH -0.21 3.65e- 3 196 ** #> 4 76 Canopy PH 0.3 1.41e- 5 196 *** #> 5 92 Canopy PH 0.28 5.96e- 5 196 *** #> 6 100 Canopy PH 0.32 6.45e- 6 196 *** #> 7 108 Canopy PH 0.07 3.14e- 1 196 ns plot(results, type = \"x_by_var\", label_size = 4, signif = TRUE)"},{"path":"https://apariciojohan.github.io/flexFitR/reference/plot.modeler.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot an object of class modeler — plot.modeler","title":"Plot an object of class modeler — plot.modeler","text":"Create several plots object class modeler","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/plot.modeler.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot an object of class modeler — plot.modeler","text":"","code":"# 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\", ... )"},{"path":"https://apariciojohan.github.io/flexFitR/reference/plot.modeler.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot an object of class modeler — plot.modeler","text":"x object inheriting class modeler resulting executing function modeler() id avoid many plots one figure. Filter group Id. type Numeric 1, 2, 3. specify type plot. Default 1. Type 4, 5 6 experimental. type = 1 Raw Data + Fitted Curve type = 2 Coefficients + Confindence Intervals type = 3 Fitted Curve + Color Group type = 4 Fitted curve + Confindence Intervals type = 5 First Derivative + Confindence Intervals type = 6 Second Derivative + Confindence Intervals label_size Label size. 3 default. base_size Base font size, given pts. color color geom_line type 1. Default \"red\". parm type equal 2 must vector names parameters. NULL, parameters considered. n_points Number points interpolate along x axis. Default 2000. title Optional string character add title plot. add_ci Add confidence interval type c(4, 5, 6).TRUE FALSE. TRUE default. add_ribbon Add geom_ribbon type c(4, 5, 6).TRUE FALSE. TRUE default. color_ribbon Ribbon color. \"blue\" default. ... graphical parameters. future improvements.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/plot.modeler.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot an object of class modeler — plot.modeler","text":"ggplot object.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/plot.modeler.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Plot an object of class modeler — plot.modeler","text":"Johan Aparicio [aut]","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/plot.modeler.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot an object of class modeler — plot.modeler","text":"","code":"library(flexFitR) data(dt_potato) explorer <- explorer(dt_potato, x = DAP, y = c(Canopy, GLI_2), id = Plot) # Example 1 mod_1 <- dt_potato |> modeler( x = DAP, y = Canopy, grp = Plot, fn = \"fn_piwise\", parameters = c(t1 = 45, t2 = 80, k = 0.9), subset = c(1:3), add_zero = TRUE, max_as_last = TRUE ) print(mod_1) #> #> Call: #> Canopy ~ fn_piwise(x, t1, t2, k) #> #> Sum of Squares Error: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> 0.4489 2.3551 4.2612 3.9082 5.6379 7.0145 #> #> Optimization Results `head()`: #> uid t1 t2 k sse #> 1 38.6 61.0 99.8 0.449 #> 2 35.2 60.7 100.0 7.014 #> 3 33.8 59.9 100.0 4.261 #> #> Metrics: #> Groups Timing Convergence Iterations #> 3 1.5726 secs 100% 499.67 (id) #> plot(mod_1, id = 1:2) plot(mod_1, id = 1:3, type = 2, label_size = 10)"},{"path":"https://apariciojohan.github.io/flexFitR/reference/plot_fn.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot Function — plot_fn","title":"Plot Function — plot_fn","text":"function plots user-defined function specified interval annotates plot calculated Area Curve (AUC) parameter values. aim `plot_fn` allow users play different Starting Values functions fitting models.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/plot_fn.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot Function — plot_fn","text":"","code":"plot_fn( fn = \"fn_piwise\", params = c(t1 = 34.9, t2 = 61.8, k = 100), interval = c(0, 100), n_points = 1000, auc = FALSE, x_auc_label = NULL, y_auc_label = NULL, auc_label_size = 4, param_label_size = 4, base_size = 12, color = \"red\", label_color = \"grey30\" )"},{"path":"https://apariciojohan.github.io/flexFitR/reference/plot_fn.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot Function — plot_fn","text":"fn character string representing name function plotted. Default \"fn_piwise\". params named numeric vector parameters passed function. Default c(t1 = 34.9, t2 = 61.8, k = 100). interval numeric vector length 2 specifying interval function plotted. Default c(0, 100). n_points integer specifying number points used plotting. Default 1000. auc Print AUC plot? Default FALSE. x_auc_label numeric value specifying x-coordinate AUC label. Default NULL. y_auc_label numeric value specifying y-coordinate AUC label. Default NULL. auc_label_size numeric value specifying size AUC label text. Default 3. param_label_size numeric value specifying size parameter label text. Default 3. base_size numeric value specifying base size plot's theme. Default 12. color character string specifying color plot lines area fill. Default \"red\". label_color character string specifying color labels. Default \"grey30\".","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/plot_fn.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot Function — plot_fn","text":"ggplot object representing plot.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/plot_fn.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot Function — plot_fn","text":"","code":"# Example usage plot_fn( fn = \"fn_piwise\", params = c(t1 = 34.9, t2 = 61.8, k = 100), interval = c(0, 100), n_points = 1000 ) plot_fn( fn = \"fn_lin_pl_lin\", params <- c(t1 = 38.7, t2 = 62, t3 = 90, k = 0.32, beta = -0.01), interval = c(0, 100), n_points = 1000, base_size = 12 )"},{"path":"https://apariciojohan.github.io/flexFitR/reference/predict.modeler.html","id":null,"dir":"Reference","previous_headings":"","what":"Predict an object of class modeler — predict.modeler","title":"Predict an object of class modeler — predict.modeler","text":"Model predictions object class modeler","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/predict.modeler.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Predict an object of class modeler — predict.modeler","text":"","code":"# S3 method for class 'modeler' predict( object, x = NULL, id = NULL, type = c(\"point\", \"auc\", \"fd\", \"sd\"), se_interval = c(\"confidence\", \"prediction\"), n_points = 1000, metadata = FALSE, ... )"},{"path":"https://apariciojohan.github.io/flexFitR/reference/predict.modeler.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Predict an object of class modeler — predict.modeler","text":"object object inheriting class modeler resulting executing function modeler() x numeric time point make prediction. Can one. type = \"auc\", x needs size 2, specifies interval calculating AUC. id unique identifier filter . NULL default. type character string specifying type prediction. \"point\" predict value y given x. \"auc\" return area curve (AUC) fitted curve. \"fd\" first order derivative x value returned. \"sd\" second order derivative x value returned. se_interval Type standard error calculation intervals. \"confidence\" \"prediction\". \"confidence\" default. n_points integer specifying number x points use approximating Area Curve (AUC). Default 1000. metadata TRUE FALSE. Whether bring metadata making predictions. ... parameters. future improvements.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/predict.modeler.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Predict an object of class modeler — predict.modeler","text":"data.frame object predicted values standard errors.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/predict.modeler.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Predict an object of class modeler — predict.modeler","text":"Johan Aparicio [aut]","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/predict.modeler.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Predict an object of class modeler — predict.modeler","text":"","code":"library(flexFitR) data(dt_potato) mod_1 <- dt_potato |> modeler( x = DAP, y = Canopy, grp = Plot, fn = \"fn_piwise\", parameters = c(t1 = 45, t2 = 80, k = 0.9), subset = c(15, 2, 45), add_zero = TRUE, max_as_last = TRUE ) print(mod_1) #> #> Call: #> Canopy ~ fn_piwise(x, t1, t2, k) #> #> Sum of Squares Error: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> 0.002601 0.504829 1.007057 2.674719 4.010777 7.014498 #> #> Optimization Results `head()`: #> uid t1 t2 k sse #> 2 35.2 60.7 100.0 7.0145 #> 15 38.5 69.4 99.8 1.0071 #> 45 38.3 64.5 100.0 0.0026 #> #> Metrics: #> Groups Timing Convergence Iterations #> 3 1.4683 secs 100% 414 (id) #> # Point Prediction predict(mod_1, x = 45, type = \"point\", id = 2) #> # A tibble: 1 × 4 #> uid x_new predicted.value std.error #> #> 1 2 45 38.4 0.622 # AUC Prediction predict(mod_1, x = c(0, 108), type = \"auc\", id = 2) #> # A tibble: 1 × 5 #> uid x_min x_max predicted.value std.error #> #> 1 2 0 108 6004. 30.8 # First Derivative predict(mod_1, x = 45, type = \"fd\", id = 2) #> # A tibble: 1 × 4 #> uid x_new predicted.value std.error #> #> 1 2 45 3.91 0.0741 # Second Derivative predict(mod_1, x = 45, type = \"sd\", id = 2) #> # A tibble: 1 × 4 #> uid x_new predicted.value std.error #> #> 1 2 45 -0.0000000298 0.0000274"},{"path":"https://apariciojohan.github.io/flexFitR/reference/print.modeler.html","id":null,"dir":"Reference","previous_headings":"","what":"Print an object of class modeler — print.modeler","title":"Print an object of class modeler — print.modeler","text":"Prints information modeler function.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/print.modeler.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Print an object of class modeler — print.modeler","text":"","code":"# S3 method for class 'modeler' print(x, ...)"},{"path":"https://apariciojohan.github.io/flexFitR/reference/print.modeler.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Print an object of class modeler — print.modeler","text":"x object fitted function modeler(). ... Options used tibble package format output. See `tibble::print()` details.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/print.modeler.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Print an object of class modeler — print.modeler","text":"object inheriting class modeler.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/print.modeler.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Print an object of class modeler — print.modeler","text":"Johan Aparicio [aut]","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/print.modeler.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Print an object of class modeler — print.modeler","text":"","code":"library(flexFitR) data(dt_potato) explorer <- explorer(dt_potato, x = DAP, y = c(Canopy, PH), id = Plot) mod_1 <- dt_potato |> modeler( x = DAP, y = Canopy, grp = Plot, fn = \"fn_piwise\", parameters = c(t1 = 45, t2 = 80, k = 0.9), subset = c(1:5), add_zero = TRUE, max_as_last = TRUE ) plot(mod_1, id = c(1:5)) print(mod_1) #> #> Call: #> Canopy ~ fn_piwise(x, t1, t2, k) #> #> Sum of Squares Error: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> 0.000000 0.000049 0.448900 2.344930 4.261203 7.014498 #> #> Optimization Results `head()`: #> uid t1 t2 k sse #> 1 38.6 61.0 99.8 4.49e-01 #> 2 35.2 60.7 100.0 7.01e+00 #> 3 33.8 59.9 100.0 4.26e+00 #> 4 39.3 65.5 99.8 4.60e-18 #> #> Metrics: #> Groups Timing Convergence Iterations #> 5 2.3402 secs 100% 435.2 (id) #>"},{"path":"https://apariciojohan.github.io/flexFitR/reference/vcov.modeler.html","id":null,"dir":"Reference","previous_headings":"","what":"Variance-Covariance matrix for an object of class modeler — vcov.modeler","title":"Variance-Covariance matrix for an object of class modeler — vcov.modeler","text":"vcov object class modeler","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/vcov.modeler.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Variance-Covariance matrix for an object of class modeler — vcov.modeler","text":"","code":"# S3 method for class 'modeler' vcov(x, id = NULL, ...)"},{"path":"https://apariciojohan.github.io/flexFitR/reference/vcov.modeler.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Variance-Covariance matrix for an object of class modeler — vcov.modeler","text":"x object inheriting class modeler resulting executing function modeler() id unique identifier filter . NULL default. ... parameters. future improvements.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/vcov.modeler.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Variance-Covariance matrix for an object of class modeler — vcov.modeler","text":"list object matrices estimated covariances parameter estimates.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/vcov.modeler.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Variance-Covariance matrix for an object of class modeler — vcov.modeler","text":"Johan Aparicio [aut]","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/vcov.modeler.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Variance-Covariance matrix for an object of class modeler — vcov.modeler","text":"","code":"library(flexFitR) data(dt_potato) mod_1 <- dt_potato |> modeler( x = DAP, y = Canopy, grp = Plot, fn = \"fn_piwise\", parameters = c(t1 = 45, t2 = 80, k = 0.9), subset = c(15, 2, 45), add_zero = TRUE, max_as_last = TRUE ) print(mod_1) #> #> Call: #> Canopy ~ fn_piwise(x, t1, t2, k) #> #> Sum of Squares Error: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> 0.002601 0.504829 1.007057 2.674719 4.010777 7.014498 #> #> Optimization Results `head()`: #> uid t1 t2 k sse #> 2 35.2 60.7 100.0 7.0145 #> 15 38.5 69.4 99.8 1.0071 #> 45 38.3 64.5 100.0 0.0026 #> #> Metrics: #> Groups Timing Convergence Iterations #> 3 1.4468 secs 100% 414 (id) #> vcov(mod_1) #> $`2` #> t1 t2 k #> t1 5.694008e-02 -0.02923676 3.683474e-06 #> t2 -2.923676e-02 0.13796365 7.471629e-02 #> k 3.683474e-06 0.07471629 2.922726e-01 #> #> $`15` #> t1 t2 k #> t1 2.636323e-02 -0.02728600 1.691502e-07 #> t2 -2.728600e-02 0.08035361 1.300394e-02 #> k 1.691502e-07 0.01300394 4.196055e-02 #> #> $`45` #> t1 t2 k #> t1 4.956862e-05 -3.526927e-05 4.195078e-11 #> t2 -3.526927e-05 9.453221e-05 2.835289e-05 #> k 4.195078e-11 2.835289e-05 1.083750e-04 #>"},{"path":"https://apariciojohan.github.io/flexFitR/news/index.html","id":"flexfitr-010","dir":"Changelog","previous_headings":"","what":"flexFitR 0.1.0","title":"flexFitR 0.1.0","text":"Initial CRAN submission.","code":""}] +[{"path":"https://apariciojohan.github.io/flexFitR/articles/canopy-model.html","id":"loading-libraries","dir":"Articles","previous_headings":"","what":"Loading libraries","title":"Modelling Emergence and Maximun Canopy","text":"","code":"library(flexFitR) library(dplyr) library(kableExtra) library(ggpubr) library(purrr)"},{"path":"https://apariciojohan.github.io/flexFitR/articles/canopy-model.html","id":"exploring-data-explorer","dir":"Articles","previous_headings":"","what":"Exploring data explorer()","title":"Modelling Emergence and Maximun Canopy","text":"","code":"data(dt_potato) explorer <- explorer(dt_potato, x = DAP, y = Canopy, id = Plot) names(explorer) #> [1] \"summ_vars\" \"summ_metadata\" \"locals_min_max\" \"dt_long\" #> [5] \"metadata\""},{"path":"https://apariciojohan.github.io/flexFitR/articles/canopy-model.html","id":"data-exploration","dir":"Articles","previous_headings":"","what":"Data exploration","title":"Modelling Emergence and Maximun Canopy","text":"","code":"p1 <- plot(explorer, type = \"evolution\", return_gg = TRUE) p2 <- plot(explorer, type = \"x_by_var\", return_gg = TRUE) ggarrange(p1, p2)"},{"path":"https://apariciojohan.github.io/flexFitR/articles/canopy-model.html","id":"target-function","dir":"Articles","previous_headings":"","what":"Target Function","title":"Modelling Emergence and Maximun Canopy","text":"fn_piwise() \\[\\begin{equation} f(t; t_1, t_2, k) = \\begin{cases} 0 & \\text{} t < t_1 \\\\ \\dfrac{k}{t_2 - t_1} \\cdot (t - t_1) & \\text{} t_1 \\leq t \\leq t_2 \\\\ k & \\text{} t > t_2 \\end{cases} \\end{equation}\\]","code":""},{"path":"https://apariciojohan.github.io/flexFitR/articles/canopy-model.html","id":"fitting-models","dir":"Articles","previous_headings":"","what":"Fitting Models","title":"Modelling Emergence and Maximun Canopy","text":"","code":"mod_1 <- dt_potato |> modeler( x = DAP, y = Canopy, grp = Plot, fn = \"fn_piwise\", parameters = c(t1 = 45, t2 = 80, k = 0.9), subset = c(195, 40), add_zero = TRUE ) mod_1 #> #> Call: #> Canopy ~ fn_piwise(x, t1, t2, k) #> #> Sum of Squares Error: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> 390.5 1004.2 1618.0 1618.0 2231.8 2845.5 #> #> Optimization Results `head()`: #> uid t1 t2 k sse #> 40 34.8 53.7 72.5 2846 #> 195 38.7 60.0 91.7 390 #> #> Metrics: #> Groups Timing Convergence Iterations #> 2 0.8015 secs 100% 547 (id) plot(mod_1, id = c(195, 40)) kable(mod_1$param)"},{"path":"https://apariciojohan.github.io/flexFitR/articles/canopy-model.html","id":"providing-different-initial-values","dir":"Articles","previous_headings":"","what":"Providing different initial values","title":"Modelling Emergence and Maximun Canopy","text":"","code":"initials <- data.frame( uid = c(195, 40), t1 = c(40, 60), t2 = c(70, 80), k = c(100, 100) ) kable(initials) mod_2 <- dt_potato |> modeler( x = DAP, y = Canopy, grp = Plot, fn = \"fn_piwise\", parameters = c(t1 = 45, t2 = 80, k = 0.9), initial_vals = initials, subset = c(195, 40), add_zero = TRUE ) plot(mod_2, id = c(195, 40)) kable(mod_2$param)"},{"path":"https://apariciojohan.github.io/flexFitR/articles/canopy-model.html","id":"fixing-some-parameters-of-the-model","dir":"Articles","previous_headings":"","what":"Fixing some parameters of the model","title":"Modelling Emergence and Maximun Canopy","text":"","code":"fixed_params <- data.frame(uid = c(195, 40), k = c(100, 100)) kable(fixed_params) mod_3 <- dt_potato |> modeler( x = DAP, y = Canopy, grp = Plot, fn = \"fn_piwise\", parameters = c(t1 = 45, t2 = 80, k = 0.9), fixed_params = fixed_params, subset = c(195, 40), add_zero = TRUE ) plot(mod_3, id = c(195, 40)) kable(mod_3$param)"},{"path":"https://apariciojohan.github.io/flexFitR/articles/canopy-model.html","id":"correcting-maximun-value","dir":"Articles","previous_headings":"","what":"Correcting Maximun value","title":"Modelling Emergence and Maximun Canopy","text":"","code":"mod_4 <- dt_potato |> modeler( x = DAP, y = Canopy, grp = Plot, fn = \"fn_piwise\", parameters = c(t1 = 45, t2 = 80, k = 0.9), fixed_params = fixed_params, subset = c(195, 40), add_zero = TRUE, max_as_last = TRUE ) plot(mod_4, id = c(195, 40)) kable(mod_4$param)"},{"path":"https://apariciojohan.github.io/flexFitR/articles/canopy-model.html","id":"comparing-models","dir":"Articles","previous_headings":"","what":"Comparing Models","title":"Modelling Emergence and Maximun Canopy","text":"","code":"rbind.data.frame( mutate(mod_1$param, mod = \"1\"), mutate(mod_2$param, mod = \"2\"), mutate(mod_3$param, mod = \"3\"), mutate(mod_4$param, mod = \"4\") ) |> filter(uid %in% 40) |> kable()"},{"path":"https://apariciojohan.github.io/flexFitR/articles/height-model.html","id":"loading-libraries","dir":"Articles","previous_headings":"","what":"Loading libraries","title":"Modelling Plant Height","text":"","code":"library(flexFitR) library(dplyr) library(kableExtra) library(ggpubr) library(purrr)"},{"path":"https://apariciojohan.github.io/flexFitR/articles/height-model.html","id":"exploring-data-explorer","dir":"Articles","previous_headings":"","what":"Exploring data explorer()","title":"Modelling Plant Height","text":"","code":"data(dt_chips) results <- explorer(dt_chips, x = DAP, y = c(PH, Canopy), id = Plot) names(results) #> [1] \"summ_vars\" \"summ_metadata\" \"locals_min_max\" \"dt_long\" #> [5] \"metadata\""},{"path":"https://apariciojohan.github.io/flexFitR/articles/height-model.html","id":"data-exploration","dir":"Articles","previous_headings":"","what":"Data exploration","title":"Modelling Plant Height","text":"","code":"p1 <- plot(results, type = \"evolution\", return_gg = TRUE) p2 <- plot(results, type = \"x_by_var\", return_gg = TRUE) ggarrange(p1, p2, nrow = 2)"},{"path":"https://apariciojohan.github.io/flexFitR/articles/height-model.html","id":"estimating-days-to-emergence","dir":"Articles","previous_headings":"","what":"Estimating days to emergence","title":"Modelling Plant Height","text":"\\[\\begin{equation} f(t; t_1, t_2, k) = \\begin{cases} 0 & \\text{} t < t_1 \\\\ \\dfrac{k}{t_2 - t_1} \\cdot (t - t_1) & \\text{} t_1 \\leq t \\leq t_2 \\\\ k & \\text{} t > t_2 \\end{cases} \\end{equation}\\]","code":""},{"path":"https://apariciojohan.github.io/flexFitR/articles/height-model.html","id":"fitting-models-for-canopy","dir":"Articles","previous_headings":"","what":"Fitting models for canopy","title":"Modelling Plant Height","text":"","code":"fixed_params <- results |> pluck(\"dt_long\") |> filter(var %in% \"Canopy\" & uid %in% c(195, 40)) |> group_by(uid) |> summarise(k = max(y), .groups = \"drop\") mod_1 <- dt_chips |> modeler( x = DAP, y = Canopy, grp = Plot, fn = \"fn_piwise\", parameters = c(t1 = 45, t2 = 80, k = 0.9), fixed_params = fixed_params, subset = c(195, 40), add_zero = TRUE, max_as_last = TRUE ) plot(mod_1, id = c(195, 40)) kable(mod_1$param)"},{"path":"https://apariciojohan.github.io/flexFitR/articles/height-model.html","id":"target-function-for-plant-height","dir":"Articles","previous_headings":"","what":"Target function for plant height","title":"Modelling Plant Height","text":"fn_exp2_exp() \\[\\begin{equation} f(t; t_1, t_2, \\alpha, \\beta) = \\begin{cases} 0 & \\text{} t < t_1 \\\\ e^{\\alpha \\cdot (t - t_1)^2} - 1 & \\text{} t_1 \\leq t \\leq t_2 \\\\ \\left(e^{\\alpha \\cdot (t_2 - t_1)^2} - 1\\right) \\cdot e^{\\beta \\cdot (t - t_2)} & \\text{} t > t_2 \\end{cases} \\end{equation}\\]","code":""},{"path":"https://apariciojohan.github.io/flexFitR/articles/height-model.html","id":"fixing-parameters-and-providing-initial-values","dir":"Articles","previous_headings":"","what":"Fixing parameters and providing initial values","title":"Modelling Plant Height","text":"","code":"fixed_params <- mod_1 |> pluck(\"param\") |> select(uid, t1) kable(fixed_params) initials <- mod_1 |> pluck(\"param\") |> select(uid, t1, t2) |> mutate(alpha = 1 / 600, beta = -1 / 30) kable(initials)"},{"path":"https://apariciojohan.github.io/flexFitR/articles/height-model.html","id":"fitting-models-for-plant-height","dir":"Articles","previous_headings":"","what":"Fitting models for plant height","title":"Modelling Plant Height","text":"Using t1 previous model fixed parameter using t2 initial parameter per plot.","code":"mod_2 <- dt_chips |> modeler( x = DAP, y = PH, grp = Plot, fn = \"fn_exp2_exp\", initial_vals = initials, fixed_params = fixed_params, subset = c(195, 40), add_zero = TRUE ) plot(mod_2, id = c(195, 40)) kable(mod_2$param)"},{"path":"https://apariciojohan.github.io/flexFitR/articles/how_to_start.html","id":"getting-started","dir":"Articles","previous_headings":"","what":"Getting started","title":"How to start","text":"basic idea vignette illustrate users use flexFitR package. ’ll start basic example: simple linear regression. Although example primary focus package, serve demonstrate use.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/articles/how_to_start.html","id":"simple-linear-regression","dir":"Articles","previous_headings":"","what":"1. Simple linear regression","title":"How to start","text":"example, ’ll work small dataset consisting 6 observations, X independent variable Y dependent variable. First, define objective function. case, function fn_lm represent linear regression, b intercept m slope regression. plot_fn function, integrated package, allows us plot function parameters provided. useful visualizing shape function fitting model data. fit model, use modeler function. function, pass x independent variable, y dependent variable, vector parameters assign initial values coefficient b coefficient m. model fitted, can examine output, extract estimated parameters, make plots, predict new x values. order get coefficients variance-covariance matrix make use coef vcov function, takes model object argument. Finally, can make predictions using predict function, takes fitted model object X value want make prediction. can compare lm function R, give results similar obtained package.","code":"library(flexFitR) library(dplyr) dt <- data.frame(X = 1:6, Y = c(12, 16, 44, 50, 95, 100)) plot(explorer(dt, X, Y), type = \"xy\") fn_lm <- function(x, b, m) { y <- b + m * x return(y) } plot_fn(fn = \"fn_lm\", params = c(b = 10, m = 5)) mod <- dt |> modeler( x = X, y = Y, fn = \"fn_lm\", parameters = c(b = -5, m = 10) ) mod #> #> Call: #> Y ~ fn_lm(x, b, m) #> #> Residuals: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> -12.5905 -6.0762 -0.3476 0.0000 6.1952 12.8952 #> #> Optimization Results `head()`: #> uid b m sse #> 1 -15.5 19.5 449 #> #> Metrics: #> Groups Timing Convergence Iterations #> 1 0.3676 secs 100% 259 (id) plot(mod) coef(mod) #> # A tibble: 2 × 6 #> uid coefficient solution std.error `t value` `Pr(>|t|)` #> #> 1 1 b -15.5 9.86 -1.57 0.192 #> 2 1 m 19.5 2.53 7.71 0.00152 vcov(mod) #> $`1` #> b m #> b 97.21937 -22.435238 #> m -22.43524 6.410068 predict(mod, x = 4.5) #> # A tibble: 1 × 4 #> uid x_new predicted.value std.error #> #> 1 1 4.5 72.3 5.01"},{"path":"https://apariciojohan.github.io/flexFitR/articles/how_to_start.html","id":"comparison-with-lm","dir":"Articles","previous_headings":"1. Simple linear regression","what":"Comparison with lm","title":"How to start","text":"previous example fairly simple, can consider complex scenario need fit just one function, hundreds functions several groups. can achieved using group_by argument modeler function. Additionally, can parallelize processes setting parallel argument TRUE defining number cores use. ’s important note depending functions defined user, parameters may need constrained, required greater less zero. cases, certain parameters might need fixed known values. complex situations, many curves fit working complex functions—whether non linear regressions specific parameter constraints cases parameters fixed group—modeler offers extensive flexibility.","code":"mo <- lm(Y ~ X, data = dt) mo #> #> Call: #> lm(formula = Y ~ X, data = dt) #> #> Coefficients: #> (Intercept) X #> -15.47 19.51 summary(mo)$coefficients #> Estimate Std. Error t value Pr(>|t|) #> (Intercept) -15.46667 9.859988 -1.568629 0.191812151 #> X 19.51429 2.531811 7.707639 0.001524882 vcov(mo) #> (Intercept) X #> (Intercept) 97.21937 -22.435238 #> X -22.43524 6.410068 predict(mo, newdata = data.frame(X = 4.5), se.fit = TRUE) #> $fit #> 1 #> 72.34762 #> #> $se.fit #> [1] 5.010599 #> #> $df #> [1] 4 #> #> $residual.scale #> [1] 10.59133"},{"path":"https://apariciojohan.github.io/flexFitR/articles/how_to_start.html","id":"piece-wise-regression","dir":"Articles","previous_headings":"","what":"2. Piece-wise regression","title":"How to start","text":"following example, although still simple, represents slightly complex function greater number parameters. case, piece-wise regression, parameterized t1, t2, k, defined following expression: fitting model, let’s take look example dataset. can make plot piecewise function fit model using modeler function. fitting model, can examine results, plot fitted curve, extract coefficients associated p-values, obtain variance-covariance matrix, make predictions unknown values x. Finally, illustrate provide different initial values function dealing multiple groups, also show fix parameters objective function.","code":"fun <- function(t, t1 = 45, t2 = 80, k = 0.9) { if (t < t1) { y <- 0 } else if (t >= t1 && t <= t2) { y <- k / (t2 - t1) * (t - t1) } else { y <- k } return(y) } dt <- data.frame( time = c(0, 29, 36, 42, 56, 76, 92, 100, 108), variable = c(0, 0, 0.67, 15.11, 77.38, 99.81, 99.81, 99.81, 99.81) ) plot(explorer(dt, time, variable), type = \"xy\") plot_fn(fn = \"fun\", params = c(t1 = 25, t2 = 70, k = 90)) mod_1 <- dt |> modeler( x = time, y = variable, fn = \"fun\", parameters = c(t1 = 45, t2 = 80, k = 90) ) mod_1 #> #> Call: #> variable ~ fun(x, t1, t2, k) #> #> Residuals: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> 0.00000 0.00000 0.00000 0.07444 0.00000 0.67000 #> #> Optimization Results `head()`: #> uid t1 t2 k sse #> 1 38.6 61 99.8 0.449 #> #> Metrics: #> Groups Timing Convergence Iterations #> 1 0.3951 secs 100% 511 (id) plot(mod_1) # Coefficients coef(mod_1) #> # A tibble: 3 × 6 #> uid coefficient solution std.error `t value` `Pr(>|t|)` #> #> 1 1 t1 38.6 0.0779 496. 4.54e-15 #> 2 1 t2 61.0 0.0918 665. 7.82e-16 #> 3 1 k 99.8 0.137 730. 4.47e-16 # Variance-Covariance Matrix vcov(mod_1) #> $`1` #> t1 t2 k #> t1 6.061705e-03 -0.002940001 1.877072e-07 #> t2 -2.940001e-03 0.008431400 4.204939e-03 #> k 1.877072e-07 0.004204939 1.870426e-02 # Making predictions predict(mod_1, x = 45) #> # A tibble: 1 × 4 #> uid x_new predicted.value std.error #> #> 1 1 45 28.5 0.223"},{"path":"https://apariciojohan.github.io/flexFitR/articles/how_to_start.html","id":"providing-initial-values","dir":"Articles","previous_headings":"2. Piece-wise regression","what":"Providing Initial values","title":"How to start","text":"example, don’t grouping variable. However, default, function assigns unique identifier (uid) dataset. , need specify uid = 1 initial values fixed parameters. one group, need modify parameters argument accordingly. approach primarily illustrative purposes.","code":"init <- data.frame(uid = 1, t1 = 20, t2 = 30, k = 0.8) mod_2 <- dt |> modeler( x = time, y = variable, fn = \"fun\", parameters = c(t1 = 45, t2 = 80, k = 90), initial_vals = init ) mod_2 #> #> Call: #> variable ~ fun(x, t1, t2, k) #> #> Residuals: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> 0.00000 0.00000 0.00000 0.07444 0.00000 0.67000 #> #> Optimization Results `head()`: #> uid t1 t2 k sse #> 1 38.6 61 99.8 0.449 #> #> Metrics: #> Groups Timing Convergence Iterations #> 1 0.4101 secs 100% 567 (id) coef(mod_2) #> # A tibble: 3 × 6 #> uid coefficient solution std.error `t value` `Pr(>|t|)` #> #> 1 1 t1 38.6 0.0779 496. 4.54e-15 #> 2 1 t2 61.0 0.0918 665. 7.82e-16 #> 3 1 k 99.8 0.137 730. 4.47e-16"},{"path":"https://apariciojohan.github.io/flexFitR/articles/how_to_start.html","id":"fixing-parameters","dir":"Articles","previous_headings":"2. Piece-wise regression","what":"Fixing parameters","title":"How to start","text":"vignette provided basic introduction using flexFitR package, starting simple examples linear regression piecewise regression. goal demonstrate fundamental features flexibility package. However, complex situations can arise working high-throughput phenotypic (HTP) data, involve multiple groups, parameter constraints, advanced modeling scenarios. complex situations illustrated vignettes, use real HTP data showcase full capabilities flexFitR package.","code":"fix <- data.frame(uid = 1, k = 98) mod_3 <- dt |> modeler( x = time, y = variable, fn = \"fun\", parameters = c(t1 = 45, t2 = 80, k = 90), fixed_params = fix ) mod_3 #> #> Call: #> variable ~ fun(x, t1, t2, k) #> #> Residuals: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> 0.0000 0.0000 0.6700 0.8789 1.8100 1.8100 #> #> Optimization Results `head()`: #> uid t1 t2 sse k #> 1 38.6 60.6 13.6 98 #> #> Metrics: #> Groups Timing Convergence Iterations #> 1 0.3723 secs 100% 321 (id) coef(mod_3) #> # A tibble: 2 × 6 #> uid coefficient solution std.error `t value` `Pr(>|t|)` #> #> 1 1 t1 38.6 0.396 97.5 3.15e-12 #> 2 1 t2 60.6 0.429 141. 2.34e-13 plot(mod_3) rbind(metrics(mod_1), metrics(mod_2), metrics(mod_3)) #> # A tibble: 3 × 8 #> uid var SSE MAE MSE RMSE r_squared n #> #> 1 1 variable 0.449 0.0744 0.0499 0.223 1.00 9 #> 2 1 variable 0.449 0.0744 0.0499 0.223 1.00 9 #> 3 1 variable 13.6 0.879 1.51 1.23 0.999 9"},{"path":"https://apariciojohan.github.io/flexFitR/articles/maturity-model.html","id":"loading-libraries","dir":"Articles","previous_headings":"","what":"Loading libraries","title":"Modelling Maturity","text":"","code":"library(flexFitR) library(dplyr) library(kableExtra) library(ggpubr) library(purrr)"},{"path":"https://apariciojohan.github.io/flexFitR/articles/maturity-model.html","id":"exploring-data-explorer","dir":"Articles","previous_headings":"","what":"Exploring data explorer()","title":"Modelling Maturity","text":"","code":"data(dt_potato) results <- explorer(dt_potato, x = DAP, y = c(Canopy, GLI_2), id = Plot) names(results) #> [1] \"summ_vars\" \"summ_metadata\" \"locals_min_max\" \"dt_long\" #> [5] \"metadata\""},{"path":"https://apariciojohan.github.io/flexFitR/articles/maturity-model.html","id":"data-exploration","dir":"Articles","previous_headings":"","what":"Data exploration","title":"Modelling Maturity","text":"","code":"p1 <- plot(results, type = \"evolution\", return_gg = TRUE) p2 <- plot(results, type = \"x_by_var\", return_gg = TRUE) ggarrange(p1, p2, nrow = 2)"},{"path":"https://apariciojohan.github.io/flexFitR/articles/maturity-model.html","id":"target-function-for-maturity","dir":"Articles","previous_headings":"","what":"Target function for maturity","title":"Modelling Maturity","text":"fn_lin_pl_lin() \\[\\begin{equation} f(t; t_1, t_2, t_3, k, \\beta) = \\begin{cases} 0 & \\text{} t < t_1 \\\\ \\dfrac{k}{t_2 - t_1} \\cdot (t - t_1) & \\text{} t_1 \\leq t \\leq t_2 \\\\ k & \\text{} t_2 \\leq t \\leq t_3 \\\\ k + \\beta \\cdot (t - t_3) & \\text{} t > t_3 \\end{cases} \\end{equation}\\]","code":""},{"path":"https://apariciojohan.github.io/flexFitR/articles/maturity-model.html","id":"fitting-models-for-maturity","dir":"Articles","previous_headings":"","what":"Fitting models for maturity","title":"Modelling Maturity","text":"","code":"mod_1 <- dt_potato |> modeler( x = DAP, y = GLI_2, grp = Plot, fn = \"fn_lin_pl_lin\", parameters = c(t1 = 38.7, t2 = 62, t3 = 90, k = 0.32, beta = -0.01), subset = c(195, 40), add_zero = TRUE ) plot(mod_1, id = c(195, 40)) kable(mod_1$param)"},{"path":"https://apariciojohan.github.io/flexFitR/articles/maturity-model.html","id":"providing-initial-parameters-from-the-canopy-model","dir":"Articles","previous_headings":"","what":"Providing initial parameters from the canopy model","title":"Modelling Maturity","text":"","code":"fixed_params <- results |> pluck(\"dt_long\") |> filter(var %in% \"Canopy\" & uid %in% c(195, 40)) |> group_by(uid) |> summarise(k = max(y), .groups = \"drop\") mod_2 <- dt_potato |> modeler( x = DAP, y = Canopy, grp = Plot, fn = \"fn_piwise\", parameters = c(t1 = 45, t2 = 80, k = 0.9), fixed_params = fixed_params, subset = c(195, 40), add_zero = TRUE, max_as_last = TRUE ) plot(mod_2, id = c(195, 40)) kable(mod_2$param)"},{"path":"https://apariciojohan.github.io/flexFitR/articles/maturity-model.html","id":"passing-initial-values","dir":"Articles","previous_headings":"","what":"Passing initial values","title":"Modelling Maturity","text":"","code":"initials <- mod_2 |> pluck(\"param\") |> select(uid, t1, t2) |> mutate(t3 = 100, k = 0.32, beta = -0.01) kable(initials) mod_3 <- dt_potato |> modeler( x = DAP, y = GLI_2, grp = Plot, fn = \"fn_lin_pl_lin\", initial_vals = initials, subset = c(195, 40), add_zero = TRUE ) plot(mod_3, id = c(195, 40)) kable(mod_3$param)"},{"path":"https://apariciojohan.github.io/flexFitR/articles/maturity-model.html","id":"adding-constrains-to-the-optimization","dir":"Articles","previous_headings":"","what":"Adding constrains to the optimization","title":"Modelling Maturity","text":"","code":"mod_4 <- dt_potato |> modeler( x = DAP, y = GLI_2, grp = Plot, fn = \"fn_lin_pl_lin2\", parameters = c(t1 = 38.7, t2 = 62, dt = 28, k = 0.32, beta = -0.01), lower = c(-Inf, -Inf, 0, -Inf, -Inf), upper = c(Inf, Inf, Inf, Inf, 0), method = c(\"nlminb\", \"L-BFGS-B\"), subset = c(195, 40), add_zero = TRUE ) plot(mod_4, id = c(195, 40)) kable(mod_4$param)"},{"path":"https://apariciojohan.github.io/flexFitR/articles/plotting.html","id":"example-dataset-and-loading-libraries","dir":"Articles","previous_headings":"","what":"Example dataset and loading libraries","title":"Plotting Options","text":"","code":"library(flexFitR) library(dplyr) library(ggpubr) set.seed(10) dt <- data.frame( time = c(0, 29, 36, 42, 56, 76, 92, 100, 108), variable = c(0, 0, 0.67, 15.11, 77.38, 99.81, 99.81, 99.81, 99.81) ) |> mutate(variable = variable + rnorm(n = n(), mean = 5, sd = 6))"},{"path":"https://apariciojohan.github.io/flexFitR/articles/plotting.html","id":"expectation-function-and-modeling","dir":"Articles","previous_headings":"","what":"Expectation function and modeling","title":"Plotting Options","text":"","code":"fn <- function(t, t0, t1, t2) t0 / (1 + exp((t1 - t) / t2)) mod <- dt |> modeler( x = time, y = variable, fn = \"fn\", parameters = c(t0 = 100, t1 = 50, t2 = 5) ) mod #> #> Call: #> variable ~ fn(x, t0, t1, t2) #> #> Residuals: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> -6.1496 -2.9462 2.1181 0.4716 3.2479 6.7654 #> #> Optimization Results `head()`: #> uid t0 t1 t2 sse #> 1 101 49.2 4.01 169 #> #> Metrics: #> Groups Timing Convergence Iterations #> 1 0.3787 secs 100% 334 (id)"},{"path":"https://apariciojohan.github.io/flexFitR/articles/plotting.html","id":"plotting-predictions-and-derivatives","dir":"Articles","previous_headings":"","what":"Plotting predictions and derivatives","title":"Plotting Options","text":"","code":"a <- plot(mod, color = \"blue\", title = \"Raw data\") b <- plot(mod, type = 4, n_points = 200, color = \"black\") c <- plot(mod, type = 5, n_points = 200, color = \"black\") d <- plot(mod, type = 6, n_points = 200, color = \"black\") ggarrange(a, b, c, d)"},{"path":"https://apariciojohan.github.io/flexFitR/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Johan Aparicio. Author, maintainer. Jeffrey Endelman. Author. University Wisconsin Madison. Copyright holder.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Aparicio J, Endelman J (2024). flexFitR: Flexible Non-Linear Least Square Modelling. R package version 0.1.0, https://github.com/AparicioJohan/flexFitR, https://apariciojohan.github.io/flexFitR/.","code":"@Manual{, title = {flexFitR: Flexible Non-Linear Least Square Modelling}, author = {Johan Aparicio and Jeffrey Endelman}, year = {2024}, note = {R package version 0.1.0, https://github.com/AparicioJohan/flexFitR}, url = {https://apariciojohan.github.io/flexFitR/}, }"},{"path":[]},{"path":"https://apariciojohan.github.io/flexFitR/CODE_OF_CONDUCT.html","id":"our-pledge","dir":"","previous_headings":"","what":"Our Pledge","title":"Contributor Covenant Code of Conduct","text":"members, contributors, leaders pledge make participation community harassment-free experience everyone, regardless age, body size, visible invisible disability, ethnicity, sex characteristics, gender identity expression, level experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, sexual identity orientation. pledge act interact ways contribute open, welcoming, diverse, inclusive, healthy community.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/CODE_OF_CONDUCT.html","id":"our-standards","dir":"","previous_headings":"","what":"Our Standards","title":"Contributor Covenant Code of Conduct","text":"Examples behavior contributes positive environment community include: Demonstrating empathy kindness toward people respectful differing opinions, viewpoints, experiences Giving gracefully accepting constructive feedback Accepting responsibility apologizing affected mistakes, learning experience Focusing best just us individuals, overall community Examples unacceptable behavior include: use sexualized language imagery, sexual attention advances kind Trolling, insulting derogatory comments, personal political attacks Public private harassment Publishing others’ private information, physical email address, without explicit permission conduct reasonably considered inappropriate professional setting","code":""},{"path":"https://apariciojohan.github.io/flexFitR/CODE_OF_CONDUCT.html","id":"enforcement-responsibilities","dir":"","previous_headings":"","what":"Enforcement Responsibilities","title":"Contributor Covenant Code of Conduct","text":"Community leaders responsible clarifying enforcing standards acceptable behavior take appropriate fair corrective action response behavior deem inappropriate, threatening, offensive, harmful. Community leaders right responsibility remove, edit, reject comments, commits, code, wiki edits, issues, contributions aligned Code Conduct, communicate reasons moderation decisions appropriate.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/CODE_OF_CONDUCT.html","id":"scope","dir":"","previous_headings":"","what":"Scope","title":"Contributor Covenant Code of Conduct","text":"Code Conduct applies within community spaces, also applies individual officially representing community public spaces. Examples representing community include using official e-mail address, posting via official social media account, acting appointed representative online offline event.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/CODE_OF_CONDUCT.html","id":"enforcement","dir":"","previous_headings":"","what":"Enforcement","title":"Contributor Covenant Code of Conduct","text":"Instances abusive, harassing, otherwise unacceptable behavior may reported community leaders responsible enforcement johanstevenapa@gmail.com. complaints reviewed investigated promptly fairly. community leaders obligated respect privacy security reporter incident.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/CODE_OF_CONDUCT.html","id":"enforcement-guidelines","dir":"","previous_headings":"","what":"Enforcement Guidelines","title":"Contributor Covenant Code of Conduct","text":"Community leaders follow Community Impact Guidelines determining consequences action deem violation Code Conduct:","code":""},{"path":"https://apariciojohan.github.io/flexFitR/CODE_OF_CONDUCT.html","id":"id_1-correction","dir":"","previous_headings":"Enforcement Guidelines","what":"1. Correction","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Use inappropriate language behavior deemed unprofessional unwelcome community. Consequence: private, written warning community leaders, providing clarity around nature violation explanation behavior inappropriate. public apology may requested.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/CODE_OF_CONDUCT.html","id":"id_2-warning","dir":"","previous_headings":"Enforcement Guidelines","what":"2. Warning","title":"Contributor Covenant Code of Conduct","text":"Community Impact: violation single incident series actions. Consequence: warning consequences continued behavior. interaction people involved, including unsolicited interaction enforcing Code Conduct, specified period time. includes avoiding interactions community spaces well external channels like social media. Violating terms may lead temporary permanent ban.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/CODE_OF_CONDUCT.html","id":"id_3-temporary-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"3. Temporary Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: serious violation community standards, including sustained inappropriate behavior. Consequence: temporary ban sort interaction public communication community specified period time. public private interaction people involved, including unsolicited interaction enforcing Code Conduct, allowed period. Violating terms may lead permanent ban.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/CODE_OF_CONDUCT.html","id":"id_4-permanent-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"4. Permanent Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Demonstrating pattern violation community standards, including sustained inappropriate behavior, harassment individual, aggression toward disparagement classes individuals. Consequence: permanent ban sort public interaction within community.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/CODE_OF_CONDUCT.html","id":"attribution","dir":"","previous_headings":"","what":"Attribution","title":"Contributor Covenant Code of Conduct","text":"Code Conduct adapted Contributor Covenant, version 2.1, available https://www.contributor-covenant.org/version/2/1/code_of_conduct.html. Community Impact Guidelines inspired [Mozilla’s code conduct enforcement ladder][https://github.com/mozilla/inclusion]. answers common questions code conduct, see FAQ https://www.contributor-covenant.org/faq. Translations available https://www.contributor-covenant.org/translations.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/index.html","id":"flexfitr-","dir":"","previous_headings":"","what":"Flexible Non-Linear Least Square Modelling","title":"Flexible Non-Linear Least Square Modelling","text":"flexFitR R package designed efficient modeling analysis large complex datasets. offers powerful tools parameter estimation, model fitting, visualization, leveraging {optimx} package optimization future package parallel processing.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Flexible Non-Linear Least Square Modelling","text":"can install development version flexFitR GitHub :","code":"# install.packages(\"devtools\") devtools::install_github(\"AparicioJohan/flexFitR\")"},{"path":"https://apariciojohan.github.io/flexFitR/index.html","id":"features","dir":"","previous_headings":"","what":"Features","title":"Flexible Non-Linear Least Square Modelling","text":"Parameter Estimation: Utilizes {optimx} derivative-free algorithms solve estimate parameters given function. Parallelization: Implements parallel processing using future package, enabling efficient fitting hundreds curves simultaneously. Visualization Tools: Provides variety plots visualize model fits, correlations, predictions, . Statistical Rigor: Offers standard errors p-values coefficients, supporting robust conclusions interpretations. Prediction: Facilitates prediction non-observed data points. Flexibility: Allows users fix certain parameters model specify different initial values per grouping factor. Custom Modeling Functions: Equipped built-modeling functions common analysis tasks, also permitting users supply custom functions.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/index.html","id":"example","dir":"","previous_headings":"","what":"Example","title":"Flexible Non-Linear Least Square Modelling","text":"’s simple example get started flexFitR. example demonstrates fitting piecewise regression model:","code":"library(flexFitR) dt <- data.frame( time = c(0, 29, 36, 42, 56, 76, 92, 100, 108), variable = c(0, 0, 0.67, 15.11, 77.38, 99.81, 99.81, 99.81, 99.81) ) plot(explorer(dt, time, variable), type = \"xy\") fun <- function(t, t1 = 45, t2 = 80, k = 0.9) { if (t < t1) { y <- 0 } else if (t >= t1 && t <= t2) { y <- k / (t2 - t1) * (t - t1) } else { y <- k } return(y) } # Fitting piecewise regression mod_1 <- dt |> modeler( x = time, y = variable, fn = \"fun\", parameters = c(t1 = 45, t2 = 80, k = 90) ) print(mod_1) Call: variable ~ fun(x, t1, t2, k) Residuals: Min. 1st Qu. Median Mean 3rd Qu. Max. 0.00000 0.00000 0.00000 0.07444 0.00000 0.67000 Optimization Results `head()`: uid t1 t2 k sse 1 38.6 61 99.8 0.449 Metrics: Groups Timing Convergence Iterations 1 0.4068 secs 100% 511 (id) # Auto plot plot(mod_1) # Coefficients coef(mod_1) # A tibble: 3 × 6 uid coefficient solution std.error `t value` `Pr(>|t|)` 1 1 t1 38.6 0.0779 496. 4.54e-15 2 1 t2 61.0 0.0918 665. 7.82e-16 3 1 k 99.8 0.137 730. 4.47e-16 # Variance-Covariance Matrix vcov(mod_1) $`1` t1 t2 k t1 6.061705e-03 -0.002940001 1.877072e-07 t2 -2.940001e-03 0.008431400 4.204939e-03 k 1.877072e-07 0.004204939 1.870426e-02 # Making predictions predict(mod_1, x = 45) # A tibble: 1 × 4 uid x_new predicted.value std.error 1 1 45 28.5 0.223"},{"path":"https://apariciojohan.github.io/flexFitR/index.html","id":"documentation","dir":"","previous_headings":"","what":"Documentation","title":"Flexible Non-Linear Least Square Modelling","text":"detailed documentation examples, visit flexFitR Vignette 1: start Vignette 2: Modeling Canopy Vignette 3: Modeling Plant Height Vignette 4: Modeling VIs","code":""},{"path":"https://apariciojohan.github.io/flexFitR/index.html","id":"contributing","dir":"","previous_headings":"","what":"Contributing","title":"Flexible Non-Linear Least Square Modelling","text":"Contributions flexFitR welcome! ’d like contribute, please fork repository submit pull request. significant changes, please open issue first discuss ideas.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/index.html","id":"code-of-conduct","dir":"","previous_headings":"","what":"Code of Conduct","title":"Flexible Non-Linear Least Square Modelling","text":"Please note flexFitR project released Contributor Code Conduct. contributing project, agree abide terms.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/index.html","id":"license","dir":"","previous_headings":"","what":"License","title":"Flexible Non-Linear Least Square Modelling","text":"flexFitR licensed MIT License. See LICENSE file details.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2024 flexFitR authors Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/anova.modeler.html","id":null,"dir":"Reference","previous_headings":"","what":"Extra sum-of-squares F-test for objects of class modeler — anova.modeler","title":"Extra sum-of-squares F-test for objects of class modeler — anova.modeler","text":"anova objects class modeler","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/anova.modeler.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Extra sum-of-squares F-test for objects of class modeler — anova.modeler","text":"","code":"# S3 method for class 'modeler' anova(reduced_model, full_model = NULL, ...)"},{"path":"https://apariciojohan.github.io/flexFitR/reference/anova.modeler.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Extra sum-of-squares F-test for objects of class modeler — anova.modeler","text":"reduced_model object class `modeler` reduced number parameters. full_model object class `modeler` number parameters. ... parameters. future improvements.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/anova.modeler.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Extra sum-of-squares F-test for objects of class modeler — anova.modeler","text":"tibble columns giving F test p values.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/anova.modeler.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Extra sum-of-squares F-test for objects of class modeler — anova.modeler","text":"Johan Aparicio [aut]","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/anova.modeler.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Extra sum-of-squares F-test for objects of class modeler — anova.modeler","text":"","code":"library(flexFitR) dt <- data.frame(X = 1:6, Y = c(12, 16, 44, 50, 95, 100)) mo_1 <- modeler(dt, X, Y, fn = \"fn_lin\", param = c(m = 10, b = -5)) #> Loading required package: foreach #> Loading required package: future plot(mo_1) mo_2 <- modeler(dt, X, Y, fn = \"fn_quad\", param = c(a = 1, b = 10, c = 5)) plot(mo_2) anova(mo_1, mo_2) #> # A tibble: 1 × 9 #> uid RSS_reduced RSS_full n df1 df2 F `Pr(>F)` . #> #> 1 1 449. 385. 6 1 3 0.494 0.533 ns"},{"path":"https://apariciojohan.github.io/flexFitR/reference/coef.modeler.html","id":null,"dir":"Reference","previous_headings":"","what":"Coefficients of an object of class modeler — coef.modeler","title":"Coefficients of an object of class modeler — coef.modeler","text":"Coefficients object class modeler","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/coef.modeler.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Coefficients of an object of class modeler — coef.modeler","text":"","code":"# S3 method for class 'modeler' coef(x, id = NULL, metadata = FALSE, df = FALSE, ...)"},{"path":"https://apariciojohan.github.io/flexFitR/reference/coef.modeler.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Coefficients of an object of class modeler — coef.modeler","text":"x object inheriting class modeler resulting executing function modeler() id unique identifier filter . NULL default. metadata TRUE FALSE. Whether bring metadata calculating coefficients. df TRUE FALSE. Whether return degrees freedom calculating coefficients. FALSE default. ... parameters. future improvements.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/coef.modeler.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Coefficients of an object of class modeler — coef.modeler","text":"data.frame object coefficients standard errors.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/coef.modeler.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Coefficients of an object of class modeler — coef.modeler","text":"Johan Aparicio [aut]","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/coef.modeler.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Coefficients of an object of class modeler — coef.modeler","text":"","code":"library(flexFitR) data(dt_potato) explorer <- explorer(dt_potato, x = DAP, y = c(Canopy, GLI_2), id = Plot) mod_1 <- dt_potato |> modeler( x = DAP, y = Canopy, grp = Plot, fn = \"fn_piwise\", parameters = c(t1 = 45, t2 = 80, k = 0.9), subset = c(15, 2, 45), add_zero = TRUE, max_as_last = TRUE ) print(mod_1) #> #> Call: #> Canopy ~ fn_piwise(x, t1, t2, k) #> #> Sum of Squares Error: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> 0.002601 0.504829 1.007057 2.674719 4.010777 7.014498 #> #> Optimization Results `head()`: #> uid t1 t2 k sse #> 2 35.2 60.7 100.0 7.0145 #> 15 38.5 69.4 99.8 1.0071 #> 45 38.3 64.5 100.0 0.0026 #> #> Metrics: #> Groups Timing Convergence Iterations #> 3 1.8156 secs 100% 414 (id) #> coef(mod_1, id = 2) #> # A tibble: 3 × 6 #> uid coefficient solution std.error `t value` `Pr(>|t|)` #> #> 1 2 t1 35.2 0.239 147. 6.57e-12 #> 2 2 t2 60.7 0.371 164. 3.53e-12 #> 3 2 k 100. 0.541 185. 1.68e-12"},{"path":"https://apariciojohan.github.io/flexFitR/reference/confint.modeler.html","id":null,"dir":"Reference","previous_headings":"","what":"Confidence Intervals for an object of class modeler — confint.modeler","title":"Confidence Intervals for an object of class modeler — confint.modeler","text":"confint object class modeler","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/confint.modeler.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Confidence Intervals for an object of class modeler — confint.modeler","text":"","code":"# S3 method for class 'modeler' confint(x, parm = NULL, level = 0.95, id = NULL, ...)"},{"path":"https://apariciojohan.github.io/flexFitR/reference/confint.modeler.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Confidence Intervals for an object of class modeler — confint.modeler","text":"x object inheriting class modeler resulting executing function modeler() parm specification parameters given confidence intervals, must vector names. missing, parameters considered. level confidence level required. Default 0.95. id unique identifier filter . NULL default. ... parameters. future improvements.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/confint.modeler.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Confidence Intervals for an object of class modeler — confint.modeler","text":"tibble columns giving lower upper confidence limits parameter.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/confint.modeler.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Confidence Intervals for an object of class modeler — confint.modeler","text":"Johan Aparicio [aut]","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/confint.modeler.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Confidence Intervals for an object of class modeler — confint.modeler","text":"","code":"library(flexFitR) data(dt_potato) mod_1 <- dt_potato |> modeler( x = DAP, y = Canopy, grp = Plot, fn = \"fn_piwise\", parameters = c(t1 = 45, t2 = 80, k = 0.9), subset = c(15, 35, 45), add_zero = TRUE, max_as_last = TRUE ) print(mod_1) #> #> Call: #> Canopy ~ fn_piwise(x, t1, t2, k) #> #> Sum of Squares Error: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> 0.002601 0.504829 1.007057 0.968957 1.452134 1.897212 #> #> Optimization Results `head()`: #> uid t1 t2 k sse #> 15 38.5 69.4 99.8 1.0071 #> 35 52.2 61.4 100.0 1.8972 #> 45 38.3 64.5 100.0 0.0026 #> #> Metrics: #> Groups Timing Convergence Iterations #> 3 2.7826 secs 100% 410 (id) #> confint(mod_1) #> # A tibble: 9 × 6 #> uid coefficient solution std.error ci_lower ci_upper #> #> 1 15 t1 38.5 0.162 38.1 38.8 #> 2 15 t2 69.4 0.283 68.7 70.1 #> 3 15 k 99.8 0.205 99.3 100. #> 4 35 t1 52.2 2.00 47.3 57.1 #> 5 35 t2 61.4 2.87 54.4 68.5 #> 6 35 k 100. 0.281 99.3 101. #> 7 45 t1 38.3 0.00704 38.3 38.3 #> 8 45 t2 64.5 0.00972 64.4 64.5 #> 9 45 k 100. 0.0104 100. 100."},{"path":"https://apariciojohan.github.io/flexFitR/reference/dot-fitter_curve.html","id":null,"dir":"Reference","previous_headings":"","what":"General-purpose optimization — .fitter_curve","title":"General-purpose optimization — .fitter_curve","text":"function .fitter_curve used internally find parameters requested.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/dot-fitter_curve.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"General-purpose optimization — .fitter_curve","text":"","code":".fitter_curve(data, id, fn, method, lower, upper, control, .keep)"},{"path":"https://apariciojohan.github.io/flexFitR/reference/dot-fitter_curve.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"General-purpose optimization — .fitter_curve","text":"data nested data.frame columns . id optional vector IDs filter data. Default NULL, meaning ids used. fn string specifying name function used curve fitting. Default \"fn_piwise\". method character vector specifying optimization methods used. See optimx package available methods. Default c(\"subplex\", \"pracmanm\", \"anms\"). lower Numeric vector specifying lower bounds parameters. Default -Inf parameters. upper Numeric vector specifying upper bounds parameters. Default Inf parameters. control list control parameters passed optimization function. example, list(maxit = 500).","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/dot-fitter_curve.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"General-purpose optimization — .fitter_curve","text":"","code":"library(flexFitR) data(dt_potato) explorer <- explorer(dt_potato, x = DAP, y = c(Canopy, GLI_2), id = Plot) mod_1 <- dt_potato |> modeler( x = DAP, y = GLI_2, grp = Plot, fn = \"fn_lin_pl_lin\", parameters = c(t1 = 38.7, t2 = 62, t3 = 90, k = 0.32, beta = -0.01), subset = 195, add_zero = TRUE )"},{"path":"https://apariciojohan.github.io/flexFitR/reference/dt_chips.html","id":null,"dir":"Reference","previous_headings":"","what":"Drone Data in Potato 2022 — dt_chips","title":"Drone Data in Potato 2022 — dt_chips","text":"Vegetative indices biomass related traits potato trial arranged p-rep design.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/dt_chips.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Drone Data in Potato 2022 — dt_chips","text":"","code":"dt_chips"},{"path":"https://apariciojohan.github.io/flexFitR/reference/dt_chips.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Drone Data in Potato 2022 — dt_chips","text":"tibble 1568 rows 17 variables: Trial chr trial name DAP dbl denoting Days planting Plot dbl denoting unique plot id Row dbl denoting row coordinate Range dbl denoting range coordinate Gen chr denoting genotype id Yield dbl Total Yield measured end season VineMaturity dbl VineMaturity measure season Red - Canopy dbl denoting drone-derived traits","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/dt_chips.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Drone Data in Potato 2022 — dt_chips","text":"UW - Potato Breeding Program","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/dt_potato.html","id":null,"dir":"Reference","previous_headings":"","what":"Drone Data in Potato 2020 — dt_potato","title":"Drone Data in Potato 2020 — dt_potato","text":"Vegetative indices biomass related traits potato trial arranged p-rep design.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/dt_potato.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Drone Data in Potato 2020 — dt_potato","text":"","code":"dt_potato"},{"path":"https://apariciojohan.github.io/flexFitR/reference/dt_potato.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Drone Data in Potato 2020 — dt_potato","text":"tibble 1372 rows 17 variables: Trial chr trial name DAP dbl denoting Days planting Plot dbl denoting unique plot id Row dbl denoting row coordinate Range dbl denoting range coordinate Gen chr denoting genotype id Yield dbl Total Yield measured end season VineMaturity dbl VineMaturity measure season Red - Canopy dbl denoting drone-derived traits","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/dt_potato.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Drone Data in Potato 2020 — dt_potato","text":"UW - Potato Breeding Program","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/explorer.html","id":null,"dir":"Reference","previous_headings":"","what":"Explore Data — explorer","title":"Explore Data — explorer","text":"Explores data data frame wide format.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/explorer.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Explore Data — explorer","text":"","code":"explorer(data, x, y, id, metadata)"},{"path":"https://apariciojohan.github.io/flexFitR/reference/explorer.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Explore Data — explorer","text":"data data.frame wide format containing data. x name column `data` contains x points. y names columns `data` contain variables analyzed. id names columns `data` contains grouping variable. metadata names columns `data` keep across analysis.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/explorer.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Explore Data — explorer","text":"object class explorer, list containing following elements: summ_vars data.frame containing summary statistics trait x point, including minimum, mean, median, maximum, standard deviation, coefficient variation, number non-missing values, percentage missing values, percentage negative values. summ_metadata data.frame summarizing metadata. locals_min_max data.frame containing local minima maxima mean y values x. dt_long data.frame long format, columns uid, metadata, var, x, y metadata character vector names variables keep across.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/explorer.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Explore Data — explorer","text":"function helps explore dataset analyzed modeler().","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/explorer.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Explore Data — explorer","text":"","code":"library(flexFitR) data(dt_potato) results <- dt_potato |> explorer( x = DAP, y = c(Canopy, PH), id = Plot, metadata = c(Gen, Row, Range) ) names(results) #> [1] \"summ_vars\" \"summ_metadata\" \"locals_min_max\" \"dt_long\" #> [5] \"metadata\" head(results$summ_vars) #> # A tibble: 6 × 12 #> var x Min Mean Median Max SD CV n miss `miss%` #> #> 1 Canopy 29 0 0 0 0 0 NaN 196 0 0 #> 2 Canopy 36 0 2.95 1.84 15.1 3.22 1.09 196 0 0 #> 3 Canopy 42 0.763 23.4 22.9 46.2 9.31 0.398 196 0 0 #> 4 Canopy 56 33.4 75.8 75.2 98.9 12.4 0.164 196 0 0 #> 5 Canopy 76 89.1 99.7 100 100 1.04 0.0104 196 0 0 #> 6 Canopy 92 62.5 97.0 98.4 100. 4.36 0.0449 196 0 0 #> # ℹ 1 more variable: `neg%` plot(results, label_size = 4, signif = TRUE, n_row = 2) # New data format head(results$dt_long) #> # A tibble: 6 × 7 #> uid Gen Row Range var x y #> #> 1 1 W17037-24 1 1 Canopy 29 0 #> 2 1 W17037-24 1 1 PH 29 NA #> 3 1 W17037-24 1 1 Canopy 36 0.67 #> 4 1 W17037-24 1 1 PH 36 0.0154 #> 5 1 W17037-24 1 1 Canopy 42 15.1 #> 6 1 W17037-24 1 1 PH 42 0.0173"},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp1_exp.html","id":null,"dir":"Reference","previous_headings":"","what":"Exponential Exponential Function 1 — fn_exp1_exp","title":"Exponential Exponential Function 1 — fn_exp1_exp","text":"Computes value based exponential growth curve exponential decay model time.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp1_exp.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Exponential Exponential Function 1 — fn_exp1_exp","text":"","code":"fn_exp1_exp(t, t1, t2, alpha, beta)"},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp1_exp.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Exponential Exponential Function 1 — fn_exp1_exp","text":"t Numeric. time value. t1 Numeric. lower threshold time. Assumed known. t2 Numeric. upper threshold time. alpha Numeric. parameter first exponential term. Must greater 0. beta Numeric. parameter second exponential term. Must less 0.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp1_exp.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Exponential Exponential Function 1 — fn_exp1_exp","text":"numeric value based double exponential model. t less t1, function returns 0. t t1 t2 (inclusive), function returns exp(alpha * (t - t1)) - 1. t greater t2, function returns (exp(alpha * (t2 - t1)) - 1) * exp(beta * (t - t2)).","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp1_exp.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Exponential Exponential Function 1 — fn_exp1_exp","text":"$$ f(t; t_1, t_2, \\alpha, \\beta) = \\begin{cases} 0 & \\text{} t < t_1 \\\\ e^{\\alpha \\cdot (t - t_1)} - 1 & \\text{} t_1 \\leq t \\leq t_2 \\\\ \\left(e^{\\alpha \\cdot (t_2 - t_1)} - 1\\right) \\cdot e^{\\beta \\cdot (t - t_2)} & \\text{} t > t_2 \\end{cases} $$","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp1_exp.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Exponential Exponential Function 1 — fn_exp1_exp","text":"","code":"library(flexFitR) plot_fn( fn = \"fn_exp1_exp\", params = c(t1 = 35, t2 = 55, alpha = 1 / 20, beta = -1 / 30), interval = c(0, 108), n_points = 2000, auc_label_size = 3, y_auc_label = 0.2 )"},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp1_lin.html","id":null,"dir":"Reference","previous_headings":"","what":"Exponential Linear Function 1 — fn_exp1_lin","title":"Exponential Linear Function 1 — fn_exp1_lin","text":"Computes value based exponential growth curve linear decay model time.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp1_lin.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Exponential Linear Function 1 — fn_exp1_lin","text":"","code":"fn_exp1_lin(t, t1, t2, alpha, beta)"},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp1_lin.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Exponential Linear Function 1 — fn_exp1_lin","text":"t Numeric. time value. t1 Numeric. lower threshold time. Assumed known. t2 Numeric. upper threshold time. alpha Numeric. parameter exponential term. Must greater 0. beta Numeric. parameter linear term. Must less 0.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp1_lin.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Exponential Linear Function 1 — fn_exp1_lin","text":"numeric value based exponential linear model. t less t1, function returns 0. t t1 t2 (inclusive), function returns exp(alpha * (t - t1)) - 1. t greater t2, function returns beta * (t - t2) + (exp(alpha * (t2 - t1)) - 1).","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp1_lin.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Exponential Linear Function 1 — fn_exp1_lin","text":"$$ f(t; t_1, t_2, \\alpha, \\beta) = \\begin{cases} 0 & \\text{} t < t_1 \\\\ e^{\\alpha \\cdot (t - t_1)} - 1 & \\text{} t_1 \\leq t \\leq t_2 \\\\ \\beta \\cdot (t - t_2) + \\left(e^{\\alpha \\cdot (t_2 - t_1)} - 1\\right) & \\text{} t > t_2 \\end{cases} $$","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp1_lin.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Exponential Linear Function 1 — fn_exp1_lin","text":"","code":"library(flexFitR) plot_fn( fn = \"fn_exp1_lin\", params = c(t1 = 35, t2 = 55, alpha = 1 / 20, beta = -1 / 40), interval = c(0, 108), n_points = 2000, auc_label_size = 3 )"},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp2_exp.html","id":null,"dir":"Reference","previous_headings":"","what":"Exponential Exponential Function 2 — fn_exp2_exp","title":"Exponential Exponential Function 2 — fn_exp2_exp","text":"Computes value based exponential growth curve exponential decay model time.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp2_exp.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Exponential Exponential Function 2 — fn_exp2_exp","text":"","code":"fn_exp2_exp(t, t1, t2, alpha, beta)"},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp2_exp.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Exponential Exponential Function 2 — fn_exp2_exp","text":"t Numeric. time value. t1 Numeric. lower threshold time. Assumed known. t2 Numeric. upper threshold time. alpha Numeric. parameter first exponential term. Must greater 0. beta Numeric. parameter second exponential term. Must less 0.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp2_exp.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Exponential Exponential Function 2 — fn_exp2_exp","text":"numeric value based double exponential model. t less t1, function returns 0. t t1 t2 (inclusive), function returns exp(alpha * (t - t1)^2) - 1. t greater t2, function returns (exp(alpha * (t2 - t1)^2) - 1) * exp(beta * (t - t2)).","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp2_exp.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Exponential Exponential Function 2 — fn_exp2_exp","text":"$$ f(t; t_1, t_2, \\alpha, \\beta) = \\begin{cases} 0 & \\text{} t < t_1 \\\\ e^{\\alpha \\cdot (t - t_1)^2} - 1 & \\text{} t_1 \\leq t \\leq t_2 \\\\ \\left(e^{\\alpha \\cdot (t_2 - t_1)^2} - 1\\right) \\cdot e^{\\beta \\cdot (t - t_2)} & \\text{} t > t_2 \\end{cases} $$","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp2_exp.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Exponential Exponential Function 2 — fn_exp2_exp","text":"","code":"library(flexFitR) plot_fn( fn = \"fn_exp2_exp\", params = c(t1 = 35, t2 = 55, alpha = 1 / 600, beta = -1 / 30), interval = c(0, 108), n_points = 2000, auc_label_size = 3, y_auc_label = 0.15 )"},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp2_lin.html","id":null,"dir":"Reference","previous_headings":"","what":"Exponential Linear Function 2 — fn_exp2_lin","title":"Exponential Linear Function 2 — fn_exp2_lin","text":"Computes value based exponential growth curve linear decay model time.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp2_lin.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Exponential Linear Function 2 — fn_exp2_lin","text":"","code":"fn_exp2_lin(t, t1, t2, alpha, beta)"},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp2_lin.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Exponential Linear Function 2 — fn_exp2_lin","text":"t Numeric. time value. t1 Numeric. lower threshold time. Assumed known. t2 Numeric. upper threshold time. alpha Numeric. parameter exponential term. Must greater 0. beta Numeric. parameter linear term. Must less 0.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp2_lin.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Exponential Linear Function 2 — fn_exp2_lin","text":"numeric value based exponential linear model. t less t1, function returns 0. t t1 t2 (inclusive), function returns exp(alpha * (t - t1)^2) - 1. t greater t2, function returns beta * (t - t2) + (exp(alpha * (t2 - t1)^2) - 1).","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp2_lin.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Exponential Linear Function 2 — fn_exp2_lin","text":"$$ f(t; t_1, t_2, \\alpha, \\beta) = \\begin{cases} 0 & \\text{} t < t_1 \\\\ e^{\\alpha \\cdot (t - t_1)^2} - 1 & \\text{} t_1 \\leq t \\leq t_2 \\\\ \\beta \\cdot (t - t_2) + \\left(e^{\\alpha \\cdot (t_2 - t_1)^2} - 1\\right) & \\text{} t > t_2 \\end{cases} $$","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_exp2_lin.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Exponential Linear Function 2 — fn_exp2_lin","text":"","code":"library(flexFitR) plot_fn( fn = \"fn_exp2_lin\", params = c(t1 = 35, t2 = 55, alpha = 1 / 600, beta = -1 / 80), interval = c(0, 108), n_points = 2000, auc_label_size = 3 )"},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin.html","id":null,"dir":"Reference","previous_headings":"","what":"Linear Function — fn_lin","title":"Linear Function — fn_lin","text":"Computes value based linear function.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Linear Function — fn_lin","text":"","code":"fn_lin(t, m, b)"},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Linear Function — fn_lin","text":"t Numeric value. m Numeric value slope coefficient. b Numeric value intercept coefficient.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Linear Function — fn_lin","text":"numeric value based linear function.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Linear Function — fn_lin","text":"$$ f(t; m, b) = m \\cdot t + b $$","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Linear Function — fn_lin","text":"","code":"library(flexFitR) plot_fn( fn = \"fn_lin\", params = c(m = 2, b = 10), interval = c(0, 108), n_points = 2000 )"},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin_pl_lin.html","id":null,"dir":"Reference","previous_headings":"","what":"Linear Plateau Linear — fn_lin_pl_lin","title":"Linear Plateau Linear — fn_lin_pl_lin","text":"Linear Plateau Linear","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin_pl_lin.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Linear Plateau Linear — fn_lin_pl_lin","text":"","code":"fn_lin_pl_lin(t, t1, t2, t3, k, beta)"},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin_pl_lin.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Linear Plateau Linear — fn_lin_pl_lin","text":"t Numeric. time value. t1 Numeric. lower threshold time. Default 45. t2 Numeric. upper threshold time plateau. Default 80. t3 Numeric. lower threshold time plateau. Default 45. k Numeric. maximum value function. Default 0.9. beta Numeric. Slope linear decay.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin_pl_lin.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Linear Plateau Linear — fn_lin_pl_lin","text":"numeric value based linear plateau linear model.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin_pl_lin.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Linear Plateau Linear — fn_lin_pl_lin","text":"$$ f(t; t_1, t_2, t_3, k, \\beta) = \\begin{cases} 0 & \\text{} t < t_1 \\\\ \\dfrac{k}{t_2 - t_1} \\cdot (t - t_1) & \\text{} t_1 \\leq t \\leq t_2 \\\\ k & \\text{} t_2 \\leq t \\leq t_3 \\\\ k + \\beta \\cdot (t - t_3) & \\text{} t > t_3 \\end{cases} $$","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin_pl_lin.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Linear Plateau Linear — fn_lin_pl_lin","text":"","code":"library(flexFitR) plot_fn( fn = \"fn_lin_pl_lin\", params = c(t1 = 38.7, t2 = 62, t3 = 90, k = 0.32, beta = -0.01), interval = c(0, 108), n_points = 2000, auc_label_size = 3 )"},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin_pl_lin2.html","id":null,"dir":"Reference","previous_headings":"","what":"Linear Plateau Linear with Constrains — fn_lin_pl_lin2","title":"Linear Plateau Linear with Constrains — fn_lin_pl_lin2","text":"Linear Plateau Linear Constrains","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin_pl_lin2.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Linear Plateau Linear with Constrains — fn_lin_pl_lin2","text":"","code":"fn_lin_pl_lin2(t, t1, t2, dt, k, beta)"},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin_pl_lin2.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Linear Plateau Linear with Constrains — fn_lin_pl_lin2","text":"t Numeric. time value. t1 Numeric. lower threshold time. t2 Numeric. upper threshold time plateau. dt Numeric. dt = t3 - t2. k Numeric. maximum value function. beta Numeric. Slope linear decay.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin_pl_lin2.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Linear Plateau Linear with Constrains — fn_lin_pl_lin2","text":"numeric value based linear plateau linear model.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin_pl_lin2.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Linear Plateau Linear with Constrains — fn_lin_pl_lin2","text":"$$ f(t; t_1, t_2, dt, k, \\beta) = \\begin{cases} 0 & \\text{} t < t_1 \\\\ \\dfrac{k}{t_2 - t_1} \\cdot (t - t_1) & \\text{} t_1 \\leq t \\leq t_2 \\\\ k & \\text{} t_2 \\leq t \\leq (t_2 + dt) \\\\ k + \\beta \\cdot (t - (t_2 + dt)) & \\text{} t > (t_2 + dt) \\end{cases} $$","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin_pl_lin2.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Linear Plateau Linear with Constrains — fn_lin_pl_lin2","text":"","code":"library(flexFitR) plot_fn( fn = \"fn_lin_pl_lin2\", params = c(t1 = 38.7, t2 = 62, dt = 28, k = 0.32, beta = -0.01), interval = c(0, 108), n_points = 2000, auc_label_size = 3 )"},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin_pl_lin3.html","id":null,"dir":"Reference","previous_headings":"","what":"Linear Plateau Linear Constrains — fn_lin_pl_lin3","title":"Linear Plateau Linear Constrains — fn_lin_pl_lin3","text":"Linear Plateau Linear Constrains","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin_pl_lin3.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Linear Plateau Linear Constrains — fn_lin_pl_lin3","text":"","code":"fn_lin_pl_lin3(t, t1, t2, t3, k, beta)"},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin_pl_lin3.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Linear Plateau Linear Constrains — fn_lin_pl_lin3","text":"t Numeric. time value. t1 Numeric. lower threshold time. Default 45. t2 Numeric. upper threshold time plateau. Default 80. t3 Numeric. lower threshold time plateau. Default 45. k Numeric. maximum value function. Default 0.9. beta Numeric. Slope linear decay.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin_pl_lin3.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Linear Plateau Linear Constrains — fn_lin_pl_lin3","text":"numeric value based linear plateau linear model.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin_pl_lin3.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Linear Plateau Linear Constrains — fn_lin_pl_lin3","text":"$$ f(t; t_1, t_2, t_3, k, \\beta) = \\begin{cases} 0 & \\text{} t < t_1 \\\\ \\dfrac{k}{t_2 - t_1} \\cdot (t - t_1) & \\text{} t_1 \\leq t \\leq t_2 \\\\ k & \\text{} t_2 \\leq t \\leq t_3 \\\\ k + \\beta \\cdot (t - t_3) & \\text{} t > t_3 \\end{cases} $$","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_lin_pl_lin3.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Linear Plateau Linear Constrains — fn_lin_pl_lin3","text":"","code":"library(flexFitR) plot_fn( fn = \"fn_lin_pl_lin3\", params = c(t1 = 38.7, t2 = 62, t3 = 90, k = 0.32, beta = -0.01), interval = c(0, 108), n_points = 2000, auc_label_size = 3 )"},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_piwise.html","id":null,"dir":"Reference","previous_headings":"","what":"Piecewise Linear Regression — fn_piwise","title":"Piecewise Linear Regression — fn_piwise","text":"Computes value based linear growth curve reaching plateau time.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_piwise.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Piecewise Linear Regression — fn_piwise","text":"","code":"fn_piwise(t, t1 = 45, t2 = 80, k = 0.9)"},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_piwise.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Piecewise Linear Regression — fn_piwise","text":"t Numeric. time value. t1 Numeric. lower threshold time. Default 45. t2 Numeric. upper threshold time. Default 80. k Numeric. maximum value function. Default 0.9. Assumed known.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_piwise.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Piecewise Linear Regression — fn_piwise","text":"numeric value based threshold model. t less t1, function returns 0. t t1 t2 (inclusive), function returns value 0 k linear trend. t greater t2, function returns k.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_piwise.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Piecewise Linear Regression — fn_piwise","text":"$$ f(t; t_1, t_2, k) = \\begin{cases} 0 & \\text{} t < t_1 \\\\ \\dfrac{k}{t_2 - t_1} \\cdot (t - t_1) & \\text{} t_1 \\leq t \\leq t_2 \\\\ k & \\text{} t > t_2 \\end{cases} $$","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_piwise.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Piecewise Linear Regression — fn_piwise","text":"","code":"library(flexFitR) plot_fn( fn = \"fn_piwise\", params = c(t1 = 34.9, t2 = 61.8, k = 100), interval = c(0, 108), n_points = 2000, auc_label_size = 3 )"},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_quad.html","id":null,"dir":"Reference","previous_headings":"","what":"Quadratic Function — fn_quad","title":"Quadratic Function — fn_quad","text":"Computes value based quadratic function..","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_quad.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Quadratic Function — fn_quad","text":"","code":"fn_quad(t, a, b, c)"},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_quad.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Quadratic Function — fn_quad","text":"t Numeric value. Numeric value coefficient . b Numeric value coefficient b. c Numeric value coefficient c.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_quad.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Quadratic Function — fn_quad","text":"numeric value based linear function.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_quad.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Quadratic Function — fn_quad","text":"$$ f(t; , b, c) = \\cdot t^2 + b \\cdot t + c $$","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/fn_quad.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Quadratic Function — fn_quad","text":"","code":"library(flexFitR) plot_fn(fn = \"fn_quad\", params = c(a = 1, b = 10, c = 5))"},{"path":"https://apariciojohan.github.io/flexFitR/reference/goodness_of_fit.html","id":null,"dir":"Reference","previous_headings":"","what":"Akaike's An Information Criterion for an object of class modeler — goodness_of_fit","title":"Akaike's An Information Criterion for an object of class modeler — goodness_of_fit","text":"Generic function calculating Akaike's ‘Information Criterion’ fitted model object class modeler.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/goodness_of_fit.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Akaike's An Information Criterion for an object of class modeler — goodness_of_fit","text":"","code":"# S3 method for class 'modeler' AIC(object, ..., k = 2) # S3 method for class 'modeler' BIC(object, ...)"},{"path":"https://apariciojohan.github.io/flexFitR/reference/goodness_of_fit.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Akaike's An Information Criterion for an object of class modeler — goodness_of_fit","text":"object object inheriting class modeler resulting executing function modeler() ... parameters. future improvements. k Numeric, penalty per parameter used; default k = 2 classical AIC.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/goodness_of_fit.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Akaike's An Information Criterion for an object of class modeler — goodness_of_fit","text":"tibble columns giving corresponding AIC BIC.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/goodness_of_fit.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Akaike's An Information Criterion for an object of class modeler — goodness_of_fit","text":"Johan Aparicio [aut]","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/goodness_of_fit.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Akaike's An Information Criterion for an object of class modeler — goodness_of_fit","text":"","code":"library(flexFitR) dt <- data.frame(X = 1:6, Y = c(12, 16, 44, 50, 95, 100)) mo_1 <- modeler(dt, X, Y, fn = \"fn_lin\", param = c(m = 10, b = -5)) mo_2 <- modeler(dt, X, Y, fn = \"fn_quad\", param = c(a = 1, b = 10, c = 5)) AIC(mo_1) #> uid logLik df nobs p AIC #> 1 1 -21.45745 3 6 2 48.9149 AIC(mo_2) #> uid logLik df nobs p AIC #> 1 1 -21.00014 4 6 3 50.00028"},{"path":"https://apariciojohan.github.io/flexFitR/reference/logLik.modeler.html","id":null,"dir":"Reference","previous_headings":"","what":"Extract Log-Likelihood for an object of class modeler — logLik.modeler","title":"Extract Log-Likelihood for an object of class modeler — logLik.modeler","text":"logLik object class modeler","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/logLik.modeler.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Extract Log-Likelihood for an object of class modeler — logLik.modeler","text":"","code":"# S3 method for class 'modeler' logLik(object, ...)"},{"path":"https://apariciojohan.github.io/flexFitR/reference/logLik.modeler.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Extract Log-Likelihood for an object of class modeler — logLik.modeler","text":"object object inheriting class modeler resulting executing function modeler() ... parameters. future improvements.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/logLik.modeler.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Extract Log-Likelihood for an object of class modeler — logLik.modeler","text":"tibble columns Log-Likelihood fitted models.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/logLik.modeler.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Extract Log-Likelihood for an object of class modeler — logLik.modeler","text":"Johan Aparicio [aut]","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/logLik.modeler.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Extract Log-Likelihood for an object of class modeler — logLik.modeler","text":"","code":"library(flexFitR) dt <- data.frame(X = 1:6, Y = c(12, 16, 44, 50, 95, 100)) mo_1 <- modeler(dt, X, Y, fn = \"fn_lin\", param = c(m = 10, b = -5)) plot(mo_1) logLik(mo_1) #> uid logLik df nobs p #> 1 1 -21.45745 3 6 2"},{"path":"https://apariciojohan.github.io/flexFitR/reference/metrics.html","id":null,"dir":"Reference","previous_headings":"","what":"Metrics for modeler — metrics","title":"Metrics for modeler — metrics","text":"Computes various performance metrics modeler object. function calculates Sum Squared Errors (SSE), Mean Absolute Error (MAE), Mean Squared Error (MSE), Root Mean Squared Error (RMSE), Coefficient Determination (R-squared).","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/metrics.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Metrics for modeler — metrics","text":"","code":"metrics(x, by_grp = TRUE)"},{"path":"https://apariciojohan.github.io/flexFitR/reference/metrics.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Metrics for modeler — metrics","text":"x object class `modeler` containing necessary data compute metrics. by_grp Return metrics id? TRUE default.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/metrics.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Metrics for modeler — metrics","text":"data frame containing calculated metrics grouped uid, metadata, variables.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/metrics.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Metrics for modeler — metrics","text":"Sum Squared Errors (SSE): $$SSE = \\sum_{=1}^{n} (y_i - \\hat{y}_i)^2$$Mean Absolute Error (MAE): $$MAE = \\frac{1}{n} \\sum_{=1}^{n} |y_i - \\hat{y}_i|$$Mean Squared Error (MSE): $$MSE = \\frac{1}{n} \\sum_{=1}^{n} (y_i - \\hat{y}_i)^2$$Root Mean Squared Error (RMSE): $$RMSE = \\sqrt{\\frac{1}{n} \\sum_{=1}^{n} (y_i - \\hat{y}_i)^2}$$Coefficient Determination (R-squared): $$R^2 = 1 - \\frac{\\sum_{=1}^{n} (y_i - \\hat{y}_i)^2}{\\sum_{=1}^{n} (y_i - \\bar{y})^2}$$","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/metrics.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Metrics for modeler — metrics","text":"","code":"library(flexFitR) data(dt_potato) explorer <- explorer(dt_potato, x = DAP, y = c(Canopy, PH), id = Plot) mod_1 <- dt_potato |> modeler( x = DAP, y = Canopy, grp = Plot, fn = \"fn_piwise\", parameters = c(t1 = 45, t2 = 80, k = 0.9), subset = c(1:2), add_zero = TRUE, max_as_last = TRUE ) plot(mod_1, id = c(1:2)) print(mod_1) #> #> Call: #> Canopy ~ fn_piwise(x, t1, t2, k) #> #> Sum of Squares Error: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> 0.4489 2.0903 3.7317 3.7317 5.3731 7.0145 #> #> Optimization Results `head()`: #> uid t1 t2 k sse #> 1 38.6 61.0 99.8 0.449 #> 2 35.2 60.7 100.0 7.014 #> #> Metrics: #> Groups Timing Convergence Iterations #> 2 1.4931 secs 100% 469 (id) #> metrics(mod_1) #> # A tibble: 2 × 8 #> uid var SSE MAE MSE RMSE r_squared n #> #> 1 1 Canopy 0.449 0.0744 0.0499 0.223 1.00 9 #> 2 2 Canopy 7.01 0.468 0.779 0.883 1.00 9"},{"path":"https://apariciojohan.github.io/flexFitR/reference/modeler.html","id":null,"dir":"Reference","previous_headings":"","what":"Modeler — modeler","title":"Modeler — modeler","text":"General-purpose optimization techniques non-linear least squares problems.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/modeler.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Modeler — modeler","text":"","code":"modeler( data, x, y, grp, keep, fn = \"fn_piwise\", parameters = NULL, lower = -Inf, upper = Inf, initial_vals = NULL, fixed_params = NULL, method = c(\"subplex\", \"pracmanm\", \"anms\"), return_method = FALSE, subset = NULL, add_zero = FALSE, check_negative = FALSE, max_as_last = FALSE, progress = FALSE, parallel = FALSE, workers = max(1, parallel::detectCores(), na.rm = TRUE), control = list() )"},{"path":"https://apariciojohan.github.io/flexFitR/reference/modeler.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Modeler — modeler","text":"data data.frame wide format. x name column `data` contains x points. y name column `data` contain variable analyzed. Must match var data. grp names columns `data` contains grouping variable. (Optional). keep names columns `data` keep across analysis. fn string specifying name function used curve fitting. Default \"fn_piwise\". parameters named numeric vector specifying initial values parameters optimized. Default NULL. lower Numeric vector specifying lower bounds parameters. Default -Inf parameters. upper Numeric vector specifying upper bounds parameters. Default Inf parameters. initial_vals data frame columns uid, initial parameter values group id. Used providing specific initial values per group id. fixed_params data frame columns uid, fixed parameter values group id. Used fixing certain parameters optimization. method character vector specifying optimization methods used. Check `optimx::checkallsolvers()` available methods. Default c(\"subplex\", \"pracmanm\", \"anms\"). return_method Logical. TRUE, includes optimization method used result. Default FALSE. subset optional vector levels `grp` filter data. Default NULL, meaning groups used. add_zero Logical. TRUE, adds zero value series start. Default FALSE. check_negative Logical. TRUE, converts negative values data zero. Default FALSE. max_as_last Logical. TRUE, appends maximum value reaching maximum. Default FALSE. progress Logical. TRUE progress bar displayed. Default FALSE. Try running function: progressr::handlers(\"progress\", \"beepr\"). parallel Logical. TRUE model fit performed parallel. Default FALSE. workers number parallel processes use. `parallel::detectCores()` control list control parameters passed optimization function. example: list(maxit = 500).","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/modeler.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Modeler — modeler","text":"object class modeler, list containing following elements: param data frame containing optimized parameters related information. dt data frame data used fitted values. fn call used fitting models. metrics Metrics summary models. execution Execution time. response Response variable. keep Metadata keep across. fun Name function. parallel List returning parallel workers. fit List fitted models.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/modeler.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Modeler — modeler","text":"","code":"library(flexFitR) data(dt_potato) explorer <- explorer(dt_potato, x = DAP, y = c(Canopy, GLI_2), id = Plot) # Example 1 mod_1 <- dt_potato |> modeler( x = DAP, y = GLI_2, grp = Plot, fn = \"fn_lin_pl_lin\", parameters = c(t1 = 38.7, t2 = 62, t3 = 90, k = 0.32, beta = -0.01), subset = 195, add_zero = TRUE ) plot(mod_1, id = 195) print(mod_1) #> #> Call: #> GLI_2 ~ fn_lin_pl_lin(x, t1, t2, t3, k, beta) #> #> Residuals: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> -0.011076 -0.002262 0.000000 -0.001676 0.000000 0.002262 #> #> Optimization Results `head()`: #> uid t1 t2 t3 k beta sse #> 195 39.6 68.3 93.3 0.323 -0.01 0.000149 #> #> Metrics: #> Groups Timing Convergence Iterations #> 1 1.5053 secs 100% 901 (id) #> # Example 2 mod_2 <- dt_potato |> modeler( x = DAP, y = Canopy, grp = Plot, fn = \"fn_piwise\", parameters = c(t1 = 45, t2 = 80, k = 0.9), subset = 195, add_zero = TRUE, max_as_last = TRUE ) plot(mod_2, id = 195) print(mod_2) #> #> Call: #> Canopy ~ fn_piwise(x, t1, t2, k) #> #> Residuals: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> -1.340e-09 0.000e+00 0.000e+00 -9.481e-11 1.391e-10 1.391e-10 #> #> Optimization Results `head()`: #> uid t1 t2 k sse #> 195 38.7 62 100 1.88e-18 #> #> Metrics: #> Groups Timing Convergence Iterations #> 1 0.8373 secs 100% 349 (id) #>"},{"path":"https://apariciojohan.github.io/flexFitR/reference/plot.explorer.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot an object of class explorer — plot.explorer","title":"Plot an object of class explorer — plot.explorer","text":"Creates various plots object class explorer. Depending specified type, function can generate plots show correlations variables x, correlations x values variable, evolution variables x.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/plot.explorer.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot an object of class explorer — plot.explorer","text":"","code":"# S3 method for class 'explorer' plot( x, type = \"var_by_x\", label_size = 4, signif = FALSE, method = \"pearson\", filter_var = NULL, id = NULL, n_row = NULL, n_col = NULL, base_size = 13, return_gg = FALSE, add_avg = FALSE, ... )"},{"path":"https://apariciojohan.github.io/flexFitR/reference/plot.explorer.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot an object of class explorer — plot.explorer","text":"x object inheriting class explorer, resulting executing function explorer(). type Character string number specifying type plot generate. Available options : \"var_by_x\" 1 Plots correlations variables x (default). \"x_by_var\" 2 Plots correlations x points variable (y). \"evolution\" 3 Plot evolution variables (y) x. \"xy\" 4 Scatterplot (x, y) label_size Numeric. Size labels plot. Default 4. works type 1 2. signif Logical. TRUE, adds p-values correlation plot labels. Default FALSE. works type 1 2. method Character string specifying method correlation calculation. Available options \"pearson\" (default), \"spearman\", \"kendall\". works type 1 2. filter_var Character vector specifying variables exclude plot. id Optional unique identifier filter evolution type plot. Default NULL. works type 3. n_row Integer specifying number rows use facet_wrap(). Default NULL. works type 1 2. n_col Integer specifying number columns use facet_wrap(). Default NULL. works type 1 2. base_size Numeric. Base font size plot. Default 13. return_gg Logical. TRUE, returns ggplot object instead printing . Default FALSE. add_avg Logical. TRUE, returns evolution plot average trend across groups. Default FALSE. ... graphical parameters future improvements.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/plot.explorer.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot an object of class explorer — plot.explorer","text":"ggplot object invisible data.frame containing correlation table type \"var_by_x\" \"x_by_var\".","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/plot.explorer.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot an object of class explorer — plot.explorer","text":"","code":"library(flexFitR) data(dt_potato) dt_potato <- dt_potato results <- explorer(dt_potato, x = DAP, y = c(Canopy, PH), id = Plot) table <- plot(results, label_size = 4, signif = TRUE, n_row = 2) table #> # A tibble: 7 × 7 #> x col row corr p.value n signi #> #> 1 36 Canopy PH 0.46 8.23e-11 176 *** #> 2 42 Canopy PH 0.67 8.55e-27 196 *** #> 3 56 Canopy PH -0.21 3.65e- 3 196 ** #> 4 76 Canopy PH 0.3 1.41e- 5 196 *** #> 5 92 Canopy PH 0.28 5.96e- 5 196 *** #> 6 100 Canopy PH 0.32 6.45e- 6 196 *** #> 7 108 Canopy PH 0.07 3.14e- 1 196 ns plot(results, type = \"x_by_var\", label_size = 4, signif = TRUE)"},{"path":"https://apariciojohan.github.io/flexFitR/reference/plot.modeler.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot an object of class modeler — plot.modeler","title":"Plot an object of class modeler — plot.modeler","text":"Create several plots object class modeler","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/plot.modeler.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot an object of class modeler — plot.modeler","text":"","code":"# 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\", ... )"},{"path":"https://apariciojohan.github.io/flexFitR/reference/plot.modeler.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot an object of class modeler — plot.modeler","text":"x object inheriting class modeler resulting executing function modeler() id avoid many plots one figure. Filter group Id. type Numeric 1, 2, 3. specify type plot. Default 1. Type 4, 5 6 experimental. type = 1 Raw Data + Fitted Curve type = 2 Coefficients + Confindence Intervals type = 3 Fitted Curve + Color Group type = 4 Fitted curve + Confindence Intervals type = 5 First Derivative + Confindence Intervals type = 6 Second Derivative + Confindence Intervals label_size Label size. 3 default. base_size Base font size, given pts. color color geom_line type 1. Default \"red\". parm type equal 2 must vector names parameters. NULL, parameters considered. n_points Number points interpolate along x axis. Default 2000. title Optional string character add title plot. add_ci Add confidence interval type c(4, 5, 6).TRUE FALSE. TRUE default. add_ribbon Add geom_ribbon type c(4, 5, 6).TRUE FALSE. TRUE default. color_ribbon Ribbon color. \"blue\" default. ... graphical parameters. future improvements.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/plot.modeler.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot an object of class modeler — plot.modeler","text":"ggplot object.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/plot.modeler.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Plot an object of class modeler — plot.modeler","text":"Johan Aparicio [aut]","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/plot.modeler.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot an object of class modeler — plot.modeler","text":"","code":"library(flexFitR) data(dt_potato) explorer <- explorer(dt_potato, x = DAP, y = c(Canopy, GLI_2), id = Plot) # Example 1 mod_1 <- dt_potato |> modeler( x = DAP, y = Canopy, grp = Plot, fn = \"fn_piwise\", parameters = c(t1 = 45, t2 = 80, k = 0.9), subset = c(1:3), add_zero = TRUE, max_as_last = TRUE ) print(mod_1) #> #> Call: #> Canopy ~ fn_piwise(x, t1, t2, k) #> #> Sum of Squares Error: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> 0.4489 2.3551 4.2612 3.9082 5.6379 7.0145 #> #> Optimization Results `head()`: #> uid t1 t2 k sse #> 1 38.6 61.0 99.8 0.449 #> 2 35.2 60.7 100.0 7.014 #> 3 33.8 59.9 100.0 4.261 #> #> Metrics: #> Groups Timing Convergence Iterations #> 3 1.8776 secs 100% 499.67 (id) #> plot(mod_1, id = 1:2) plot(mod_1, id = 1:3, type = 2, label_size = 10)"},{"path":"https://apariciojohan.github.io/flexFitR/reference/plot_fn.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot Function — plot_fn","title":"Plot Function — plot_fn","text":"function plots user-defined function specified interval annotates plot calculated Area Curve (AUC) parameter values. aim `plot_fn` allow users play different Starting Values functions fitting models.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/plot_fn.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot Function — plot_fn","text":"","code":"plot_fn( fn = \"fn_piwise\", params = c(t1 = 34.9, t2 = 61.8, k = 100), interval = c(0, 100), n_points = 1000, auc = FALSE, x_auc_label = NULL, y_auc_label = NULL, auc_label_size = 4, param_label_size = 4, base_size = 12, color = \"red\", label_color = \"grey30\" )"},{"path":"https://apariciojohan.github.io/flexFitR/reference/plot_fn.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot Function — plot_fn","text":"fn character string representing name function plotted. Default \"fn_piwise\". params named numeric vector parameters passed function. Default c(t1 = 34.9, t2 = 61.8, k = 100). interval numeric vector length 2 specifying interval function plotted. Default c(0, 100). n_points integer specifying number points used plotting. Default 1000. auc Print AUC plot? Default FALSE. x_auc_label numeric value specifying x-coordinate AUC label. Default NULL. y_auc_label numeric value specifying y-coordinate AUC label. Default NULL. auc_label_size numeric value specifying size AUC label text. Default 3. param_label_size numeric value specifying size parameter label text. Default 3. base_size numeric value specifying base size plot's theme. Default 12. color character string specifying color plot lines area fill. Default \"red\". label_color character string specifying color labels. Default \"grey30\".","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/plot_fn.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot Function — plot_fn","text":"ggplot object representing plot.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/plot_fn.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot Function — plot_fn","text":"","code":"# Example usage plot_fn( fn = \"fn_piwise\", params = c(t1 = 34.9, t2 = 61.8, k = 100), interval = c(0, 100), n_points = 1000 ) plot_fn( fn = \"fn_lin_pl_lin\", params <- c(t1 = 38.7, t2 = 62, t3 = 90, k = 0.32, beta = -0.01), interval = c(0, 100), n_points = 1000, base_size = 12 )"},{"path":"https://apariciojohan.github.io/flexFitR/reference/predict.modeler.html","id":null,"dir":"Reference","previous_headings":"","what":"Predict an object of class modeler — predict.modeler","title":"Predict an object of class modeler — predict.modeler","text":"Model predictions object class modeler","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/predict.modeler.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Predict an object of class modeler — predict.modeler","text":"","code":"# S3 method for class 'modeler' predict( object, x = NULL, id = NULL, type = c(\"point\", \"auc\", \"fd\", \"sd\"), se_interval = c(\"confidence\", \"prediction\"), n_points = 1000, metadata = FALSE, ... )"},{"path":"https://apariciojohan.github.io/flexFitR/reference/predict.modeler.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Predict an object of class modeler — predict.modeler","text":"object object inheriting class modeler resulting executing function modeler() x numeric time point make prediction. Can one. type = \"auc\", x needs size 2, specifies interval calculating AUC. id unique identifier filter . NULL default. type character string specifying type prediction. \"point\" predict value y given x. \"auc\" return area curve (AUC) fitted curve. \"fd\" first order derivative x value returned. \"sd\" second order derivative x value returned. se_interval Type standard error calculation intervals. \"confidence\" \"prediction\". \"confidence\" default. n_points integer specifying number x points use approximating Area Curve (AUC). Default 1000. metadata TRUE FALSE. Whether bring metadata making predictions. ... parameters. future improvements.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/predict.modeler.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Predict an object of class modeler — predict.modeler","text":"data.frame object predicted values standard errors.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/predict.modeler.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Predict an object of class modeler — predict.modeler","text":"Johan Aparicio [aut]","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/predict.modeler.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Predict an object of class modeler — predict.modeler","text":"","code":"library(flexFitR) data(dt_potato) mod_1 <- dt_potato |> modeler( x = DAP, y = Canopy, grp = Plot, fn = \"fn_piwise\", parameters = c(t1 = 45, t2 = 80, k = 0.9), subset = c(15, 2, 45), add_zero = TRUE, max_as_last = TRUE ) print(mod_1) #> #> Call: #> Canopy ~ fn_piwise(x, t1, t2, k) #> #> Sum of Squares Error: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> 0.002601 0.504829 1.007057 2.674719 4.010777 7.014498 #> #> Optimization Results `head()`: #> uid t1 t2 k sse #> 2 35.2 60.7 100.0 7.0145 #> 15 38.5 69.4 99.8 1.0071 #> 45 38.3 64.5 100.0 0.0026 #> #> Metrics: #> Groups Timing Convergence Iterations #> 3 2.1496 secs 100% 414 (id) #> # Point Prediction predict(mod_1, x = 45, type = \"point\", id = 2) #> # A tibble: 1 × 4 #> uid x_new predicted.value std.error #> #> 1 2 45 38.4 0.622 # AUC Prediction predict(mod_1, x = c(0, 108), type = \"auc\", id = 2) #> # A tibble: 1 × 5 #> uid x_min x_max predicted.value std.error #> #> 1 2 0 108 6004. 30.8 # First Derivative predict(mod_1, x = 45, type = \"fd\", id = 2) #> # A tibble: 1 × 4 #> uid x_new predicted.value std.error #> #> 1 2 45 3.91 0.0741 # Second Derivative predict(mod_1, x = 45, type = \"sd\", id = 2) #> # A tibble: 1 × 4 #> uid x_new predicted.value std.error #> #> 1 2 45 -0.0000000298 0.0000274"},{"path":"https://apariciojohan.github.io/flexFitR/reference/print.modeler.html","id":null,"dir":"Reference","previous_headings":"","what":"Print an object of class modeler — print.modeler","title":"Print an object of class modeler — print.modeler","text":"Prints information modeler function.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/print.modeler.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Print an object of class modeler — print.modeler","text":"","code":"# S3 method for class 'modeler' print(x, ...)"},{"path":"https://apariciojohan.github.io/flexFitR/reference/print.modeler.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Print an object of class modeler — print.modeler","text":"x object fitted function modeler(). ... Options used tibble package format output. See `tibble::print()` details.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/print.modeler.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Print an object of class modeler — print.modeler","text":"object inheriting class modeler.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/print.modeler.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Print an object of class modeler — print.modeler","text":"Johan Aparicio [aut]","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/print.modeler.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Print an object of class modeler — print.modeler","text":"","code":"library(flexFitR) data(dt_potato) explorer <- explorer(dt_potato, x = DAP, y = c(Canopy, PH), id = Plot) mod_1 <- dt_potato |> modeler( x = DAP, y = Canopy, grp = Plot, fn = \"fn_piwise\", parameters = c(t1 = 45, t2 = 80, k = 0.9), subset = c(1:5), add_zero = TRUE, max_as_last = TRUE ) plot(mod_1, id = c(1:5)) print(mod_1) #> #> Call: #> Canopy ~ fn_piwise(x, t1, t2, k) #> #> Sum of Squares Error: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> 0.000000 0.000049 0.448900 2.344930 4.261203 7.014498 #> #> Optimization Results `head()`: #> uid t1 t2 k sse #> 1 38.6 61.0 99.8 4.49e-01 #> 2 35.2 60.7 100.0 7.01e+00 #> 3 33.8 59.9 100.0 4.26e+00 #> 4 39.3 65.5 99.8 4.60e-18 #> #> Metrics: #> Groups Timing Convergence Iterations #> 5 3.4596 secs 100% 435.2 (id) #>"},{"path":"https://apariciojohan.github.io/flexFitR/reference/vcov.modeler.html","id":null,"dir":"Reference","previous_headings":"","what":"Variance-Covariance matrix for an object of class modeler — vcov.modeler","title":"Variance-Covariance matrix for an object of class modeler — vcov.modeler","text":"vcov object class modeler","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/vcov.modeler.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Variance-Covariance matrix for an object of class modeler — vcov.modeler","text":"","code":"# S3 method for class 'modeler' vcov(x, id = NULL, ...)"},{"path":"https://apariciojohan.github.io/flexFitR/reference/vcov.modeler.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Variance-Covariance matrix for an object of class modeler — vcov.modeler","text":"x object inheriting class modeler resulting executing function modeler() id unique identifier filter . NULL default. ... parameters. future improvements.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/vcov.modeler.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Variance-Covariance matrix for an object of class modeler — vcov.modeler","text":"list object matrices estimated covariances parameter estimates.","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/vcov.modeler.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Variance-Covariance matrix for an object of class modeler — vcov.modeler","text":"Johan Aparicio [aut]","code":""},{"path":"https://apariciojohan.github.io/flexFitR/reference/vcov.modeler.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Variance-Covariance matrix for an object of class modeler — vcov.modeler","text":"","code":"library(flexFitR) data(dt_potato) mod_1 <- dt_potato |> modeler( x = DAP, y = Canopy, grp = Plot, fn = \"fn_piwise\", parameters = c(t1 = 45, t2 = 80, k = 0.9), subset = c(15, 2, 45), add_zero = TRUE, max_as_last = TRUE ) print(mod_1) #> #> Call: #> Canopy ~ fn_piwise(x, t1, t2, k) #> #> Sum of Squares Error: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> 0.002601 0.504829 1.007057 2.674719 4.010777 7.014498 #> #> Optimization Results `head()`: #> uid t1 t2 k sse #> 2 35.2 60.7 100.0 7.0145 #> 15 38.5 69.4 99.8 1.0071 #> 45 38.3 64.5 100.0 0.0026 #> #> Metrics: #> Groups Timing Convergence Iterations #> 3 1.8317 secs 100% 414 (id) #> vcov(mod_1) #> $`2` #> t1 t2 k #> t1 5.694008e-02 -0.02923676 3.683474e-06 #> t2 -2.923676e-02 0.13796365 7.471629e-02 #> k 3.683474e-06 0.07471629 2.922726e-01 #> #> $`15` #> t1 t2 k #> t1 2.636323e-02 -0.02728600 1.691502e-07 #> t2 -2.728600e-02 0.08035361 1.300394e-02 #> k 1.691502e-07 0.01300394 4.196055e-02 #> #> $`45` #> t1 t2 k #> t1 4.956862e-05 -3.526927e-05 4.195078e-11 #> t2 -3.526927e-05 9.453221e-05 2.835289e-05 #> k 4.195078e-11 2.835289e-05 1.083750e-04 #>"},{"path":"https://apariciojohan.github.io/flexFitR/news/index.html","id":"flexfitr-010","dir":"Changelog","previous_headings":"","what":"flexFitR 0.1.0","title":"flexFitR 0.1.0","text":"Initial CRAN submission.","code":""}] diff --git a/vignettes/plotting.Rmd b/vignettes/plotting.Rmd index 33211c9..dba8e51 100644 --- a/vignettes/plotting.Rmd +++ b/vignettes/plotting.Rmd @@ -52,7 +52,7 @@ mod ## Plotting predictions and derivatives ```{r, fig.width= 8, fig.height=8, fig.alt="plot derivatives"} -a <- plot(mod, color = "blue", title = "Raw - data") +a <- plot(mod, color = "blue", title = "Raw data") b <- plot(mod, type = 4, n_points = 200, color = "black") c <- plot(mod, type = 5, n_points = 200, color = "black") d <- plot(mod, type = 6, n_points = 200, color = "black")