Learn R Programming

languageR (version 1.2)

plot.logistic.fit.fnc: Plot for goodness of fit of logistic regression

Description

This function plots observed proportions against mean predicted probabilities. For a good fit, points should be approximately on a straight line.

Usage

plot.logistic.fit.fnc(x, data, method, where, scalesize, ...)

Arguments

x
A logistic regression model fitted with lmer or lrm.
data
The data set to which the model was fitted.
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
...
other parameters to be passed through to plotting functions.

Value

  • A plot is produced on the graphics device. The R-squared value shown above the plot represents the correlation between the X and Y values in the plot. It does NOT represent the R-squared of the lrm or lmer model.

Examples

Run this code
data(dative)
library(lme4, keep.source=FALSE)

dative.lrm = lrm(RealizationOfRecipient ~ AccessOfTheme + 
   AccessOfRec + LengthOfRecipient + AnimacyOfRec +
   AnimacyOfTheme + PronomOfTheme + DefinOfTheme + LengthOfTheme +
   SemanticClass + Modality, data = dative)

dative.glmm = lmer(RealizationOfRecipient ~ AccessOfTheme + 
   AccessOfRec + LengthOfRecipient + AnimacyOfRec +
   AnimacyOfTheme + PronomOfTheme + DefinOfTheme + LengthOfTheme +
   SemanticClass + Modality + (1|Verb), 
   data = dative, family = "binomial")

par(mfrow=c(2,2))
plot.logistic.fit.fnc (dative.lrm, dative)
mtext("lrm", 3, 3)
plot.logistic.fit.fnc (dative.glmm, dative)
mtext("lmer", 3, 3)
plot.logistic.fit.fnc (dative.lrm, dative, scalesize=0.2)
mtext("lrm", 3, 3)
plot.logistic.fit.fnc (dative.glmm, dative, method="shingle")
mtext("lmer", 3, 3)
par(mfrow=c(1,1))

Run the code above in your browser using DataLab