condEffect: Draw interact plot with moderation effect

View source: R/condEffect.R

condEffectR Documentation

Draw interact plot with moderation effect

Description

Draw interact plot with moderation effect

Usage

condEffect(
  fit,
  pred,
  modx,
  modx.values = NULL,
  probs = NULL,
  digits = 1,
  show.Effect = TRUE,
  switchVars = FALSE,
  max.ylev = 6,
  arrowlength = 0.05,
  ...
)

Arguments

fit

A regression model

pred

The name of the predictor variable

modx

The name of the moderator variable

modx.values

For which values of the moderator should lines be plotted? Default is NULL. If NULL, then the customary +/- 1 standard deviation from the mean as well as the mean itself are used for continuous moderators.

probs

A vector of probability weights for obtaining the elements of the vector being sampled. Default is NULL.

digits

integer indicating the number of decimal places

show.Effect

A logical

switchVars

A logical

max.ylev

An integer indicating the maximum number of levels of modifier variable

arrowlength

arrow length

...

Further argument to be passed to interactions::interact_plot

Examples

fit=lm(mpg~wt*am+disp+cyl+drat,data=mtcars)
condEffect(fit,pred="wt",modx="am")
condEffect(fit,pred="wt",modx="am",switchVars=TRUE)
fit=lm(mpg~wt*hp+disp+cyl+drat,data=mtcars)
condEffect(fit,pred="wt",modx="hp")
condEffect(fit,pred="wt",modx="hp",show.Effect=FALSE)
condEffect(fit,pred="wt",modx="hp",switchVars=TRUE)
condEffect(fit,pred="wt",modx="hp",modx.values=c(100,150,200))
condEffect(fit,pred="wt",modx="hp",probs=c(0.16,0.4,0.6,0.84))

cardiomoon/semMediation documentation built on Nov. 16, 2023, 4:26 a.m.