## loglike_compare
library(lavaan)
data(simple_med)
dat <- simple_med
mod <-
"
m ~ a * x
y ~ b * m
ab := a * b
"
fit <- lavaan::sem(mod, simple_med, fixed.x = FALSE)
# Four points are used just for illustration
# At least 21 points should be used for a smooth plot
# Remove try_k_more in real applications. It is set
# to run such that this example is not too slow.
# use_pbapply can be removed or set to TRUE to show the progress.
ll_a <- loglike_compare(fit, par_i = "m ~ x", n_points = 4,
try_k_more = 0,
use_pbapply = FALSE)
plot(ll_a)
plot(ll_a, add_pvalues = TRUE)
# See the vignette "loglike" for an example for the
# indirect effect.
Run the code above in your browser using DataLab