code for asymptotic covariance matrix (ACM) in lavaan (ordinal var).

456 views
Skip to first unread message

Ho-Won Jung

unread,
Jul 27, 2016, 10:19:29 AM7/27/16
to lavaan
Hello:


In lavaan & ordinal variables, would you let me know commands to compute the polychoric correlation (covariance) matrix and its accompanying asymptotic covariance matrix (ACM)?


Cheers,

Ho-Won Jung, Ph.D. (MIS Professor)

Korea University Business School (KUBS)

145, Anam-ro, Seongbuk-gu, Seoul, 02841, Korea

Office Tel): 82-2 3290-1938

Cell) 82-10-9447-1938

Fax)  82-2 3290-1307

mailto: hwjung@.korea.ac.kr

http://biz.korea.ac.kr/~misjung

Terrence Jorgensen

unread,
Jul 29, 2016, 4:24:16 AM7/29/16
to lavaan
In lavaan & ordinal variables, would you let me know commands to compute the polychoric correlation (covariance) matrix and its accompanying asymptotic covariance matrix (ACM)?

Look at the bottom example on the help page for ?lavCor.  After getting that fitted model of polychoric correlations, you can extract the matrix using either of these:

lavInspect(fit.un, "coef")$theta
lavInspect(fit.un, "cor.ov")

And the ACM using:

vcov(fit.un)


Terrence D. Jorgensen
Postdoctoral Researcher, Methods and Statistics
Research Institute for Child Development and Education, the University of Amsterdam

Ho-Won Jung

unread,
Aug 1, 2016, 9:49:04 PM8/1/16
to lavaan
Thanks for your responses.

I perform the vanishing tetrad test with SAS macros that require the output formats of Mplus.
The SAS macros require three files such as pcm, acm, and model implied correlation matrix.

Your hints on pcm from lavInspect gave me the same output as Mplus's. 
However, vcov(fit.un) generates different output from Mplus.
(I got the model implied correlation matrix from lavaan).

Mplus acm includes 228 elements, but vcov generates 100 elements.

Would you find some hints to get acm of Mplus output format?

Thank you very much.
---------------------------------------------------
Mplus code is as follows:
--------------------------------------------------

data:          file  = CLp2.txt;
variable:     names = y1 y2 y3 y4 y5;     
                 categorical = y1 - y5;   

analysis:     estimator=wls;   

model:   
    y1-y4 with y5;   
    y1-y3 with y4;   
    y1-y2 with y3;   
    y1 with y2;     
    
 output:    sampstat tech3;   
 savedata:  tech3 is  D:\Now(MyPaper)\2016_CTA_Phase2\Mplus\CLp2_Mplus.acm;
                sample is D:\Now(MyPaper)\2016_CTA_Phase2\Mplus\CLp2_Mplus.pcm;

Terrence Jorgensen

unread,
Aug 3, 2016, 9:12:12 AM8/3/16
to lavaan
Mplus acm includes 228 elements, but vcov generates 100 elements.

I am not sure what you mean by "elements".  Is the number of rows (or columns) in the ACM?  Is it the number of cells (rows times columns)?  Is it the number of non-redundant elements in the ACM?

Would you find some hints to get acm of Mplus output format?


Try counting how many parameters you should estimate.  With 5 variables, there are 5*(5 - 1) / 2 = 10 estimated polychoric correlations.  There are also k - 1 thresholds for each k-category variable.  So the sum of the numbers of thresholds and polychorics is the total number of estimated parameters, which is how many rows (and columns) your ACM should have.  And the number of nonredundant elements in the ACM is [p*(p + 1)] / 2.  

I'm not sure what Mplus's format is, but I'm sure their user guide will tell you.  Once you find that out, you should be able to figure out how to extract the same elements in the order you need from the lavaan output.

Seongho Bae

unread,
Aug 14, 2016, 5:09:21 AM8/14/16
to lavaan
First, The estimation must be 'WLSMV'; not 'WLS' in Mplus. (It's called Limited-information Item Factor Analysis or Limited-information Item response theory.)

See this;
이순묵, 윤창영, 이민형, 정선호 (2016). 탐색적 요인분석 : 어떻게 달라지나?. 한국심리학회지: 일반, 35(1), 217-255.

And then, I write pseudo code

model <- '
y1 + y2 + y3 + y4 ~~ y5
y1 + y2 + y3 ~~ y4
y1 + y2 ~~ y3
y1 ~~ y2
'
mod1 <- lavaan::sem(data = data, model = model, ordered = c(y1, y2, y3, y4), estimator = 'WLSMV')

But, If you want just calculate polychoric correlation, just do this. I'm not sure the polychoric correlation is same with the ACM matrix. You may want to calculate polychoric correlation I thought.

install.packages('psych') 
psych::polychoric(data)

Best,
Seongho Bae

Psy.D Student in Work Psychology for the large-scale assessment and evaluation

Research Interests

· Personnel Selection (Methods and Competency Assessment)

· Quantitative Psychology (Multidimensional Item Response Theory, Multidimensional Computer Adaptive Testing, Cognitive Diagnosis Model, Structural Equation Model, Multilevel Modeling in Generalizability Theory perspectives)


2016년 8월 2일 화요일 오전 10시 49분 4초 UTC+9, Ho-Won Jung 님의 말:

Yves Rosseel

unread,
Aug 19, 2016, 9:19:09 AM8/19/16
to lav...@googlegroups.com
> In lavaan & ordinal variables, would you let me know commands to
> compute the polychoric correlation (covariance) matrix and its
> accompanying asymptotic covariance matrix (ACM)?

Once you have fitted the model, you can get the polychoric correlation
matrix as follows:

inspect(fit, "sampstat")$cov

and N times the asymptotic covariance matrix (of both thresholds and
correlations):

inspect(fit, "gamma")

The first rows/cols correspond to the thresholds; then, we have the
variances of the correlations.

Alternatively, you can fit a saturated model. For example, assuming all
categorical variables are in Data:

fit <- lavCor(Data, output = "fit", se = "standard")
inspect(fit, "sampstat")$cov
vcov(fit)

The latter will give you 'labeled' rows/columns. Multiplying this matrix
by N will again give you Gamma (although rows/cols may be in a different
order).

Yves.

tran viet Yen

unread,
Apr 24, 2018, 2:38:18 AM4/24/18
to lavaan
Dear all,

By the way, could you give out the code for deriving the asymptotic covariance matrix (ACOV) of estimates in case of standardized solution?

For instance, I run the following code: vcov(fit)

The program returned the ACOV of unstandardized estimates.

Thank you very much.

Best regards,

Tran Viet Yen.

Vào 23:19:29 UTC+9 Thứ Tư, ngày 27 tháng 7 năm 2016, Ho-Won Jung đã viết:
Hello:


In lavaan & ordinal variables, would you let me know commands to compute the polychoric correlation (covariance) matrix and its accompanying asymptotic covariance matrix (ACM)?


Cheers,

Ho-Won Jung, Ph.D. (MIS Professor)

Korea University Business School (KUBS)

145, Anam-ro, Seongbuk-gu, Seoul, 02841, Korea

Office Tel): 82-2 3290-1938

Cell) 82-10-9447-1938

Fax)  82-2 3290-1307

Yves Rosseel

unread,
Apr 24, 2018, 8:10:28 AM4/24/18
to lav...@googlegroups.com
On 04/24/2018 08:38 AM, tran viet Yen wrote:
> Dear all,
>
> By the way, could you give out the code for deriving the asymptotic
> covariance matrix (ACOV) of estimates in case of standardized solution?

Have a look at the source code for standardizedSolution(). We just just
the Delta rule.

Yves.

Trần Việt Yên

unread,
Apr 25, 2018, 8:04:15 AM4/25/18
to lav...@googlegroups.com
Dear Yves,

Thank you for the advice. I will try it.

Best regards,

Tran Viet Yen
> --
> 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 https://groups.google.com/group/lavaan.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages