qgraph.lavaan {qgraph} | R Documentation |
This functions uses a "lavaan" object from the lavaan
package (Rosseel, 2011) and outputs a multi-page pdf file containing path diagram, graphs of the parameter estimates and graphs of the implied and observed covariance and correlation matrices.
qgraph.lavaan( fit, ..., layout="circle", groups=NULL, vsize.man=3, vsize.lat=6, filename="qgraph", filetype="pdf", residuals=TRUE, include=1:12, curve=0, residSize=0.2, onefile=TRUE, width=12, height=8, titles=TRUE)
fit |
A |
... |
arguments passed to |
layout |
The layout used for the path diagram. Can be "tree", "spring", "circle" and "springtree" |
groups |
An optional list containing the measurement model, see |
vsize.man |
Size of the manifest variables in the path diagram |
vsize.lat |
Size of the latent variables in the path diagram |
filename |
Name of the file (will be extended with the filetype) |
filetype |
The filetype to be used. Can be "pdf" to make a pdf (default) or anything else to plot in R. More filetypes will be supported in a future version. |
residuals |
Omitting residuals is currently not supported for qgraph.lavaan, leave this to TRUE |
include |
A vector indicating which panels should be included in the output |
curve |
Numerical value indicating the curve of edges that are on the same level in the "tree" layout, See details. This represent an offset from the middle of the straight edge through where the curved edge must be drawn. 0 indicates no curve, and any other value indicates a curve of that strength. Defaults to 0.2 |
residSize |
Size of the residual arrows |
onefile |
Logical indicating if a multi-page pdf should be produced. If FALSE each plot will be a new pdf. Use this only with panels=1 and filename="(Arbitrary name)%03d". |
width |
Width of each panel, in inches |
height |
Height of each panel, in inches |
titles |
Logical indicating if titles should be printed |
This function uses a "lavaan"
object and outputs a multi-page pdf file.
The function reads the 'lavaan' object and creates a residual variable for each variable present
in the model. Layout options include a tree-layout (layout="tree") in which each variable is
placed as a node on one of four vertical levels. At the bottom are the residuals of the
manifest variables placed, Above that the manifest variables, above that the latent variables
and at the top the residuals of the latent variables. The nodes are evenly spaced horizontally
in order of appearance in the model (residuals are placed at the same horizontal position of
their corresponding variable). So the order of specifying in the model defines the order of
placement in the path diagram. If the 'residuals' argument is FALSE then residuals are omitted
and this diagram will only contain two levels.
Alternatively the 'spring' layout can be used (layout="spring"). This will use the Fruchterman-reingold algorithm (Fruchterman & Reingold, 1991), which has been ported from the 'sna' package (Butts, 2010). This is a force-directed algorithm. It is best to use this in combination with residuals=FALSE. Another option is a circular layout (default), which is the same as the tree except that the levels are placed in inner circles rather than horizontal lines.
Names for variables used in the model specification are passed to the path diagram. To keep the model readable it is advised to limit these names to 3 characters.
This is the first isntallment of qgraph.sem
for the Lavaan package. This function will likely be changed a lot in future installments.
Sacha Epskamp (s.epskamp@uva.nl)
https://sites.google.com/site/qgraphproject
Carter T. Butts <buttsc@uci.edu> (2010). sna: Tools for Social Network Analysis. R package version 2.2-0. http://CRAN.R-project.org/package=sna
Yves Rosseel <Yves.Rosseel@UGent.be> (2011). lavaan: Latent Variable Analysis. R package version 0.4-7. http://CRAN.R-project.org/package=lavaan
Fruchterman, T. & Reingold, E. (1991). Graph drawing by force-directed placement. Software - Pract. Exp. 21, 1129?1164.
qgraph
qgraph.cfa
qgraph.sem
sem
## Not run: ## Example from lavaan::sem help file: require("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 + equal("dem60=~y2")*y6 + equal("dem60=~y3")*y7 + equal("dem60=~y4")*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) # Plot standardized model (numerical): qgraph.lavaan(fit,layout="tree",vsize.man=5,vsize.lat=10, filetype="",include=4,curve=-0.4,edge.label.cex=0.6) # Plot standardized model (graphical): qgraph.lavaan(fit,layout="tree",vsize.man=5,vsize.lat=10, filetype="",include=8,curve=-0.4,edge.label.cex=0.6) # Create output document: qgraph.lavaan(fit,layout="spring",vsize.man=5,vsize.lat=10, filename="lavaan") ## End(Not run)