View source: R/johnson_neyman_wrapper.R
johnson_neyman | R Documentation |
Generates a Johnson-Neyman plot for the effect of X on the dependent variable, moderated by M. Performs two-sided t-Test on coefficient.
johnson_neyman( object, X, M, modrange = NULL, resolution = 10000, sig.thresh = 0.05 )
object |
model object, either "lm","lmer","nlme" |
X |
name of independent variable |
M |
name of moderator variable |
modrange |
moderator range to consider. Defaults to observed range. |
resolution |
plotting resolution, i.e. count of moderator values to consider |
sig.thresh |
significance threshold alpha. Defaults to 0.05. |
Johnson-neyman plot as gpplot2 object. Also prints the exact significance regions within the supplied moderator range.
#Generate base plot for linear model x <- rnorm(50) m <- rnorm(50) y <- rnorm(50,x*m,2) model <- lm(y~x*m) plot <- johnson_neyman(model,"x","m") # Add custom ggplot2 elements plot + labs(x="Changed x label",y="Changed y label") #mixed models x <- rnorm(50) m <- rnorm(50) y <- rnorm(50,x*m,2) g <- sample(1:10,50,TRUE) model <- lme4::lmer(y~m*x + (1|g)) johnson_neyman(model,"x","m")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.