partialResp: Partial response plot(s) for probability or favourability

View source: R/partialResp.R

partialRespR Documentation

Partial response plot(s) for probability or favourability

Description

This function produces partial response plot(s) for probability or favourability, for one to all variables in a 'glm' model object.

Usage

partialResp(model, vars = NULL, Fav = FALSE, se.mult = 1.96, plot.points = FALSE,
ylim = c(0, 1), reset.par = TRUE, ...)

Arguments

model

a model object of class 'glm' and family 'binomial'.

vars

character vector of the name(s) of the variable(s) for which to compute the partial response plot. The default is NULL, for all variables in 'model'.

Fav

logical value indicating whether to compute the response curve(s) for Favourability instead of predicted probability. Default FALSE.

se.mult

numeric value indicating the multiplier for the standard error of the predictions. The default is 1.96, for the 95% confidence interval. If set to 0, no confidence intervals are plotted.

plot.points

logical value indicating whether to plot the points of predicted probability (or favourability, if Fav=TRUE) against the values of the plotted variable. Default FALSE.

ylim

either a numeric vector of length 2 indicating the minimum and maximum value for the y-axis, or character value "auto" for fitting the axis limits to the existing values in each plot. The default is c(0, 1), for all curves to be directly comparable.

reset.par

logical. If TRUE (the default), plotting parameters are changed by the function and reset in the end. FALSE can be useful if the user wants to set their own parameters (like 'mfrow' or 'mar') and combine this with other plots.

...

some additional arguments that can be passed to plot, e.g. 'main', 'cex.axis' or 'cex.lab'.

Details

Each variable is plotted at intervals of 1/100th of its range. Confidence intervals are computed as the value plus/minus the standard error multiplied by 'se.mult' (default 1.96, for the 95% confidence interval). To avoid the confidence intervals exceeding the 0:1 interval that's possible for probability, the standard error is computed on the predictions at the scale of the predictors (i.e., computed with type="link"), and then back-transformed with model$family$linkinv (see https://fromthebottomoftheheap.net/2018/12/10/confidence-intervals-for-glms – thanks to Gavin Simpson for this post!).

Value

A partial response plot for each variable.

Author(s)

A. Marcia Barbosa

See Also

plotmo::plotmo, predicts::partialResponse

Examples

data(rotif.env)

form <- reformulate(names(rotif.env)[5:17], "Kcochl")

mod <- glm(form, data = rotif.env, family = binomial)

partialResp(mod)

partialResp(mod, Fav = TRUE)

partialResp(mod, Fav = TRUE, plot.points = TRUE)

fuzzySim documentation built on March 22, 2025, 3 a.m.