Learn R Programming

onls (version 0.1-1)

plot.onls: Plotting function for 'onls' objects

Description

Plots an orthogonal nonlinear model obtained from onls.

Usage

"plot"(x, fitted.nls = TRUE, fitted.onls = TRUE, segments = TRUE,...)

Arguments

x
an object returned from onls.
fitted.nls
logical. If TRUE, the fit from the normal (vertical) nonlinear model is plotted as a blue line for comparison purposes.
fitted.onls
logical. If TRUE, the fit from the orthogonal nonlinear model is plotted as a red line.
segments
logical. If TRUE, segments connecting $(x_i, y_i)$ and $(x_{0i}, y_{0i})$ are displayed.
...
other parameters to plot.

Value

A plot of the onls model.

Examples

Run this code
## Quadratic model with 10% added noise.
## Omitting the "nls" curve,
## display orthogonal segments.
x <- 1:20
y <- 10 + 3*x^2
y <- sapply(y, function(a) rnorm(1, a, 0.1 * a))
DAT <- data.frame(x, y)
mod <- onls(y ~ a + b * x^2, data = DAT, start = list(a = 1, b = 1))
plot(mod, fitted.nls = FALSE)

## Due to different scaling, 
## orthogonality of fit is not evident.
## We need to have equal x/y-scaling for that:
plot(mod, fitted.nls = FALSE, xlim = c(0, 50),
     ylim = c(0, 50))

Run the code above in your browser using DataLab