Basic plot to look at the dependence of a binary variable from a metric one. Scatterplot BINARY verus METRIC. BINARY is jittered to avoid overplotting. Blue line is logistic regression curve. Grey line is lowess smoother. Legend details Nvalid, Baserate and Wald pValue of METRIC in logistic regession.

PlotBinaryByMetric(BINARY, METRIC, BNAME = NULL, MNAME = NULL,
  MAIN = "", SCALE = "ID", XLIM = NULL, NPRETTY = 6, SPAN = 0.75,
  LOWESSCOL = 8, ...)

Arguments

BINARY

is a variable of any type with only two values

METRIC

is a metric variable

BNAME

= NULL is an optional label for BINARY

MNAME

= NULL is an optional label for M

MAIN

= "" is an optional title

SCALE

="ID" chooses a ScaleTransformation ID, POWER_Z, LOG10, LOGIT for X: use optional parameter Z to specify the power to use with POWER_Z. use optional parameter PERCENT = T for percent instead of proportions on LOGIT scale.

XLIM

= NULL sets the x-axis range to be plotted manually - generally not necessary

NPRETTY

= 6 influences approximate number of labels when using ID or POWER_Z (cf. base pretty)

SPAN

= 0.75 is the smoothing parameter for lowess

LOWESSCOL

= 8 Colour of Lowess-Smoother. Set to 0 to eliminate the curve

Value

Generates a plot and returns the summary of the logistic regression.

Examples

METRIC<-rnorm(200); BINARY<-(METRIC+rnorm(200))>0; PlotBinaryByMetric(BINARY,METRIC)
#> [1] "Ntotal = 200 Nvalid = 200"
#> #> Call: #> stats::glm(formula = BINARY ~ Metric, family = "binomial") #> #> Deviance Residuals: #> Min 1Q Median 3Q Max #> -2.2583 -0.8084 0.1805 0.8714 2.1444 #> #> Coefficients: #> Estimate Std. Error z value Pr(>|z|) #> (Intercept) 0.03087 0.17233 0.179 0.858 #> Metric 1.61949 0.24049 6.734 1.65e-11 *** #> --- #> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 #> #> (Dispersion parameter for binomial family taken to be 1) #> #> Null deviance: 277.18 on 199 degrees of freedom #> Residual deviance: 202.81 on 198 degrees of freedom #> AIC: 206.81 #> #> Number of Fisher Scoring iterations: 4 #>