Learn R Programming

datana (version 1.1.5)

obspredplot: Observed versus predicted values plot.

Description

Creates a scatterplot between the observed values and the predicted ones from a fitted model.

Usage

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,
  ...
)

Value

The function returns the above described graph.

Arguments

y.obs

observed values of the variable of interest

y.pred

predicted values of the variable of interest

col

A string specifying the color of the data points. The default is "black".

linecol

A string specifying the straight line color. The default is set to "red".

eng

logical; if TRUE (by default), the language of the statistics will be in English; if "FALSE" will be in Spanish.

xlab

(optional) A string specifying X-axis label.

ylab

(optional) A string specifying Y-axis label.

xlim

(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.

ylim

(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.

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).

Author

Christian Salas-Eljatib

Details

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.

References

  • 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")

Examples

Run this code
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