jn_plot: Function to generate a Johnson-Neyman Plot of Conditional...

View source: R/jn_plot.R

jn_plotR Documentation

Function to generate a Johnson-Neyman Plot of Conditional Slope with rblimp

Description

Generates a Johnson-Neyman Plot based on the posterior summaries from the output of rblimp.

Usage

jn_plot(formula, model, ci = 0.95, ...)

Arguments

formula

an object of class formula to specify simple effect to plot. The formula must have the following form: outcome ~ focal | moderator. See Details below for nominal moderators.

model

an blimp_obj.

ci

a value between 0 and 1 specifying the credible interval size

...

passed bounds search algorithm. See jn_plot_func for details.

Details

To change colors use ggplot2's scale system. Both fill and color are used. See ggplot2::aes_colour_fill_alpha for more information about setting a manual set of colors.

Value

a ggplot2::ggplot plot. The bounding values are saved in the attribute 'bounds'.

See Also

jn_plot_func()

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 x*m',
    mydata,
    center = ~ m,
    simple = 'x | m',
    seed = 10972,
    burn = 1000,
    iter = 1000
)

# Generate Plot
jn_plot(y ~ x | m, m1)

# Generate Plot with different colors
(
    jn_plot(y ~ x | m, m1)
    + ggplot2::scale_fill_manual(
        values = c(`FALSE` = '#ca0020', `TRUE` = '#0571b0')
    )
)


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