The methods autoplot()
or chart()
for nls objects. If
type = model
(by default for chart()
), a scatterplot with the model
superimposed is produced,. The other types allow to analyze the residuals of
the model.
# S3 method for class 'nls'
chart(
data,
type = "model",
...,
title,
labels = "AUTO",
name = deparse(substitute(data)),
lang = getOption("SciViews_lang", "en"),
env = parent.frame()
)
autoplot.nls(
object,
type = c("model", "resfitted", "qqplot", "scalelocation", "reshist", "resautocor"),
title,
xlab,
ylab,
...,
name = deparse(substitute(object)),
lang = getOption("SciViews_lang", "en"),
env = parent.frame()
)
A nls model.
The type of plot: "model"
, "resfitted"
, "qqplot"
,
"scalelocation"
, "reshist"
or "resautocor"
. For chart()
, can also
be provided as chart$type(....)
. chart()
also uses "residuals"
that
constructs a combined figure with resfitted, qqplot, scalelocation and
resautocor.
Additional arguments passed to the chart.
A title for the plot. If not provided, a default title is computed.
A vector of four character strings, one for each plot done with
chart$residuals()
.
The name of the model. If not provided, it is the name of the model object by default.
The language to use for titles and labels, currently only "en"
or "fr"
.
The environment to evaluate code. It is parent.frame()
by
default, and there is no reasons to change it, unless you really know what
you are doing!
Idem
A label for the X axis. A default label is proposed if it is not provided.
A label for the Y axis (with default if not provided).
The ggplot object produced.
data("ChickWeight", package = "datasets")
chick1 <- ChickWeight[ChickWeight$Chick == 1, ]
# Adjust a logistic curve
chick1_logis <- nls(weight ~ SSlogis(Time, Asym, xmid, scal), data = chick1)
library(chart)
chart(chick1_logis)
# Residuals analysis
chart$resfitted(chick1_logis)
chart$qqplot(chick1_logis)
chart$scalelocation(chick1_logis)
chart$reshist(chick1_logis, bins = 15)
chart$resautocor(chick1_logis)
# The four most important residual analysis plots in one figure
chart$residuals(chick1_logis)