% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/test_group_constraints.R
\name{test_group_equal}
\alias{test_group_equal}
\title{Test Group Constraints}
\usage{
test_group_equal(
  fit = fit,
  group.equal = NULL,
  group.partial = NULL,
  check_post_check = TRUE,
  ...,
  fit_name = "fit",
  get_map_names = FALSE,
  get_test_name = FALSE
)
}
\arguments{
\item{fit}{The fit object. Must be
the output of \code{\link[lavaan:lavaan]{lavaan::lavaan()}} or
its wrappers, such as \code{\link[lavaan:sem]{lavaan::sem()}}
and \code{\link[lavaan:cfa]{lavaan::cfa()}}. The model must
be a multigroup model.}

\item{group.equal}{The same argument
used by \code{lavaan}. A character vector
with one or more of these values:
\code{"regressions"}, \code{"loadings"},
\code{"lv.covariances"}, \code{"lv.variances"},
\code{"intercepts"}, \code{"means"}, \code{"thresholds"},
\code{"residual.covariances"}, \code{"composite.weights"},
and \code{"residuals"}.}

\item{group.partial}{The same argument
used by \code{lavaan}. The parameters that
should be free across groups. Used with
\code{group.equal} to exclude some parameters
from those requested to be equal
across groups by \code{group.equal}.}

\item{check_post_check}{Logical. If
\code{TRUE}, the default, and the model
is fitted by \code{lavaan}, the test
will be conducted only if the model
passes the \code{post.check} conducted
by \code{\link[lavaan:lavInspect]{lavaan::lavInspect()}} (with
\code{what = "post.check"}).}

\item{...}{Optional arguments to be
passed to \code{\link[lavaan:lavTestLRT]{lavaan::lavTestLRT()}}.}

\item{fit_name}{The name of the
model fit object to be extracted.
Default is \code{"fit"}. Used only when
more than one model is fitted in
each replication. This should be
the name of the model on which the
test is to be conducted.}

\item{get_map_names}{Logical. Used
by \code{\link[=power4test]{power4test()}} to determine how
to extract stored information and
assign them to this function. Users
should not use this argument.}

\item{get_test_name}{Logical. Used
by \code{\link[=power4test]{power4test()}} to get the default
name of this test. Users should not
use this argument.}
}
\value{
In its normal usage, it returns
a one-row data frame with the
following columns:
\itemize{
\item \code{est}: The chi-square difference.
\item \code{cilo} and \code{cihi}: \code{NA}. Not used.
\item \code{sig}: Whether the chi-square
difference test is significant
\item \code{test_label}: The constraints
imposted.
}
}
\description{
Test the model fit change
when one or more between-group
constraints are imposed.
}
\details{
This function is to be used in
\code{\link[=power4test]{power4test()}} for testing
the difference in model fit
when one or more between-group
constraints are imposed
, by
setting it to the \code{test_fun}
argument.
}
\examples{

# Specify the model

mod <-
"
m ~ x
y ~ m + x
"

# Specify the population values

mod_es <-
"
y ~ m: l
m ~ x:
  - nil
  - s
y ~ x: nil
"

# Simulate the data

sim_only <- power4test(nrep = 2,
                       model = mod,
                       pop_es = mod_es,
                       n = 100,
                       iseed = 1234)

# Do the tests in each replication

test_out <- power4test(object = sim_only,
                       test_fun = test_group_equal,
                       test_args = list(group.equal = "regressions"))

print(test_out,
      test_long = TRUE)


}
\seealso{
\code{\link[=power4test]{power4test()}}
}
