MBESS (version 4.8.0)

intr.plot.2d: Plotting Conditional Regression Lines with Interactions in Two Dimensions

Description

To plot regression lines for one two-way interactions, holding one of the predictors (in this function, z) at values -2, -1, 0, 1, and 2 standard deviations above the mean.

Usage

intr.plot.2d(b.0, b.x, b.z, b.xz,x.min=NULL, x.max=NULL, x=NULL, 
n.x=50, mean.z=NULL, sd.z=NULL, z=NULL,xlab="Value of X",  
ylab="Dependent Variable", sd.plot=TRUE, sd2.plot=TRUE, sd_1.plot=TRUE, 
sd_2.plot=TRUE, type.sd=2, type.sd2=3, type.sd_1=4, type.sd_2=5, 
legend.pos="bottomright", legend.on=TRUE, ... )

Arguments

b.0

the intercept

b.x

regression coefficient for predictor x

b.z

regression coefficient for predictor z

b.xz

regression coefficient for the interaction of predictors x and z

x.min,x.max

the range of x used in the plot

x

a specific predictor vector x, used instead of x.min and x.max

n.x

number of elements in predictor vector x

mean.z

mean of predictor z

sd.z

standard deviation of predictor z

z

a specific predictor vector z, used instead of z.min and z.max

xlab

title for the axis which the predictor x is on

ylab

title for the axis which the dependent y is on

sd.plot, sd2.plot, sd_1.plot, sd_2.plot

whether or not to plot the regression line holding z at values 1, 2, -1, and -2 standard deviations above the mean, respectively. Default values are all TRUE.

type.sd, type.sd2, type.sd_1, type.sd_2

types of lines to be plotted holding z at values 1, 2, -1, and -2 standard deviations above the mean, respectively. Default are line type 2,3,4, and 5, respectively.

legend.pos

position of the legend; possible options are "bottomright", "bottom", "bottomleft", "left", "center", "right", "topleft", "top", and "topright".

legend.on

whether or not to show the legend

allows one to potentially include parameter values for inner functions

Details

To input the predictor x, one can use either the limits of x (x.max and x.min) , or a specific vector x (x). To input the predictor z, one can use either the mean and standard deviation of z (mean.z and sd.z ), or a specific vector z (z).

References

Cohen, J., Cohen, P., West, S. G. and Aiken, L. S. (2003). Applied multiple regression/correlation analysis for the behavioral sciences (3rd ed.). Mahwah, NJ: Erlbaum.

See Also

intr.plot

Examples

Run this code
# NOT RUN {
## A situation where one regression line is outside the default scope of the coordinates
intr.plot.2d(b.0=16, b.x=2.2, b.z=2.6, b.xz=.4, x.min=0, x.max=20, mean.z=0, sd.z=3)

## Adjust the scope of x and y axes so that proper sections of regression lines can be seen 
intr.plot.2d(b.0=16, b.x=2.2, b.z=2.6, b.xz=.4, x.min=0, x.max=50, mean.z=0, 
sd.z=3, xlim=c(0,50), ylim=c(-20,100) )

## Use specific vector(s) to define the predictor(s) 
intr.plot.2d(b.0=16, b.x=2.2, b.z=2.6, b.xz=.4, x=c(1:10), z=c(0,2,4,6,8,10))

intr.plot.2d(b.0=16, b.x=2.2, b.z=2.6, b.xz=.4, x.min=0, x.max=20, 
z=c(1,3,6,7,9,13,16,20), ylim=c(0,100))

## Change the position of the legend so that it does not block regression lines
intr.plot.2d(b.0=10, b.x=-.3, b.z=1, b.xz=.5, x.min=0, x.max=40, mean.z=-5, sd.z=3, 
ylim=c(-100,100),legend.pos="topright" )

# }

Run the code above in your browser using DataLab