Learn R Programming

soundcorrs (version 0.1.1)

multiFit: Fit multiple models to one dataset.

Description

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

Usage

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.

Value

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

Examples

Run this code
# NOT RUN {
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)
# }

Run the code above in your browser using DataLab