nlstools: Nonlinear least squares fit

nlstoolsR Documentation

Nonlinear least squares fit

Description

Tools to help the fit of nonlinear models with nls

Usage

  preview (formula, data, start, variable = 1)
  plotfit (x, smooth = FALSE, variable = 1, xlab = NULL, ylab = NULL, 
           pch.obs = 1, pch.fit = "+", lty = 1, lwd = 1, col.obs = "black", 
           col.fit = "red", ...)
  overview (x)

Arguments

formula

formula of a non-linear model

data

a data frame with header matching the variables given in the formula

start

a list of parameter starting values which names match the parameters given in the formula

variable

index of the variable to be plotted against the predicted values; default is the first independent variable as it appears in the orginal dataset

x

an object of class 'nls'

smooth

a logical value, default is FALSE. If smooth is TRUE, a plot of observed values is plotted as a function of 1000 values continuously taken in the range interval [min(variable),max(variable)]. This option can only be used if the number of controlled variables is 1.

xlab

X-label

ylab

Y-label

pch.obs

type of point of the observed values

pch.fit

type of point of the fitted values (not applicable if smooth=TRUE)

lty

type of line of the smoothed fitted values (if smooth=TRUE)

lwd

thickness of line of the smoothed fitted values (if smooth=TRUE)

col.obs

color of the observed points

col.fit

color of the fitted values

...

further arguments passed to or from other methods

Details

The function preview helps defining the parameter starting values prior fitting the model. It provides a superimposed plot of observed (circles) and predicted (crosses) values of the dependent variable versus one of the independent variables with the model evaluated at the starting values of the parameters. The function overview returns the parameters estimates, their standard errors as well as their asymptotic confidence intervals and the correlation matrix (alternately, the function confint provides better confidence interval estimates whenever it converges). plotfit displays a superimposed plot of the dependent variable versus one the independent variables together with the fitted model.

Author(s)

Florent Baty, Marie-Laure Delignette-Muller

References

Baty F, Ritz C, Charles S, Brutsche M, Flandrois J-P, Delignette-Muller M-L (2015). A Toolbox for Nonlinear Regression in R: The Package nlstools. Journal of Statistical Software, 66(5), 1-21.

Bates DM and Watts DG (1988) Nonlinear regression analysis and its applications. Wiley, Chichester, UK.

See Also

nls in the stats library and confint.nls in the package MASS

Examples

formulaExp <- as.formula(VO2 ~ (t <= 5.883) * VO2rest + (t > 5.883) * 
                        (VO2rest + (VO2peak - VO2rest) * 
                        (1 - exp(-(t - 5.883) / mu))))
preview(formulaExp, O2K, list(VO2rest = 400, VO2peak = 1600, mu = 1))
O2K.nls1 <- nls(formulaExp, start = list(VO2rest = 400, VO2peak = 1600, 
                mu = 1), data = O2K)
overview(O2K.nls1)
plotfit(O2K.nls1, smooth = TRUE)

nlstools documentation built on Aug. 24, 2023, 5:10 p.m.