Michael Friendly
2010-May-24 16:31 UTC
[R] [R-pkgs] New package: `lavaan' for latent variable analysis (including structural equation modeling)
Hi Yves lavaan looks like a very nice package. From the tutorial introduction I see you create path diagrams for some of the models you describe. How did you do this? I don't see a function for this in the package. I know there is a path.diagram function in the sem package that uses dot to draw the diagram, but I've always found the layouts from dot somewhat strange for path diagrams without a fair bit of tweaking. -Michael Yves Rosseel wrote:> Dear R-users, > > A new package called `lavaan' (for latent variable analysis) has been > uploaded to CRAN. The current version of lavaan (0.3-1) can be used for > path analysis, confirmatory factor analysis, structural equation > modeling, and growth curve modeling. > > More information can be found on the website: http://lavaan.org > > Some notable features of lavaan: > > - the 'lavaan model syntax' allows users to express their models in a > compact, elegant and useR-friendly way > > - lavaan is robust and reliable: there are no convergence problems and > numerical results are very close (if not identical) to the commercial > package Mplus > > - many different estimators are available: ML, GLS, WLS, robust ML using > Satorra-Bentler corrections, and FIML for data with missing values > > - full support for meanstructures and multiple groups > > - user friendly output including standardized solutions, fit measures, > modification indices and more > > To get a first impression of how the 'lavaan model syntax' looks like, > below is the full R code for fitting a SEM model: > > ## begin R Code ## > > library(lavaan) > > # The industrialization and Political Democracy Example > # Bollen (1989), page 332 > > model <- ' > # latent variable definitions > ind60 =~ x1 + x2 + x3 > dem60 =~ y1 + y2 + y3 + y4 > dem65 =~ y5 + y6 + y7 + y8 > > # regressions > dem60 ~ ind60 > dem65 ~ ind60 + dem60 > > # residual correlations > y1 ~~ y5 > y2 ~~ y4 + y6 > y3 ~~ y7 > y4 ~~ y8 > y6 ~~ y8 > ' > > fit <- sem(model, data=PoliticalDemocracy) > summary(fit, fit.measures=TRUE) > > ## end R code ## > > > Please feel free to contact me directly with questions and comments. > > Best, > > Yves Rosseel. > > >
Yves Rosseel
2010-May-24 16:58 UTC
[R] [R-pkgs] New package: `lavaan' for latent variable analysis (including structural equation modeling)
On 05/24/2010 06:31 PM, Michael Friendly wrote:> Hi Yves > > lavaan looks like a very nice package. From the tutorial introduction > I see you create path diagrams for some of the models you describe. > How did you do this? I don't see a function for this in the package. > > I know there is a path.diagram function in the sem package that uses > dot to draw the diagram, but I've always found the layouts from dot > somewhat strange for path diagrams without a fair bit of tweaking.There is currently no function in lavaan to automatically draw a path diagram. The path diagrams in the tutorial are handmade in latex, using the tikz/pgf environment. Best, Yves Rosseel.
Yves Rosseel
2010-May-25 07:31 UTC
[R] [R-pkgs] New package: `lavaan' for latent variable analysis (including structural equation modeling)
On 05/24/2010 09:53 PM, JLucke at ria.buffalo.edu wrote:> > Yves > Would it by to much to ask of you to supply a copy of your LaTeX for the > tikz/pgf? I would like to learn tikz/pgf and your pictures are > motivating examples. > JoeWhen I find the time, I will put the complete latex source of the tutorial on the webpage. But the tikz/pgf code for the second example is given below: %% this goes in the latex preamble \usepackage{tikz} \tikzstyle{ov}=[shape=rectangle, draw=black!80, minimum height=0.75cm, minimum width=1cm, thick] \tikzstyle{av}=[shape=rectangle, draw=black!80, fill=black!10, minimum height=1cm, minimum width=1cm, thick] \tikzstyle{lv}=[shape=circle,draw=black!80,thick,minimum width=1.5cm] %% this the tikz code for the SEM example \begin{center} \begin{tabular}{p{0.5\textwidth}p{0.4\textwidth}} \hline \begin{center} \begin{tikzpicture}[>=stealth,semithick,scale=0.6] \node[ov] (y1) at (0,0) {\code{y1}}; \node[ov] (y2) at (0,-1.4) {\code{y2}}; \node[ov] (y3) at (0,-2.8) {\code{y3}}; \node[ov] (y4) at (0,-4.2) {\code{y4}}; \node[ov] (y5) at (0,-5.6) {\code{y5}}; \node[ov] (y6) at (0,-7) {\code{y6}}; \node[ov] (y7) at (0,-8.4) {\code{y7}}; \node[ov] (y8) at (0,-9.8) {\code{y8}}; \node[ov] (x1) at ( 6,0) {\code{x1}}; \node[ov] (x2) at ( 8,0) {\code{x2}}; \node[ov] (x3) at (10,0) {\code{x3}}; \node[lv] (f1) at (4, -2.8) {\code{dem60}}; \node[lv] (f2) at (4, -7.6) {\code{dem65}}; \node[lv] (f3) at (8, -2.8) {\code{ind60}}; \path[->] (f1) edge node[above=0.08cm,scale=0.8,pos=0.7] {} (y1.east); \path[->] (f1) edge node[above=0.08cm,scale=0.8,pos=0.7] {} (y2.east); \path[->] (f1) edge node[above=0.08cm,scale=0.8,pos=0.7] {} (y3.east); \path[->] (f1) edge node[above=0.08cm,scale=0.8,pos=0.7] {} (y4.east); \path[->] (f2) edge node[above=0.08cm,scale=0.8,pos=0.7] {} (y5.east); \path[->] (f2) edge node[above=0.08cm,scale=0.8,pos=0.7] {} (y6.east); \path[->] (f2) edge node[above=0.08cm,scale=0.8,pos=0.7] {} (y7.east); \path[->] (f2) edge node[above=0.08cm,scale=0.8,pos=0.7] {} (y8.east); \path[->] (f3) edge node[above=0.08cm,scale=0.8,pos=0.7] {} (x1.south); \path[->] (f3) edge node[above=0.08cm,scale=0.8,pos=0.7] {} (x2.south); \path[->] (f3) edge node[above=0.08cm,scale=0.8,pos=0.7] {} (x3.south); \path[->] (f1) edge node[above=0.08cm,scale=0.8,pos=0.7] {} (f2); \path[->] (f3) edge node[above=0.08cm,scale=0.8,pos=0.7] {} (f1.east); \path[->] (f3) edge node[above=0.08cm,scale=0.8,pos=0.7] {} (f2.north east); \path[<->] (y1.west) edge [bend right=45] node[left,scale=0.8] {} (y5.west); \path[<->] (y2.west) edge [bend right=45] node[left,scale=0.8] {} (y6.west); \path[<->] (y3.west) edge [bend right=45] node[left,scale=0.8] {} (y7.west); \path[<->] (y4.west) edge [bend right=45] node[left,scale=0.8] {} (y8.west); \path[<->] (y2.south west) edge [bend right=45] node[left,scale=0.8] {} (y4.north west); \path[<->] (y6.south west) edge [bend right=45] node[left,scale=0.8] {} (y8.north west); \end{tikzpicture} \end{center} -- Yves Rosseel -- http://www.da.ugent.be Department of Data Analysis, Ghent University Henri Dunantlaan 1, B-9000 Gent, Belgium
Reasonably Related Threads
- New package: `lavaan' for latent variable analysis (including structural equation modeling)
- New package: `lavaan' for latent variable analysis (including structural equation modeling)
- lavaan version 0.4-8
- lavaan version 0.4-8
- lavaan: how to analyse residuals of a latent variable