Learn R Programming

DAMisc (version 1.3)

aveEffPlot: Average Effect Plot for Generalized Linear Models

Description

For objects of class glm, it calculates the change the average predicted probability for a hypothetical candidate set of values of a covariate.

Usage

aveEffPlot(obj, varname, data, R=1500, nvals=25, plot=TRUE,...)

Arguments

obj
A model object of class glm.
varname
Character string giving the variable name for which average effects are to be calculated.
data
Data frame used to fit object.
R
Number of simulations to perform.
nvals
Number of evaluation points at which the average probability will be calculated.
plot
Logical indicating whether plot should be returned, or just data (if FALSE).
...
Other arguments to be passed down to xyplot.

Value

  • A plot or a data frame

Details

The function plots the average effect of a model covariate, for objects of class glm. The function does not work with poly unless the coefficients are provided as arguments to the command in the model (see example below).

Examples

Run this code
data(france)
p <- poly(france$lrself, 2)
left.mod <- glm(voteleft ~ male + age + retnat + 
	poly(lrself, 2, coefs=attr(p, "coefs")), data=france, family=binomial)
aveEffPlot(left.mod, "age", data=france, plot=FALSE)

Run the code above in your browser using DataLab