Skip to content

Commit

Permalink
docs updating documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
AparicioJohan committed Dec 17, 2024
1 parent c095491 commit e72e0e5
Show file tree
Hide file tree
Showing 95 changed files with 10,870 additions and 260 deletions.
68 changes: 39 additions & 29 deletions R/02_modeler.R
Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@
#' Modeler
#' Modeler: Non-linear Regression for Curve Fitting
#'
#' @description
#' General-purpose optimization techniques for non-linear least squares problems.
#'
#' @param data A data.frame in a wide format.
#' @param x The name of the column in `data` that contains x points.
#' @param y The name of the column in `data` that contain the variable to be analyzed. Must match a var in the data.
#' @param grp The names of the columns in `data` that contains a grouping variable. (Optional).
#' @param keep The names of the columns in `data` to keep across the analysis.
#' @param fn A string specifying the name of the function to be used for the curve fitting. Default is \code{"fn_linear_sat"}.
#' @param parameters Can be a named numeric vector specifying the initial values for the parameters to be optimized,
#' If a data frame it needs to have a column \code{uid}, and the initial parameter values for each group id.
#' If list it needs to be a named list with the initial parameters and numeric or string values can be used (e.g. list(k = "max(y)", t1 = 40)).
#' Used for providing specific initial values per group id. Default is \code{NULL}.
#' @param lower Numeric vector specifying the lower bounds for the parameters. Default is \code{-Inf} for all parameters.
#' @param upper Numeric vector specifying the upper bounds for the parameters. Default is \code{Inf} for all parameters.
#' @param fixed_params Can be a list or data frame. If data frame it needs columns \code{uid}, and the fixed parameter values for each group id.
#' If list it needs to be a named list with the parameters to be fixed and numeric or string values can be used (e.g. list(k = "max(y)", t1 = 40)).
#' @param method A character vector specifying the optimization methods to be used. Check `optimx::checkallsolvers()` for available methods.
#' Default is \code{c("subplex", "pracmanm", "anms")}.
#' @param subset An optional vector with levels of `grp` to filter the data. Default is \code{NULL}, meaning all groups are used.
#' A versatile function for performing non-linear least squares optimization on grouped data.
#' It supports customizable optimization methods, flexible initial/fixed parameters, and parallel processing.
#' @param data A `data.frame` containing the input data for analysis.
#' @param x The name of the column in `data` representing the independent variable (x points).
#' @param y The name of the column in `data` containing the dependent variable to analyze (response variable).
#' @param grp Column(s) in `data` used as grouping variable(s). Defaults to `NULL`. (optional)
#' @param keep Names of columns to retain in the output. Defaults to `NULL`. (Optional)
#' @param fn A string. The name of the function used for curve fitting.
#' Example: `"fn_linear_sat"`. Defaults to \code{"fn_linear_sat"}.
#' @param parameters A numeric vector, named list, or `data.frame` providing initial values for parameters:
#' \describe{
#' \item{Numeric vector}{Named vector specifying initial values (e.g., `c(k = 0.5, t1 = 30)`).}
#' \item{Data frame}{Requires a `uid` column with group IDs and parameter values for each group.}
#' \item{List}{Named list where parameter values can be numeric or expressions (e.g., `list(k = "max(y)", t1 = 40)`).}
#' }
#' Defaults to `NULL`.
#' @param lower A numeric vector specifying lower bounds for parameters. Defaults to `-Inf` for all parameters.
#' @param upper A numeric vector specifying upper bounds for parameters. Defaults to `Inf` for all parameters.
#' @param fixed_params A list or `data.frame` for fixing specific parameters:
#' \describe{
#' \item{List}{Named list where parameter values can be numeric or expressions (e.g., `list(k = "max(y)", t1 = 40)`).}
#' \item{Data frame}{Requires a `uid` column for group IDs and fixed parameter values.}
#' }
#' Defaults to `NULL`.
#' @param method A character vector specifying optimization methods.
#' Check available methods using \code{list_methods()} and their dependencies using
#' \code{optimx::checkallsolvers()}. Defaults to \code{c("subplex", "pracmanm", "anms")}.
#' @param subset A vector (optional) containing levels of `grp` to filter the data for analysis.
#' Defaults to `NULL` (all groups are included).
#' @param options A list of additional options. See `modeler.options()`
#' \describe{
#' \item{\code{add_zero}}{Logical. If \code{TRUE}, adds a zero value to the series at the start. Default is \code{FALSE}.}
Expand All @@ -34,16 +44,16 @@
#' @param control A list of control parameters to be passed to the optimization function. For example: \code{list(maxit = 500)}.
#' @return An object of class \code{modeler}, which is a list containing the following elements:
#' \describe{
#' \item{\code{param}}{A data frame containing the optimized parameters and related information.}
#' \item{\code{dt}}{A data frame with data used and fitted values.}
#' \item{\code{fn}}{The call used when fitting models.}
#' \item{\code{param}}{Data frame containing optimized parameters and related information.}
#' \item{\code{dt}}{Data frame with input data, fitted values, and residuals.}
#' \item{\code{fn}}{The function call used for fitting models.}
#' \item{\code{metrics}}{Metrics and summary of the models.}
#' \item{\code{execution}}{Execution time.}
#' \item{\code{response}}{Response variable.}
#' \item{\code{keep}}{Metadata to keep across.}
#' \item{\code{fun}}{Name of the function.}
#' \item{\code{parallel}}{List returning parallel and workers.}
#' \item{\code{fit}}{List with the fitted models.}
#' \item{\code{execution}}{Total execution time for the analysis.}
#' \item{\code{response}}{Name of the response variable analyzed.}
#' \item{\code{keep}}{Metadata retained based on the `keep` argument.}
#' \item{\code{fun}}{Name of the curve-fitting function used.}
#' \item{\code{parallel}}{List containing parallel execution details (if applicable).}
#' \item{\code{fit}}{List of fitted models for each group.}
#' }
#' @export
#'
Expand Down
3 changes: 3 additions & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ reference:
- goodness_of_fit
- print.modeler
- metrics
- list_methods
- title: Data Exploration
- contents:
- explorer
Expand All @@ -68,9 +69,11 @@ reference:
- fn_lin
- fn_quad
- fn_linear_sat
- fn_logistic
- fn_exp1_lin
- fn_exp2_lin
- fn_exp1_exp
- fn_exp2_exp
- fn_lin_pl_lin
- fn_lin_pl_lin2
- list_funs
6 changes: 3 additions & 3 deletions docs/404.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/CODE_OF_CONDUCT.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/LICENSE-text.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e72e0e5

Please sign in to comment.