fit_multiple_curves: A function that fits multiple curves with nls.

View source: R/fit_multiple_curves.R

fit_multiple_curvesR Documentation

A function that fits multiple curves with nls.

Description

A function that fits multiple curves with nls.

Usage

fit_multiple_curves(
  x,
  y,
  formula_list = list(as.formula(y ~ a * x + b), as.formula(y ~ a * x^2 + b * x + c)),
  variable_name = "x",
  list_of_start_parameters_lists = list(list(a = 0, b = 10), list(a = 0, b = 0, c =
    12)),
  list_of_static_parameters_lists = list(list(), list()),
  title = "random fit",
  subtitle = "no filename",
  show_try = FALSE,
  save_plot = FALSE,
  save_path = "output_directory_licorfiles/plots/",
  list_of_lower_bounds = list(NULL, NULL),
  list_of_upper_bounds = list(NULL, NULL)
)

Arguments

x

The variable values.

y

The dependent values.

variable_name

A string of the name of the variable, default is x.

title

The title of the plot.

subtitle

The subtitle of the plot. Filename is reccomended. Used for the saved plot name.

save_plot

The boolean to check if the plots have to be saved.

save_path

The path sting to save the plot if save_plot is TRUE.

formula

The formula to use for fitting the data, default is linear.

list_of_start_parameters

The list of starting parameters.

manual_check

The boolean if the plots are manually checked or not.

Value

A list of parameters that are fitted.

Author(s)

Sam Loontjens

Examples

parameters <- fit_any_curve(x = 1:10,
                            y = 1:10 +5 + rnorm(10),
                            formula = as.formula(banaan ~ k * x + p),
                            list_of_start_parameters = list(k = 2, p = 3))
or
x <- 1:10
y <- 0.5 * x^2 + rnorm(10) + 10
parameters <- fit_any_curve(x = x,
                            y = y,
                            formula = as.formula(stuff ~ a1 * t^2 + b1),
                            variable_name = "t",
                            list_of_start_parameters = list(a1 = 2, b1 = 3),
                            title = "quadratic fit",
                            subtitle = "from no file",
                            save_plot = TRUE)


SamLoontjens/HandlingLicorFiles documentation built on Nov. 14, 2023, 6:32 a.m.