sample.cov
argument must be a list containing the sample variance-covariance matrix of each group as a separate element in the list. If a mean structure is needed, the sample.mean
argument must be a list containing the sample means of each group..." (http://lavaan.ugent.be/tutorial/cov.html). But I have no idea how to impliment this. Any advice? Is there any example/script I can learn from?Here is an example, with two groups, using the sem function, and specifying scalar invariance. The lists are declared with the c() “concatenate” function. The two covariance matrices are objects named covlo and covhi, and the sample mean vectors are objects named meanslo and meanshi. Notice that you also need a list of sample sizes.
--Ed Rigdon
<- sem(model=model.syntax,
sample.cov=list(covlo,covhi),
sample.mean=list(meanslo,meanshi),
sample.nobs=list(200, 160),
group.equal=c("loadings","intercepts"))
--
You received this message because you are subscribed to the Google Groups "lavaan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lavaan+un...@googlegroups.com.
To post to this group, send email to lav...@googlegroups.com.
Visit this group at http://groups.google.com/group/lavaan.
For more options, visit https://groups.google.com/d/optout.
I am having difficulty finding the correct format for sample.mean=list(means1,means2).
In other words, is there a 'mean' equivalent to the getCov ?
library(lavaan)
HS.model <- ' visual =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed =~ x7 + x8 + x9
'
# using full data
fit <- cfa(HS.model, data=HolzingerSwineford1939, group="school")
summary(fit)
# Using sample statistics
S.Pasteur <- cov(subset(HolzingerSwineford1939, subset = school=="Pasteur",
select = paste0("x", 1:9)))
S.GrantWhite <- cov(subset(HolzingerSwineford1939, subset = school=="Grant-White",
select = paste0("x", 1:9)))
M.Pasteur <- colMeans(subset(HolzingerSwineford1939,
subset = school=="Pasteur",
select = paste0("x", 1:9)))
M.GW <- colMeans(subset(HolzingerSwineford1939,
subset = school=="Grant-White",
select = paste0("x", 1:9)))
fit2 <- cfa(HS.model, sample.cov=list(Pasteur=S.Pasteur,
`Grant-White`=S.GrantWhite),
sample.mean = list(Pasteur=M.Pasteur, `Grant-White`= M.GW),
sample.nobs=c(156,145), meanstructure=TRUE)
summary(fit2)
--
You received this message because you are subscribed to a topic in the Google Groups "lavaan" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/lavaan/PWh2TAniWbM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to lavaan+un...@googlegroups.com.
To post to this group, send email to lav...@googlegroups.com.
Visit this group at https://groups.google.com/group/lavaan.
fit <- cfa(HS.model,data=HolzingerSwineford1939,group="school")
summary(fit)
# Using sample statistics
S.Pasteur <-cov(subset(HolzingerSwineford1939, subset = school=="Pasteur",
select =paste0("x", 1:9)))
S.GrantWhite <-cov(subset(HolzingerSwineford1939, subset = school=="Grant-White",
select =paste0("x", 1:9)))
M.Pasteur <-colMeans(subset(HolzingerSwineford1939,
subset =school=="Pasteur",
select =paste0("x", 1:9)))
M.GW <-colMeans(subset(HolzingerSwineford1939,
subset =school=="Grant-White",
select =paste0("x", 1:9)))
fit2 <- cfa(HS.model,sample.cov=list(Pasteur=S.Pasteur,
`Grant-White`=S.GrantWhite),
sample.mean =list(Pasteur=M.Pasteur, `Grant-White`=M.GW),
sample.nobs=c(156,145),meanstructure=TRUE)
summary(fit2)
Terrence D. JorgensenAssistant Professor, Methods and StatisticsResearch Institute for Child Development and Education, the University of AmsterdamUvA web page: http://www.uva.nl/profile/t.d.jorgensen
--
You received this message because you are subscribed to a topic in the Google Groups "lavaan" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/lavaan/PWh2TAniWbM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to lavaan+un...@googlegroups.com.
To post to this group, send email to lav...@googlegroups.com.Visit this group at https://groups.google.com/group/lavaan.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "lavaan" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/lavaan/PWh2TAniWbM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to lavaan+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lavaan/dec28646-64fb-4c41-bf2d-891417ed283an%40googlegroups.com.