R/mlm_plot.R
mlm_spaghetti_plot.Rd
Plot population-level fitted values and X values, for M and Y.
mlm_spaghetti_plot(
mod = NULL,
d = NULL,
id = "id",
x = "x",
m = "m",
y = "y",
level = 0.95,
n = 12,
binary_y = FALSE,
mx = "fitted",
fixed = TRUE,
random = TRUE,
h_jitter = 0,
v_jitter = 0,
bar_width = 0.2,
bar_size = 0.75,
n_samples = NA
)
A multilevel mediation model estimated with mlm()
.
A data.frame
or a data_frame
used in fitting model.
Name of id variable (identifying subjects) in data (d
).
Name of X variable in data
.
Name of M variable in data
.
Name of Y variable in data
.
X level for Credible Intervals. (Defaults to .95.)
Number of points along X to evaluate fitted values on. See details.
Set to TRUE if the outcome variable (Y) is 0/1.
Should the X axis of the M-Y figure be "fitted" values, or "data" values. Defaults to "fitted".
Should the population-level ("fixed") fitted values be shown?
Should the subject-level ("random") fitted values be shown?
Horizontal jitter of points. Defaults to 0.
Vertical jitter of points. Defaults to 0.
Width of the error bars. Defaults to 0.2.
Thickness of the error bars. Defaults to 0.75.
Number of MCMC samples to use in calculating fitted values. See details.
A list of two ggplot2 objects.
If n = 2
, the fitted values will be represented as points
with X
line with a Confidence Ribbon instead.
If a very large model is fitted with a large number of MCMC iterations,
the function might take a long time to run. In these cases, users can set
n_samples
to a smaller value (e.g. 1000), in which case the fitted
values (and the CIs) will be based on a random subset of n_samples
MCMC samples. The default value is NA, meaning that all MCMC samples are
used.