withinPlot {mlmtools} | R Documentation |
Plots Within Group Associations
Description
Plots the within-group associations between an outcome and predictor variable.
Usage
withinPlot(
x,
y,
grouping,
dataset,
xlab = x,
ylab = y,
within_title = "Within-Group Association Plot",
point_color = "gray40",
line_color = "black",
se = FALSE,
full_range = FALSE,
lty = 1,
size = 2
)
Arguments
x |
Predictor variable. |
y |
Outcome variable. |
grouping |
Grouping variable (individual may be grouping variable). |
dataset |
A dataset containing the predictor, outcome, and grouping variables. |
xlab |
Character vector specifying the horizontal axis label. |
ylab |
Character vector specifying the vertical axis label. |
within_title |
Character vector specifying the title for the within group plot. |
point_color |
Color for points. |
line_color |
Color for lines. |
se |
A logical value indicating whether confidence intervals should be displayed. |
full_range |
A logical value indicating whether the fit line should span the full range of the plot or just the data. |
lty |
Line type. |
size |
Width of fit line. |
Value
Produces a plot of the within-group associations between an outcome and predictor variable.
References
Chow, S., Gilmore, R. O., Hallquist, M., Ram, N., & Brinberg, M. (2019). Introduction to multilevel model and interactions. GitHub. https://github.com/psu-psychology/r-bootcamp-2019/blob/master/talks/RBootcamp_MLMInteractions_2019_0820_Final2.Rmd
Examples
# Read in data
data(instruction)
# Create within plot
mathkind_withinPlot <- withinPlot(x = "mathkind", y = "mathgain",
grouping = "classid", dataset = instruction,
xlab = "Kindergarten Math Score", ylab = "Gain in Math Score")