residual_plot: Function to generate conditional regression equation plots...

View source: R/residual_plot.R

residual_plotR Documentation

Function to generate conditional regression equation plots (i.e., simple effects) with rblimp and SIMPLE command

Description

Generates a conditional effect plots based on the posterior summaries from the output of rblimp.

Usage

residual_plot(
  model,
  variable,
  nsigma = 1,
  point_col = "black",
  horz_line = "black",
  col1 = "#0571b0",
  col2 = "#ca0020",
  linewidth = 1.1,
  ...
)

Arguments

model

an blimp_obj. The object must have a SIMPLE command output saved.

variable

the name of the outcome for which to create a plot

nsigma

the number of standard deviations to produce credible bounds

point_col

the color of the points in the plot

horz_line

the color of the horiztonal zero line

col1

the color of the loess mean line

col2

the color of the loess credible bound lines

linewidth

the linewidth value for the loess lines and its bounds.

...

arguments passed to loess call used to loess lines.

Details

All colors are passed into ggplot2. See ggplot2::aes_colour_fill_alpha for details on changing colors.

Value

a ggplot2::ggplot plot

Examples


# Generate Data
mydata <- rblimp_sim(
    c(
        'x ~ normal(0, 1)',
        'm ~ normal(0, 1)',
        'y ~ normal(10 + 0.5*x + m + 0.2*x*m, 1)'
    ),
    n = 100,
    seed = 981273
)

# Run Rblimp
m1 <- rblimp(
    'y ~ x m',
    mydata,
    nimps = 10,
    seed = 10972,
    burn = 1000,
    iter = 1000
)

# Generate Plot
residual_plot(m1, 'y') + ggplot2::theme_minimal()


rblimp documentation built on May 18, 2026, 9:07 a.m.