Learn R Programming

LogisticDx (version 0.1)

plotLogiDx: Diagnostic plots for a logistic regression

Description

Common diagnostic plots for a logistic regression model

Usage

plotLogiDx(x, noPerPage = 6,
    cols = c("deepskyblue", "dodgerblue"), cex = 2,
    pch = 21, inches = 0.25, identify = FALSE,
    extras = FALSE, width = NULL, height = NULL)

Arguments

x
A logistic regression model of class glm
noPerPage
Number of plots per page (for initial plots). Will be used as guidance and optimised for ease of display
cols
Colours. As used by graphics::points
cex
Cex Character expansion. See ?graphics::plot.default
pch
Plotting character. See ?graphics::points
inches
Width of circles for bubble plot. See ?graphics::symbols
identify
If TRUE will give option to identify individual points on a number of the plots produced. The number which appears next to the point corresponds to the relevant row as given by logiGOF
extras
If TRUE produces additional plots, detailed below
width
Width of screen(display device) in pixels
height
Height of screen(display device) in pixels

Value

  • The following are plotted, for each covariate group:
  • p_X_levProbability of $y=1$ for this group by leverage (diagonal of hat matrix, a measure of influence)
  • p_X_dXsqProbability as above by dXsq change in Pearson chi-square statistic with deletion of this group
  • p_X_dBhatProbability by dBhat change in Bhat; the difference in the maximum likelihood estimators Beta for model coefficients with all subjects included vs those with this group, standardized by the estimated covariance matrix of Beta
  • p_X_dDevProbability by dDev, the change in deviance when this group is excluded
  • bubbleplotProbability by dXsq, with area of circle proportional to dBhat
  • lev_X_dXsqLeverage by dXsq, the change in the Pearson chi-square statistic when this group is excluded
  • lev_X_dBhatLeverage by dBhat, the difference in the maximum likelihood estimators Beta for model coefficients with all subjects included vs those when this group is excluded. This is standardized by the estimated covariance matrix of Beta
  • lev_X_dDevLeverage by dDev, the change in deviance when this group is excluded
  • ROCReceiver Operator Curve
  • Additional plots are given when extras=TRUE:
  • influenceplotSee ?car::influencePlot
  • sr_X_hatStudentized residual by hat values. Studentized residual = residual / estimate of standard deviation of residual
  • slpSpread-level plot. See from ?car::spreadLevelPlot
  • qqPlotquantile-quantile plot vs Normal for residuals. See ?stats::qqplot
  • iipInfluence-index plot. Gives Cooks distance, studentized residual and hat values for each observation
  • pairsPairs plot for the measures of influence dBhat, dXsq and dDev. See ?graphics::pairs
  • crPlotsComponent + residual plots. See ?car::crPlots
  • avPlotsAdded-variable plots. See ?car::avPlots
  • mmpsMarginal model plots. These require that the data.frame used to fit the model be present in the current environment. See ?car::mmps

Examples

Run this code
set.seed(1)
### generate up to 8x covariate patterns
mod1 <- genLogiDf(b=3, f=0, c=0, n=50)$model
plotLogiDx(mod1, cex=8, noPerPage=1)
plotLogiDx(mod1, cex=3, noPerPage=6, extras=TRUE)
df1 <- genLogiDf(b=0,f=0,c=2,n=50, model=FALSE)
g1 <- glm(y ~ ., family=binomial("logit"), data=df1)
plotLogiDx(g1)

Run the code above in your browser using DataLab