ggLogit.plot: Plot for Goodness of Fit of Logistic Regression Model with...

Description Usage Arguments Value Author(s) References See Also Examples

Description

Plots observed proportions against mean predicted probabilities from a logistic regression model. For a good fit, points should be approximately on a straight line.

Usage

1
2
3
4
5
ggLogit.plot(x, data, ...)
## Default S3 method:
ggLogit.plot(x, newdata = NULL, method = "cut",
	where = seq(0, 1, by = 0.1), scalesize = NA, r2 = FALSE,
	dot.shape = 19, dot.size = 3, col = "black", add.se = FALSE)

Arguments

x

one of two possibilities: 1) a model object of class glmerMod or glm (from package lme4), lrm (from package rms), averaging (from package MuMIn), or MCMCglmm (from package MCMCglmm); 2) a list of length 2 whose first element is a vector of predicted probabilities and whose second element is a character string specifying the corresponding response column in data.

newdata

a dataframe containing a vector of observations for which to evaluate predictions.

method

Either "cut", in which case the vector of cut-off points supplied by the "where" argument will be used to partition the fitted probabilities, or "shingle", in which a shingle (using equal.count and its defaults) will be used.

where

A vector of cut-off points for partitioning the vector of fitted probabilities, by default seq(0, 1, by = 0.1)

scalesize

A positive real <= 1. If not NA (the default), the circles representing data points in the graph are scaled to reflect the number of data points in the underlying data set. The scalesize parameter specifies how large the largest circle will be compared to 1 inch. For counts with large outliers, small values of scalesize are better. See example below.

r2

logical. Should the R-squared correlation between predictions and observations be added to the printout?

dot.shape

numeric. Shape of the plotted points (default is solid circles).

dot.size

numeric. Size of plotted points.

col

character. Color of plotted points.

add.se

logical. Should error bars for the standard errors of the mean probabilities be plotted?

Value

A ggplot2 object to which other layers can be added. Note the optional R-squared value above the plot represents the correlation between the X and Y values in the plot. It does NOT represent the R-squared of the model itself.

Author(s)

Jason Grafmiller

References

Baayen, R.H. (2008). Analyzing Linguistic Data. Cambridge: Cambridge University Press.

See Also

This borrows heavily from plotlogistic.fit.fnc in the languageR package. For more plotting options, see geom_point and geom_abline.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
## Not run:
data(brown_genitives)

require(lme4)
require(rms)
require(lmerTest)
require(ggplot2)

genitive.lrm = lrm(Type ~ PossrAnimacyBin +
   PossrWordC + Genre, data = brown_genitives)

genitive.glm = glm(Type ~ PossrAnimacyBin +
   PossrWordC + Genre, data = brown_genitives, family = binomial)

genitive.glmm = glmer(Type ~ PossrAnimacyBin +
   PossrWordC + Genre + (1|Text), data = brown_genitives,
   family = binomial, control = glmerControl(optimizer = "bobyqa"))

ggLogit.plot(genitive.lrm, brown_genitives)
ggLogit.plot(genitive.glm, brown_genitives, col = "red") + theme_bw()
ggLogit.plot(genitive.glmm, brown_genitives, dot.shape = 2, r2 = T)

## End(Not run)

jasongraf1/JGmermod documentation built on May 24, 2019, 9:54 p.m.