Description Usage Arguments Value Examples
Convenient function for adding curves to an existing plot, or to plot the data with the fitted curve.
For non-linear regression plotting (plot_nls
), works for simple non-linear regression models fit with nls
, and grouped non-linear regression (with nlsList
), in which case one fitted curve for each group is drawn on the same plot.
For local regression models fitted with loess
, use the plot_loess
function which additionally adds a confidence interval around the fitted curve.
1 2 3 4 5 6 |
object |
The object returned by |
col |
Colour to be used for the data symbols and the fitted line, unless |
band |
For |
plotdata |
Logical. Whether to add the data points to the plot. |
lines.col |
Colour(s) for the fitted lines. When plotting a |
points.col |
Colour(s) for the data symbols. When plotting a |
ci.col |
Colour of the confidence band, if plotted. Defaults to a transparent grey colour. |
lwd |
Thickness of the line (see |
lty |
Line type (see |
add |
Logical. Whether to add to current plot (default FALSE). |
xlab |
Label for x-axis |
ylab |
Label for y-axis |
coverage |
If confidence band to be plotted, the coverage (e.g. for 95% confidence interval, use 0.95) |
... |
Further arguments passed to |
Returns the predicted values used in plotting (invisibly), as a dataframe with columns 'predvar' (regularly spaced predictor values), and 'fit' (fitted values). For plot_loess
also returns confidence intervals, standard error, and df of the residual.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # Plot an nls object
chick <- as.data.frame(ChickWeight)
fit0 <- nls(weight ~ a*Time^b, data=chick, start=list(a=10, b=1.1))
plot_nls(fit0)
# Plot a grouped nls object
library(nlme)
fit1 <- nlsList(weight ~ a*Time^b|Diet, data=chick, start=list(a=10, b=1.1))
plot_nls(fit1)
# Plot a local regression object, with confidence interval
l <- loess(wt ~ disp, data=mtcars)
plot_loess(l)
# To plot behind the data:
with(mtcars, plot(disp, wt, pch=19,
panel.first=plot_loess(l, plotdata=FALSE)))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.