intplot: Interaction Plots with Error Bars

intplotR Documentation

Interaction Plots with Error Bars

Description

This function allows you to generate interaction plots for a Two-Way ANOVA with error bars.

Usage

intplot(
  formula = NULL,
  data = NULL,
  type = "b",
  x.cont = FALSE,
  legend = TRUE,
  trace.label = NULL,
  leg.lab = NULL,
  fixed = FALSE,
  x.leg = NULL,
  y.leg = NULL,
  cex.leg = 1,
  ncol = 1,
  pch = c(16, 21, 15, 22, 17, 24, c(3:14)),
  fun = function(x) mean(x, na.rm = TRUE),
  ci.fun = function(x) c(fun(x) - se(x), fun(x) + se(x)),
  err.width = if (length(levels(as.factor(x.factor))) > 10) 0 else 0.1,
  err.col = col,
  err.lty = 1,
  xlim = NULL,
  ylim = NULL,
  cex = NULL,
  lwd = NULL,
  col = 1:10,
  cex.axis = 1,
  xaxt = "s",
  main = NULL,
  cld = F,
  cldshift = 0.1,
  cldcol = "white",
  hor.shift = 0.02,
  ...
)

Arguments

formula

an object of class "formula" (or one that can be coerced to that class); a symbolic description of the model to be plotted. The details of the model specification are given under "Details".

data

a required data frame containing the variables for the plot.

type

character. One of "p" or "b". Defaults to "b" for base version that adds lines between points. Choose "p" to not have lines (just points with error bars).

x.cont

boolean. Defaults to FALSE as current interaction plots are not for continuous predictors but included for future development.

legend

boolean. Defaults to TRUE. Adds legend to plot, removal causes other changes.

trace.label

text. Adds a text label to the legend

leg.lab

text. Changes the names of levels used in legend, must match the number of levels.

fixed

boolean. Defaults to FALSE and relates to order of labels in legend.

x.leg

Defaults to NULL. Determines x-location of legend on plot.

y.leg

Defaults to NULL. Determines x-location of legend on plot.

cex.leg

Defaults to 1. Size of text in legend.

ncol

Defaults to 1. Number of columns for the legend. 1 is usually best.

pch

Symbols for means in plot. Match number of levels as used in first variable in formula.

fun

Function for finding the point estimates, defaults to finding the mean. Change not recommended.

ci.fun

Function for finding the width of error bars, with default of plus/minus 1 SE. See function for details to change this.

err.width

Defaults to 0.1 if less than 10 levels and 0 otherwise. Can specify wider or smaller than 0.1.

err.col

Defaults to matching order of levels and other aspects of plot but can make contrasting error bars with other choices.

err.lty

Defaults to 1. Line type for the error bars. Best to leave solid but can be changed.

xlim

Defaults to NULL. Can make other choices to modify default choice that tries to make room for standard versions of interaction plots.

ylim

Defaults to NULL. Can make other choices to modify default choice that tries to make room for standard versions of interaction plots.

cex

Defaults to 1. Size of points for means in plot.

lwd

Deafults to 1. Line width for lines in plot.

col

Defaults to 1:10 for the colors used in the plot.

cex.axis

Defaults to 1. Size of text for tick marks on x and y axis.

xaxt

Defaults to "s". Change to "n" to remove x-axis tick marks.

main

Title for plot.

cld

boolean. Defaults to FALSE. If true, adds compact letter display from Tukey's HSD that is run.

cldshift

Defaults to 0.1. Amount to shift letters added to plot.

cldcol

Colors for letters for CLD.

...

optional arguments to be passed to plot.

Details

Function for making nice looking interaction plots with 1 SE-based intervals. Add Tukey's HSD results via Compact Letter Displays.

Examples

# must have the carData package installed
data(TitanicSurvival, package = "carData")
intplot(age ~ sex * survived, data = TitanicSurvival)

greenwood-stat/catstats documentation built on Dec. 14, 2024, 6:25 p.m.