modRegGraph: Plot a moderated regression interaction diagram and return...

View source: R/modRegGraph.R

modRegGraphR Documentation

Plot a moderated regression interaction diagram and return graphical coordinates

Description

Function plots a moderated regression interaction diagramm and returns the coordinates of the points pred_H_mod_H pred_H_mod_L pred_L_mod_H pred_L_mod_L to be used elswhere (e.g., in another plot). H denotes high (+1 SD), L denotes low (-1 SD).

Usage

modRegGraph(
  betas,
  pred,
  mod,
  crit,
  modRangeL = -1,
  modRangeH = 1,
  modLabSeq = 1,
  plotRange = 1,
  title = "",
  plot = TRUE
)

Arguments

betas

Coefficients (Betas) of the moderated regression. Attribute names are used as beta labels, generated for example by coef(lm(my_model)). Attribute labels can also be used to mask variable names in a regression plot.

pred

String with the name of the predictor.

mod

String with the name of the moderator.

crit

String with the name of the criterium.

modRangeL

Lower end of the moderator to be plottet (default: -1 SD).

modRangeH

Upper end of the moderator to be plottet (default: 1 SD).

modLabSeq

Moderation label sequence (1 or 2). Cope with the lm() function, which puts out the labels in 2 different orders pred:mod (which is 1), or mod:pred (which is 2). Default is 1.

plotRange

Plot range of the square plot (default: 1 SD).

title

Title of the plot.

plot

Logical value if a plot should be printed (default is TRUE).

Value

Named vector with the four coordinates (pred_H_mod_H, pred_H_mod_L, pred_L_mod_H, pred_L_mod_L) on the y-axis for predictor at -1/1 SD and moderator at modRangeL/modRangeH SD.

Author(s)

Axel Zinkernagel zinkernagel@uni-landau.de

Examples

betas <- coef(lm("AutoBehav ~ IndMeasure * mod", data = df1))

modRegGraph(betas, pred = "IndMeasure", mod = "mod", crit = "AutoBehav",
title = "Title plot")

# See also vignette


axzinker/axBoost documentation built on July 4, 2024, 9:14 p.m.