Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

plotGLM

Plot a generalized linear model


Description

This function plots the observed (presence/absence) data and the predicted (probability) values of a Generalized Linear Model against the y regression equation (logit) values. Only logistic regression (binomial response, logit link) is currently implemented.

Usage

plotGLM(model = NULL, obs = NULL, pred = NULL, link = "logit", 
plot.values = TRUE, plot.digits = 3, xlab = "Logit (Y)", 
ylab = "Predicted probability", main = "Model plot", ...)

Arguments

model

a model object of class "glm".

obs

a vector of presence/absence or other binary (1-0) observed data. Not necessary (and ignored) if 'model' is provided.

pred

a vector of the values predicted by a GLM of the binary observed data. Not necessary (and ignored) if 'model' is provided.

link

the link function of the GLM; only 'logit' (the default) is implemented.

plot.values

logical, whether to include in the plot diagnostic values such as explained deviance (calculated with the Dsquared function) and pseudo-R-squared measures (calculated with the RsqGLM function). Defaults to TRUE.

plot.digits

integer number indicating the number of digits to which the values in the plot should be rounded (if 'plot.values = TRUE'). Defaults to 3.

xlab

character string specifying the label for the x axis.

ylab

character string specifying the label for the y axis.

main

character string specifying the title for the plot.

...

additional arguments to pass to plot.

Value

This function outputs a plot of model predictions against observations.

Author(s)

A. Marcia Barbosa

References

Guisan A. & Zimmermann N.E. (2000) Predictive habitat distribution models in ecology. Ecological Modelling 135: 147-186

Weisberg S. (1980) Applied Linear Regression. Wiley, New York

See Also

Examples

# load sample models:
data(rotif.mods)

# choose a particular model to play with:
mod <- rotif.mods$models[[1]]

plotGLM(model = mod)

plotGLM(model = mod, plot.values = FALSE)


# you can also use 'plotGLM' with vectors of observed and
# predicted values instead of with a model object:

plotGLM(obs = mod$y, pred = mod$fitted.values)

modEvA

Model Evaluation and Analysis

v2.0
GPL-3
Authors
Barbosa A.M., Brown J.A., Jimenez-Valverde A., Real R.
Initial release
2020-01-21

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.