Learn R Programming

mosaic (version 0.4-1)

nlsModel: Fit a nonlinear least squares model

Description

Allows you to specify a formula with parameters, along with starting guesses for the parameters. Refines those guesses to find the least-squares fit.

Usage

nlsModel(formula, data, ..., options)

Arguments

formula
formula specifying the model
data
dataframe containing the data to be used
...
named initial values for parameters
options
not yet used

Value

  • a function

Details

Fits a nonlinear least squares model to data. In contrast to linear models, all the parameters (including linear ones) need to be named in the formula. The function returned simply contains the formula together with pre-assigned arguments setting the parameter value. Variables used in the fitting (as opposed to parameters) are unassigned arguments to the returned function.

See Also

linearModel, nls

Examples

Run this code
stan <- fetchData("stan-data.csv")
f <- nlsModel(temp ~ A+B*exp(-k*time), data=stan,A=50,B=50,k=1/20)
f(time=50)

Run the code above in your browser using DataLab