DAintfun: Surface Plots for Two-Way Interactions

Description Usage Arguments Details Value Author(s) Examples

Description

Makes surface plots to display interactions between two continuous variables

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
DAintfun(
  obj,
  varnames,
  theta = 45,
  phi = 10,
  xlab = NULL,
  ylab = NULL,
  zlab = NULL,
  adjustY = 0,
  plot = TRUE,
  hcols = NULL,
  ...
)

Arguments

obj

A model object of class lm

varnames

A two-element character vector where each element is the name of a variable involved in a two-way interaction.

theta

Angle defining the azimuthal viewing direction to be passed to persp

phi

Angle defining the colatitude viewing direction to be passed to persp

xlab

Optional label to put on the x-axis, otherwise if NULL, it will take the first element of varnames

ylab

Optional label to put on the y-axis, otherwise if NULL, it will take the second element of varnames

zlab

Optional label to put on the z-axis, otherwise if NULL, it will be ‘Predictions’.

adjustY

Scalar indicating a constant that should be added to all of fitted values. Defaults to 0.

plot

Logical indicating whether the plot should be returned. If FALSE, the data are returned instead.

hcols

Vector of four colors to color increasingly high density areas

...

Other arguments to be passed down to the initial call to persp

Details

This function makes a surface plot of an interaction between two continuous covariates. If the model is

y = b[0] + b[1]x1 + b[2]x2 + b[3]x1*x2 + ... + e[i],


this function plots b[1]x1 + b[2]x2 + b[3]x1*x2 for values over the range of X1 and X2. The highest 75%, 50% and 25% of the bivariate density of X1 and X2 (as calculated by sm.density from the sm package) are colored in with colors of increasing gray-scale.

Value

x1

Values of the first element of varnames used to make predictions.

x2

Values of the second element of varnames used to make predictions.

pred

The predictions based on the values x1 and x2.

graph

A graph is produced, but no other information is returned.

Author(s)

Dave Armstrong

Examples

1
2
3
data(InteractionEx)
mod <- lm(y ~ x1*x2 + z, data=InteractionEx)
DAintfun(mod, c("x1", "x2"))

DAMisc documentation built on Jan. 12, 2022, 1:07 a.m.