Fit a Confirmatory Factor Analysis (CFA) model.
cfa(model = NULL, data = NULL, ordered = NULL,
sample.cov = NULL, sample.mean = NULL, sample.nobs = NULL,
group = NULL, cluster = NULL,
constraints = "", WLS.V = NULL, NACOV = NULL,
...)
A description of the user-specified model. Typically, the model
is described using the lavaan model syntax. See
model.syntax
for more information. Alternatively, a
parameter table (eg. the output of the lavaanify()
function) is also
accepted.
An optional data frame containing the observed variables used in the model. If some variables are declared as ordered factors, lavaan will treat them as ordinal variables.
Character vector. Only used if the data is in a data.frame. Treat these variables as ordered (ordinal) variables, if they are endogenous in the model. Importantly, all other variables will be treated as numeric (unless they are declared as ordered in the original data.frame.)
Numeric matrix. A sample variance-covariance matrix.
The rownames and/or colnames must contain the observed variable names.
For a multiple group analysis, a list with a variance-covariance matrix
for each group. Note that if maximum likelihood estimation is used and
likelihood="normal"
, the user provided covariance matrix is
internally rescaled by multiplying it with a factor (N-1)/N, to ensure
that the covariance matrix has been divided by N. This can be turned off
by setting the sample.cov.rescale
argument to FALSE
.
A sample mean vector. For a multiple group analysis, a list with a mean vector for each group.
Number of observations if the full data frame is missing and only sample moments are given. For a multiple group analysis, a list or a vector with the number of observations for each group.
A variable name in the data frame defining the groups in a multiple group analysis.
Not used yet.
Additional (in)equality constraints not yet included in the
model syntax. See model.syntax
for more information.
A user provided weight matrix to be used by estimator "WLS"
;
if the estimator is "DWLS"
, only the diagonal of this matrix will be
used. For a multiple group analysis, a list with a weight matrix
for each group. The elements of the weight matrix should be in the
following order (if all data is continuous): first the means (if a
meanstructure is involved), then the lower triangular elements of the
covariance matrix including the diagonal, ordered column by column. In
the categorical case: first the thresholds (including the means for
continuous variables), then the slopes (if any), the variances of
continuous variables (if any), and finally the lower triangular elements
of the correlation/covariance matrix excluding the diagonal, ordered
column by column.
A user provided matrix containing the elements of (N times)
the asymptotic variance-covariance matrix of the sample statistics.
For a multiple group analysis, a list with an asymptotic
variance-covariance matrix for each group. See the WLS.V
argument for information about the order of the elements.
Many more additional options can be defined, using 'name = value'.
See lavOptions
for a complete list.
An object of class '>lavaan
, for which several methods
are available, including a summary
method.
The cfa
function is a wrapper for the more general
lavaan
function, using the following default arguments:
int.ov.free = TRUE
, int.lv.free = FALSE
,
auto.fix.first = TRUE
(unless std.lv = TRUE
),
auto.fix.single = TRUE
, auto.var = TRUE
,
auto.cov.lv.x = TRUE
,
auto.th = TRUE
, auto.delta = TRUE
,
and auto.cov.y = TRUE
.
Yves Rosseel (2012). lavaan: An R Package for Structural Equation Modeling. Journal of Statistical Software, 48(2), 1-36. URL http://www.jstatsoft.org/v48/i02/.
# NOT RUN {
## The famous Holzinger and Swineford (1939) example
HS.model <- ' visual =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed =~ x7 + x8 + x9 '
fit <- cfa(HS.model, data=HolzingerSwineford1939)
summary(fit, fit.measures=TRUE)
# }
Run the code above in your browser using DataLab