FactorGraph {mgm} | R Documentation |
Draws a factor graph of a (time-varying) MGM
Description
Wrapper function around qgraph() that draws factor graphs for (time-varying) MGMs
Usage
FactorGraph(object, labels, PairwiseAsEdge = FALSE,
Nodewise = FALSE, DoNotPlot = FALSE,
FactorLabels = TRUE, colors, shapes,
shapeSizes = c(8, 4), estpoint = NULL,
negDashed = FALSE, ...)
Arguments
object |
The output object of |
labels |
A character vector of (variable) node labels. |
PairwiseAsEdge |
If |
Nodewise |
If |
DoNotPlot |
If |
FactorLabels |
If |
colors |
A character vector of colors for nodes and factors. The first color is for variable-nodes, the second for 2-way interactions, the third for 3-way interactions, etc. Defaults to |
shapes |
A character vector of shapes for for nodes and factors. The first shape is for variable-nodes, the second for 2-way interactions, the third for 3-way interactions, etc. Defaults to |
shapeSizes |
A numeric vector of length two indicating the size of shapes for nodes and factors. Defaults to |
estpoint |
An integer indicating the estimation point to display if the output object of a time-varying MGM is provided. |
negDashed |
If |
... |
Arguments passed to qgraph. |
Details
FactorGraph()
is a wrapper around qgraph()
from the qgraph package. Therefore all arguments of qgraph()
are available and can be provided as additional arguments.
To make time-varying factor graphs comparable across estimation points, the factor graph of each estimation point includes all factors that are estimated nonzero at least at one estimation point.
Value
Plots the factor graph and returns a list including the arguments used to plot the factor graph using qgraph().
Specifically, a list is returned including: graph
contains a weighted adjacency matrix of a (bipartide) factor graph. If p is the number of variables and E the number of interactions (factors) in the model, this matrix has dimensions (p+E) x (p+E). The factor graph is furter specified by the following objects: signs
is a matrix of the same dimensions as graph
that indicates the sign of each interaction, if defined (see pairwise
above). edgecolor
is a matrix with the same dimension as graph
that provides edge colors depending on the sign as above. order
is a (p+E) vector indicating the order of interaction. The first p entries are set to zero. qgraph
contains the qgraph object created while plotting.
Author(s)
Jonas Haslbeck <jonashaslbeck@gmail.com>
See Also
mgm()
, tvmgm()
, qgraph()
Examples
## Not run:
# Fit MGM with pairwise & threeway interactions to Autism Dataset
fit_k3 <- mgm(data = autism_data$data,
type = autism_data$type,
level = autism_data$lev,
k = 3,
overparameterize = TRUE,
lambdaSel = "EBIC",
lambdaGam = .5)
# List of estimated interactions
fit_k3$interactions$indicator
FactorGraph(object = fit_k3,
PairwiseAsEdge = FALSE,
DoNotPlot = FALSE,
labels = 1:7,
layout="circle")
# For more examples see https://github.com/jmbh/mgmDocumentation
## End(Not run)