Raw File
Tip revision: 86e6cf8abb72a283862946ed4a502d4c84506729 authored by Daniel Oberski on 25 October 2012, 00:00 UTC
version 0.5
Tip revision: 86e6cf8
	Complex survey analysis of structural equation models (SEM)
	Takes a lavaan fit object and a complex survey design object as input
	and returns a structural equation modeling analysis based on the fit 
	object, where the complex sampling design is taken into account. 
	The structural equation model parameter estimates and standard errors
	are design-based. See Satorra and Muthen (1995) for details on the 
%- maybe also 'usage' for other objects documented here.
	A \code{\linkS4class{lavaan}} object resulting from a lavaan call. 
	It probably makes most sense to use estimator="MLM" in the call
	since this is the estimator that will be used in the complex sample
	estimates, but it is not strictly necessary.
	An  \code{\link{svydesign}} object resulting from a call to 
	svydesign in the survey package. This allows for incorporation of
	clustering, stratification, unequal probability weights, and finite
	population correction. See the survey documentation for more 
	The user specifies a complex sampling design with the survey package's
	\code{\link{svydesign}} function, and a structural equation model with
	When calling lavaan.survey, the following steps are then completed:
		\item The covariance matrix of the observed variables
		(or matrices in the case of multiple
		group analysis) is estimated using the svyvar command from the
		survey package. 
	       	\item The asymptotic covariance matrix of the variances and
		covariances is obtained from the svyvar output  (the "Gamma"
		\item The lavaan model is re-fit using Maximum Likelihood
		with the covariance matrix as data. After normal-theory ML
		estimation, the standard errors (vcov matrix), likelihood ratio
		("chi-square") statistic, and all derived fit indices and
		statistics are adjusted for the complex sampling design using
		the Gamma matrix. I.e. the Satorra-Bentler (SB) corrections are
		obtained ("MLM" estimation in lavaan terminology).

	The Satorra-Bentler ("aggregrated modeling") approach to complex 
	survey analysis of SEM was discussed by Satorra and Muthen (1995). 
	An alternative method to take clustering into account is multilevel 
	SEM ("disaggregated modeling").
	An object of class \code{\linkS4class{lavaan}}, where the estimates, 
	standard errors, vcov matrix, chi-square statistic, and fit measures 
	based on the chi-square take into account the complex survey 
	design. Several methods are available for \code{\linkS4class{lavaan}} 
	objects, including a \code{summary} method.}
	Oberski, D. and Saris, W. (2012). A model-based procedure to evaluate
	    the relative effects of different TSE components on structural equation
	    model parameter estimates. Presentation given at the International
	    Total Survey Error Workshop in Santpoort, the Netherlands. 

	Satorra, A., & Bentler, P. M. (1994). Corrections to test statistics
		and standard errors in covariance structure analysis. 

	Satorra, A., and Muthen, B. (1995). Complex sample data in structural
	   equation modeling. Sociological methodology, 25, 267-316.
	Daniel Oberski - \url{} - \email{}
    The function has been testing using simulation.
    Currently only continuous observed variables are implemented.

%% ~Make other sections like Warning with \section{Warning }{....} ~

###### A single group example #######


dk.model <- "
  socialTrust ~ 1 + systemTrust + fearCrime
  systemTrust ~ 1 + socialTrust + efficacy
  socialTrust ~~ systemTrust
" <- lavaan(dk.model,, auto.var=TRUE, estimator="MLM")
summary( <- svydesign(ids=~intnum, <- lavaan.survey(,


# A test for R CMD CHECK 
stopifnot(abs(attr(,"creff.svy")[2] - 1.2713339) < 1e-6)	
###### A multiple group example #######


# The Holzinger and Swineford (1939) example - some model with complex restrictions
HS.model <- ' visual  =~ x1 + x2 + c(lam31, lam31)*x3
              textual =~ x4 + x5 + c(lam62, lam62)*x6
              speed   =~ x7 + x8 + c(lam93, lam93)*x9 
             speed ~ textual 
             textual ~ visual'

# Fit multiple group per school
fit <- lavaan(HS.model, data=HolzingerSwineford1939,
              auto.var=TRUE, auto.fix.first=TRUE, group="school",
    , estimator="MLM")
summary(fit, fit.measures=TRUE)

# Create fictional clusters in the HS data
HolzingerSwineford1939$clus <- sample(1:100, size=nrow(HolzingerSwineford1939), replace=TRUE) <- svydesign(ids=~clus, data=HolzingerSwineford1939)

summary(fit.survey <- lavaan.survey(fit,

# Obtain a "relative efficiency" measure:
attr(fit.survey, "creff.svy")

#TODO: stopifnot
% Add one or more standard keywords, see file 'KEYWORDS' in the
% R documentation directory.
back to top