% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/cfa_cutoff.R
\name{RMdimCFAPlot}
\alias{RMdimCFAPlot}
\title{Plot observed CFA fit and loadings against the simulated null}
\usage{
RMdimCFAPlot(simfit, data, percentile = NULL)
}
\arguments{
\item{simfit}{The list returned by \code{\link{RMdimCFACutoff}}.}

\item{data}{The item-response data the CFA was run on (the same items used
for the cutoff). Required: the observed values are computed from it.}

\item{percentile}{Numeric in (50, 100) or \code{NULL}. When supplied, the
cutoffs and flags are recomputed at this percentile from the stored
simulated distributions (no re-simulation). When \code{NULL} (default), the
percentile from the original \code{RMdimCFACutoff()} call is reused.}
}
\value{
A named list of two \code{ggplot} objects:
\describe{
\item{\code{loadings}}{Per-item standardized loadings: simulated distribution
(dots), expected interval, and the observed loading as a diamond
(red when flagged).}
\item{\code{fit}}{Faceted CFI / RMSEA / SRMR simulated distributions with the
observed value and cutoff overlaid.}
}
}
\description{
Returns two figures (in a list) comparing the observed one-factor CFA to
the simulated null distribution from \code{\link{RMdimCFACutoff}}:
a per-item standardized-loadings plot (observed marker against each item's
simulated distribution and expected range, in the style of
\code{\link{RMitemInfitPlot}}), and a faceted plot of the CFI / RMSEA
/ SRMR distributions with the observed value overlaid.
}
\examples{
\donttest{
if (requireNamespace("lavaan", quietly = TRUE) &&
    requireNamespace("ggplot2", quietly = TRUE) &&
    requireNamespace("eRm", quietly = TRUE)) {
  data("raschdat1", package = "eRm")
  sim <- RMdimCFACutoff(raschdat1[, 1:8], iterations = 50,
                        parallel = FALSE, seed = 1)
  plots <- RMdimCFAPlot(sim, data = raschdat1[, 1:8])
  plots$loadings
  plots$fit
}
}

}
\seealso{
\code{\link{RMdimCFACutoff}}, \code{\link{RMdimCFA}}
}
