Creates a scatterplot between the observed values and the predicted ones from a fitted model.
obspredplot(
y.obs = y.obs,
y.pred = y.pred,
col = "black",
linecol = "red",
eng = TRUE,
xlab = NULL,
ylab = NULL,
xlim = NULL,
ylim = NULL,
coef.max.val = 1.1,
...
)
The function returns the above described graph.
observed values of the variable of interest
predicted values of the variable of interest
A string specifying the color of the data points. The default is "black".
A string specifying the straight line color. The default is set to "red".
logical; if TRUE
(by default), the language of the
statistics will be in English; if "FALSE" will be in Spanish.
(optional) A string specifying X-axis label.
(optional) A string specifying Y-axis label.
(optional) A range (min,max) for the limits
of the X-axis. By default is set to be 0 and the maximum
value of the both observed and predicted values, multiplied by
the option coef.max.val
.
(optional) A range (min,max) for the limits
of the Y-axis. By default is set to be 0 and the maximum
value of the both observed and predicted values, multiplied by
the option coef.max.val
.
(optional) A number to be used for
multiplying the maximum vale of the variable (either the
observed or the predicted values). By default is set to 1.1
.
other graphical parameters (see par and section 'Details' below).
Christian Salas-Eljatib
Notice that the straight-line is draw using an intercept=0, and a slope=1.
Commonly used graphical parameters are:
col
The colors for lines and points. Multiple colors can be specified so that each point can be given its own color. If there are fewer colors than points they are recycled in the standard fashion. Lines will all be plotted in the first colour specified.
bg
a vector of background colors for open plot symbols, see points. Note: this is not the same setting as par("bg").
pch
a vector of plotting characters or symbols: see points.
cex
a numerical vector giving the amount by which plotting characters and symbols should be scaled relative to the default.
This works as a multiple of par("cex"). NULL and NA are
equivalent to 1.0. Note that this does not
affect annotation: see below.
lty
a vector of line types, see par
.
cex.main
, col.lab
, font.sub
, etc settings for main- and sub-title and axis annotation, see title and par
.
lwd
a vector of line widths, see par
.
Salas-Eljatib C. 2021. Análisis de datos con el programa estadístico R: una introducción aplicada. Ediciones Universidad Mayor. Santiago, Chile. 170 p. https://eljatib.com
Piñeiro G, Perelman S, Guerschman JP, Paruelo JM. 2008. How to evaluate models: Observed vs. predicted or predicted vs. observed? Ecological Modelling 216(3-4):316-322 tools:::Rd_expr_doi("10.1016/j.ecolmodel.2008.05.006")
df <- datana::maple
head(df)
m1<-lm(leaf~dbh,data=df)
# Example 1, a residual plot
obspredplot(y.obs=df$leaf,y.pred=fitted(m1))
Run the code above in your browser using DataLab