pathDiagram creates a description of the path diagram
for a structural-equation-model or SEM-specification object to be processed by the
graph-drawing program dot.
a structural-equation-model or SEM-specification object produced by sem,
or, respectively, specifyEquations, specifyModel, or cfa.
...
arguments passed down, e.g., from the semmod method to the sem method.
file
a file name, by default "pathDiagram",
given without an extension, to which to write the dot description of the
path diagram if output.type"graphics" or "dot" is selected, and for the
graphics output file (with appropriate extension) if "graphics" output is selected, in which case
a ".dot" file and a graphics file of type specified by the graphics.fmt argument (below);
file may include a path specification.
style
"ram" (the default) for a RAM path diagram including self-directed double-headed arrows
representing variances, including error variances; or "traditional" for a path diagram
including nodes representing error variables.
output.type
if "html" (the default), the path diagram will open in the user"s default
web browser; if "dot", a file containing dot commands will be written; if "graphics",
both .dot and graphics files will be written.
graphics.fmt
a graphics format recognized by the dot program; the default is "pdf";
graphics.fmt is also used for the extension of the graphics file that is created.
dot.options
options to be passed to the dot program, given as a character string.
size
the size of the graph, in inches.
node.font
font name and point-size for printing variable names.
edge.font
font name and point-size for printing arrow names or values.
digits
number of digits after the decimal point (default, 2) to which
to round parameter estimates.
rank.direction
draw graph left-to-right, "LR", the default,
or top-to-bottom, "TB".
min.rank
a character string listing names of variables to be assigned
minimum rank (order) in the graph; the names should be separated by commas.
max.rank
a character string listing names of variables to be assigned
maximum rank in the graph; the names should be separated by commas.
same.rank
a character string or vector of character strings of variables
to be assigned equivalent rank in the graph; names in each string should be
separated by commas.
variables
variable names; defaults to the variable names in model.
If specified, the variable names should be in the same order as in model.
var.labels
a character vector with labels to be used
in lieu of (some of) the variables names, for greater flexibility
in labelling nodes in the graph — e.g., the labels can be created with the math
function. The elements of the vector must have names corresponding to variables in the model.
parameters
parameter names; defaults to the parameter names in
model. If specified, the parameter names should be in the same order
as in model.
par.labels
a character vector with labels to be used
in lieu of (some of) the parameter names, for greater flexibility
in labelling edges in the graph — e.g., the labels can be created with the math
function. The elements of the vector must have names corresponding to parameters in the model.
ignore.double
if TRUE, the default, double-headed arrows, representing
variances and covariances, are not graphed.
ignore.self
if TRUE (the default is FALSE), and ignore.double=FALSE,
self-directed double-headed arrows representing error variances are suppressed; note that
if ignore.double=TRUE, all double-headed arrows, including self-directed arrows,
are suppressed.
error.nodes
if TRUE (the default) and style="traditional", show the nodes
representing error variables.
edge.labels
"names" to label arrows with parameter names;
"values" to label arrows with parameter estimates, or "both".
edge.colors
two-element character vector giving colors of positive
and negative arrows respectively; the default is c("black", "black").
edge.weight
if "proportional" (the default is "fixed"), the thickness of
edges is proportional to the absolute size of the corresponding parameter estimate;
this is generally sensible only if standardize=TRUE.
node.colors
a two- or three-element character vector giving colors of nodes representing
exogenous, endogenous, and error variables (for traditional path diagrams) consecutively;
the default is "transparent" for all three; if a two colors are given, error variables
are colored as exogenous (the first color.
standardize
if TRUE, display standardized coefficients; default is FALSE.
obs.variables
a character vector with the names of the observed variables in the model.
text
a character string or vector of character strings to be translated into node or edge label symbols.
If a vector of character strings is supplied, then the elements of the vector should be named with the
corresponding variable (node) or parameter (edge) name.
html.only
If TRUE (the default is FALSE), the
character strings in text are to be treated as an HTML character codes, in
which case the prefix "#" and suffix ";" are appended to each. Otherwise, text should
only contain the names of lowercase or uppercase Greek letters, such as "alpha" or "Alpha".
The full set of Greek letters recognized is given in the file Greek.txt in the package's
etc subdirectory – or type sem:::Greek at the R command prompt.
In either case, the symbols may be followed by numeric subscripts in curly braces consisting of numerals
(e.g., "beta_{12}"),
and/or numeric superscripts (e.g., "sigma^{2}",
"sigma_{1}^{2}"). Depending upon your OS, subscripts and superscripts may only work properly with HTML output
from pathDiagram, not with graphics output produced by dot.
hat
If TRUE (the default is FALSE), a hat (circumflex) is placed over the
symbols in text; this feature doesn't produce a visually appealing result.
Details
pathDiagram creates a description of the path diagram
for a structural-equation-model or SEM-specification object to be processed by the
graph-drawing program dot, which can be called
automatically; see Koutsofios and North (2002)
and http://www.graphviz.org/. To obtain graphics output
directly, the dot program must be on the system search path.
Alternatively, HTML output can be created in a web browser without an independent installation
of dot using facilities in the DiagrammeR package.
The math function can be used to create node (variable) and edge (arrow) labels with
symbols such as Greek letters, subscripts, and superscripts.
The semmod method of pathDiagram sets up a call to the sem method.
The various
arguments to pathDiagram can be used to customize the diagram, but if there are too many constraints
on node placement, dot may fail to produce a graph or may produce a distorted graph.
pathDiagram can create both RAM-style diagrams, in which variances are represented as self-directed
arrows, and traditional path diagrams, in which error variables appear explicitly as nodes. As is conventional,
latent variables (including error variables) are represented as ellipses and observed variables as
rectangles; double-headed arrows represent covariances (and in RAM diagrams, variances) and single-headed
arrows represent structural coefficients.
Value
pathDiagram invisibly returns a character vector containing dot commands.
math returns a character vector containing suitable HTML markup.