multiFit: Fit multiple models to one dataset.

Description Usage Arguments Details Value See Also Examples

Description

Apply a fitting function, with multiple models and multiple starting estimates, to one dataset.

Usage

1
multiFit(models, data, fun = nls, ...)

Arguments

models

[list] A list of models to fit data to. Each element must be a list with at least two named fields: formula which contains the formula, and start which is a list of lists of starting estimates.

data

[numeric data.frame/list] A list of vectors to fit models to.

fun

[function] The function to use for fitting. Defaults to nls.

...

Additional arguments passed to fun.

Details

Finding the right model and the right starting estimates for a model is often a time consuming process, very inconvenient to do manually. This function automates it as much as possible. It takes a list of models and starting estimates, and fits them to data not stopping whenever an error occurs or a warning is issued. Error and warning messages are saved and can be inspected in the output, they just do not halt the process. multiFit has an extension in the form of fitTable which applies multiple models to multiple datasets.

Value

[list.multiFit] A list of results returned by fun or, if it ended with an error, NULL.

See Also

fitTable, summary.list.multiFit

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
set.seed (27)
dataset <- data.frame (X=1:10, Y=(1:10)^2+runif(10,-10,10))
models <- list (
"model A" = list (
	formula = "Y ~ X^a",
	start = list (list(a=100), list(a=1))),
"model B" = list (
	formula = "Y ~ a*(X+b)",
	start = list (list(a=1,b=1)))
)
multiFit (models, dataset)

Example output

To start the graphic interface, run "soundcorrsGUI()"
(requires packages "shiny" and "shinyjqui").

$`model A`
Nonlinear regression model
  model: Y ~ X^a
   data: dat
    a 
1.953 
 residual sum-of-squares: 291.1

Number of iterations to convergence: 5 
Achieved convergence tolerance: 2.887e-06

$`model B`
Nonlinear regression model
  model: Y ~ a * (X + b)
   data: dat
     a      b 
 9.595 -1.845 
 residual sum-of-squares: 998.8

Number of iterations to convergence: 5 
Achieved convergence tolerance: 1.206e-08

attr(,"class")
[1] "list.multiFit"
attr(,"depth")
[1] 1

soundcorrs documentation built on Nov. 16, 2020, 5:09 p.m.