Learn R Programming

caroline (version 1.1.2)

plot.confound.grid: Plot a grid of x y plots split by a confounder z

Description

Plot a grid of x y plots showing how a third confounding variable 'z' changes the slope.

Usage

# S3 method for confound.grid
plot(x, f, breaks=4, mains=NA,...)

Value

A confounding diagnostic grid of plots.

Arguments

x

a data frame

f

a formula of the form "Y ~ X | confounder" with names that correspond to names of the dataframe columns.

breaks

number or vector of breaks to split the plots horizontally (across x), automatically set for factors.

mains

a vector plot title strings; defaults to the continuous->categorical break levels of 'confounder'

...

other arguments passed to 'plot'

References

Simpson, E.H. (1951). "The Interpretation of Interaction in Contingency Tables". Journal of the Royal Statiatical Soceity, Series B. 13(2) p. 238-241.

Examples

Run this code

# Swiss Fertility dataset confounding example
plot.confound.grid(x=swiss, f="Infant.Mortality ~ Fertility | Education", breaks=4)

# Intertility dataset confounding example
infert$parity <- as.factor(infert$parity)
plot.confound.grid(x=infert, f="spontaneous ~ age |  parity")

Run the code above in your browser using DataLab