lavaan output with xtable()

1,700 views
Skip to first unread message

SHIN Jong-Hwa

unread,
Nov 6, 2012, 11:16:30 PM11/6/12
to lav...@googlegroups.com
Dear lavaan Users,

There are some packages in R for generating outputs with table format
based on Latex. lavaan's outputs do not seem to be transformed into a
Latex style output. xtable() in xtable package does not work at all, for
example. Do you have any idea to transform lavaan's outputs into Latex
style's tables. Thank you in advance.

best,

Jong-Hwa

yrosseel

unread,
Nov 7, 2012, 3:28:24 PM11/7/12
to lav...@googlegroups.com
The output of the 'summary()' function will not work with xtable.
However, the parameterEstimates() function returns a data.frame, which
is supported by xtable. This works rather well:

> library(lavaan)
> library(xtable)
> example(> xtable(parameterEstimates(fit))
% latex table generated in R 2.15.1 by xtable 1.7-0 package
% Wed Nov 7 21:24:00 2012
\begin{table}[ht]
\begin{center}
\begin{tabular}{rlllrrrrrr}
\hline
& lhs & op & rhs & est & se & z & pvalue & ci.lower & ci.upper \\
\hline
1 & visual & =\~{} & x1 & 1.00 & 0.00 & & & 1.00 & 1.00 \\
2 & visual & =\~{} & x2 & 0.55 & 0.10 & 5.55 & 0.00 & 0.36 & 0.75 \\
3 & visual & =\~{} & x3 & 0.73 & 0.11 & 6.68 & 0.00 & 0.52 & 0.94 \\
4 & textual & =\~{} & x4 & 1.00 & 0.00 & & & 1.00 & 1.00 \\
5 & textual & =\~{} & x5 & 1.11 & 0.07 & 17.01 & 0.00 & 0.98 & 1.24 \\
6 & textual & =\~{} & x6 & 0.93 & 0.06 & 16.70 & 0.00 & 0.82 & 1.03 \\
7 & speed & =\~{} & x7 & 1.00 & 0.00 & & & 1.00 & 1.00 \\
8 & speed & =\~{} & x8 & 1.18 & 0.16 & 7.15 & 0.00 & 0.86 & 1.50 \\
9 & speed & =\~{} & x9 & 1.08 & 0.15 & 7.15 & 0.00 & 0.79 & 1.38 \\
10 & x1 & \~{}\~{} & x1 & 0.55 & 0.11 & 4.83 & 0.00 & 0.33 & 0.77 \\
11 & x2 & \~{}\~{} & x2 & 1.13 & 0.10 & 11.15 & 0.00 & 0.93 & 1.33 \\
12 & x3 & \~{}\~{} & x3 & 0.84 & 0.09 & 9.32 & 0.00 & 0.67 & 1.02 \\
13 & x4 & \~{}\~{} & x4 & 0.37 & 0.05 & 7.78 & 0.00 & 0.28 & 0.46 \\
14 & x5 & \~{}\~{} & x5 & 0.45 & 0.06 & 7.64 & 0.00 & 0.33 & 0.56 \\
15 & x6 & \~{}\~{} & x6 & 0.36 & 0.04 & 8.28 & 0.00 & 0.27 & 0.44 \\
16 & x7 & \~{}\~{} & x7 & 0.80 & 0.08 & 9.82 & 0.00 & 0.64 & 0.96 \\
17 & x8 & \~{}\~{} & x8 & 0.49 & 0.07 & 6.57 & 0.00 & 0.34 & 0.63 \\
18 & x9 & \~{}\~{} & x9 & 0.57 & 0.07 & 8.00 & 0.00 & 0.43 & 0.70 \\
19 & visual & \~{}\~{} & visual & 0.81 & 0.15 & 5.56 & 0.00 & 0.52 &
1.09 \\
20 & textual & \~{}\~{} & textual & 0.98 & 0.11 & 8.74 & 0.00 & 0.76
& 1.20 \\
21 & speed & \~{}\~{} & speed & 0.38 & 0.09 & 4.45 & 0.00 & 0.21 &
0.55 \\
22 & visual & \~{}\~{} & textual & 0.41 & 0.07 & 5.55 & 0.00 & 0.26 &
0.55 \\
23 & visual & \~{}\~{} & speed & 0.26 & 0.06 & 4.66 & 0.00 & 0.15 &
0.37 \\
24 & textual & \~{}\~{} & speed & 0.17 & 0.05 & 3.52 & 0.00 & 0.08 &
0.27 \\
\hline
\end{tabular}
\end{center}
\end{table}


Yves.




SHIN Jong-Hwa

unread,
Nov 8, 2012, 3:19:06 AM11/8/12
to lav...@googlegroups.com
2012년 11월 08일 05:28, yrosseel 쓴 글:
Dear Yves,

Thank you very much indeed!

Jong-Hwa

p.s) I would ask some related questions again when I test estout,
TeXreg, outreg, apsrtable, memisc packages for lavaan.

CHU-DING LING

unread,
Nov 26, 2018, 7:45:31 AM11/26/18
to lavaan

Dear Jong-Hwa and colleagues,

 

I want to consult with you that whether there is a package which can produce ASCII text for well-formatted tables from SEM analysis with lavaan. I find stargazer works well with other packages like lme4 and nlme. But I am not sure whether it is compatible with lavaan. Do you have any ideas?

 

Best,

Chuding


在 2012年11月8日星期四 UTC+8下午4:19:06,Jong-Hwa写道:

Edward Rigdon

unread,
Nov 26, 2018, 7:12:56 PM11/26/18
to lav...@googlegroups.com
One of my students this semseter has been using stargazer to produce his lavaan homework papers, so my guess is that stargazer works fine with lavaan.

--
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.

CHU-DING LING

unread,
Nov 26, 2018, 7:59:34 PM11/26/18
to lav...@googlegroups.com
Received and noted. Thanks!

Best,
Chuding


Edward Rigdon <edward...@gmail.com> 于2018年11月27日周二 上午8:12写道:
Reply all
Reply to author
Forward
0 new messages