plot.loglike_compare | R Documentation |
Visualize the log profile likelihood of a parameter fixed to values in a range.
## S3 method for class 'loglike_compare'
plot(
x,
y,
type = c("ggplot2", "default"),
size_label = 4,
size_point = 4,
nd_theta = 3,
nd_pvalue = 3,
size_theta = 4,
size_pvalue = 4,
add_pvalues = FALSE,
...
)
x |
The output of |
y |
Not used. |
type |
Character. If |
size_label |
The relative size of the labels for thetas
(and p-values, if requested) in the
plot, determined by |
size_point |
The relative size of the points to be added
if p-values are requested in the
plot, determined by |
nd_theta |
The number of decimal places for the labels of theta. Default is 3. |
nd_pvalue |
The number of decimal places for the labels of p-values. Default is 3. |
size_theta |
Deprecated. No longer used. |
size_pvalue |
Deprecated. No longer used. |
add_pvalues |
If |
... |
Optional arguments. Ignored. |
Given the output of loglike_compare()
, it plots the log
profile likelihood based on quadratic approximation and that
based on the original log-likelihood. The log profile likelihood
is scaled to have a maximum of zero (at the point estimate) as
suggested by Pawitan (2013).
Nothing if type = "default"
, the generated ggplot2::ggplot()
graph if type = "ggplot2"
.
Pawitan, Y. (2013). In all likelihood: Statistical modelling and inference using likelihood. Oxford University Press.
## 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.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.