Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

emplogitplot1

Empirical logit plot for one quantitative variable


Description

This function produces an empirical logit plot for a binary response variable and a single quantitative predictor variable.

Usage

emplogitplot1(formula, data = NULL, ngroups = 3, breaks = NULL,
  yes = NULL, padj = TRUE, out = FALSE, showplot = TRUE,
  showline = TRUE, ylab = "Log(Odds)", xlab = NULL,
  dotcol = "black", linecol = "blue", pch = 16, main = "",
  ylim = NULL, xlim = NULL, lty = 1, lwd = 1, cex = 1)

Arguments

formula

A formula of the form (binary) Response~Predictor

data

A dataframe

ngroups

Number of groups to use (not needed if breaks is used), ngroups="all" uses all unique values

breaks

A vector of endpoints for the bins (not needed if ngroups is used)

yes

Set a value for the response to be counted for proportions (optional)

padj

Should proportions be adjusted to avoid zero and one? (default is TRUE)

out

Should the function return a dataframe with group information? (default is FALSE)

showplot

Show the plot? default is TRUE

showline

Show the regression line? default is TRUE

ylab

Text label for the vertical axis (default is "Log(Odds)")

xlab

Text label for the horizontal axis (default is NULL)

dotcol

Color for the dots (default is "black")

linecol

Color for the line (default is "black")

pch

Plot character for the dots (default is 16)

main

Title for plot

ylim

Limits for the vertical axis

xlim

Limits for the horizontal axis

lty

Line type (default is 1)

lwd

Line width (default is 1)

cex

Multiplier for plot symbols

Details

Values of the quantitative explanatory variable will be grouped into ngroups roughly equal sized groups, unless breaks is used to determine the boundaries of the groups. Using ngroups="all" will make each distinct value of the explanatory variable its own group

We find an adjusted proportion for the binary response variable within each of the groups with (Number yes +0.5)/(Number of cases+1). This is converted to an adjusted log odds log(adjp/(1-adjp)). The adjustment avoids problems if there are no "successes" or all "successes" in a group. What constitutes a "success" can be specified with yes= and the proportion adjustment can be turned off (if no group proportions are likely to be zero or one) with padj=FALSE.

The function plots the log odds versus the mean of the explanatory variable within each group. A least square line is fit to these points. The plot can be suppressed with showplot=FALSE.

The out=TRUE option will return a dataframe with the boundaries of each group, proportion, adjusted proportion, mean explanatory variable, and (adjusted or unadjusted) log odds.

Value

A dataframe with group information (if out=TRUE)

Examples

data(MedGPA)
emplogitplot1(Acceptance~GPA,data=MedGPA)

GroupTable=emplogitplot1(Acceptance~MCAT,ngroups=5,out=TRUE,data=MedGPA)

emplogitplot1(Acceptance~MCAT,data=MedGPA,breaks=c(0,34.5,39.5,50.5),dotcol="red",linecol="black")

data(Putts1)
emplogitplot1(Made~Length,data=Putts1,ngroups="all")

Stat2Data

Datasets for Stat2

v2.0.0
GPL-3
Authors
Ann Cannon, George Cobb, Bradley Hartlaub, Julie Legler, Robin Lock, Thomas Moore, Allan Rossman, Jeffrey Witmer
Initial release
2018-12-29

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.