Learn R Programming

DAMisc (version 1.7.2)

DAintfun3: Conditional Effects Plots for Interactions in Linear Models

Description

Generates two conditional effects plots for two interacted continuous covariates in linear models.

Usage

DAintfun3(
  obj,
  varnames,
  varcov = NULL,
  name.stem = "cond_eff",
  xlab = NULL,
  ylab = NULL,
  plot.type = "screen"
)

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.

varcov

A variance-covariance matrix with which to calculate the conditional standard errors. If NULL, it is calculated with vcov(obj).

name.stem

A character string giving filename to which the appropriate extension will be appended

xlab

Optional vector of length two giving the x-labels for the two plots that are generated. The first element of the vector corresponds to the figure plotting the conditional effect of the first variable in varnames given the second and the second element of the vector corresponds to the figure plotting the conditional effect of the second variable in varnames conditional on the first.

ylab

Optional vector of length two giving the y-labels for the two plots that are generated. The first element of the vector corresponds to the figure plotting the conditional effect of the first variable in varnames given the second and the second element of the vector corresponds to the figure plotting the conditional effect of the second variable in varnames conditional on the first.

plot.type

One of ‘pdf’, ‘png’, ‘eps’ or ‘screen’, where the one of the first three will produce two graphs starting with name.stem written to the appropriate file type and the third will produce graphical output on the screen.

Value

graphs

Either a single graph is printed on the screen (using par(mfrow=c(1,2))) or two figures starting with name.stem are produced where each gives the conditional effect of one variable based on the values of another.

Details

This function does the same thing as DAintfun2, but presents effects only at the mean of the conditioning variable and the mean +/- 1 standard deviation.

References

Brambor, T., W.R. Clark and M. Golder. (2006) Understanding Interaction Models: Improving Empirical Analyses. Political Analysis 14, 63-82. Berry, W., M. Golder and D. Milton. (2012) Improving Tests of Theories Positing Interactions. Journal of Politics.

Examples

Run this code
# NOT RUN {
data(InteractionEx)
mod <- lm(y ~ x1*x2 + z, data=InteractionEx)
DAintfun3(mod, c("x1", "x2"))

# }

Run the code above in your browser using DataLab