% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plot.gg_udependent.R
\name{plot.gg_udependent}
\alias{plot.gg_udependent}
\title{Plot a \code{gg_udependent} variable dependency graph}
\usage{
\method{plot}{gg_udependent}(x, layout = "fr", ...)
}
\arguments{
\item{x}{A \code{gg_udependent} object from \code{\link{gg_udependent}}.}

\item{layout}{Character; the igraph/ggraph layout algorithm.  Common
choices are \code{"fr"} (Fruchterman-Reingold, the default),
\code{"kk"} (Kamada-Kawai), \code{"stress"}, \code{"circle"}, and
\code{"grid"}.}

\item{...}{Not currently used.}
}
\value{
A \code{ggplot} object (built via ggraph).
}
\description{
Draws the dependency graph held in a \code{gg_udependent} object as a
ggraph network.  Node colour marks whether a variable made the signal
set, and the width and opacity of an edge tell you how strong the
dependency between its two variables is.
}
\details{
This plot needs the \pkg{ggraph} package, which is in \code{Suggests}
rather than installed for you.  If it is missing, run
\code{install.packages("ggraph")}.

A signal variable (\code{selected = TRUE}) gets a blue node
(\code{#4e8fcd}); the rest are grey (\code{#888888}).  Node size grows
with degree.  Edge width and opacity both grow with the raw dependency
weight \code{I[i,j]}.
}
\section{Reading the network}{

Each node is a variable; each edge is a cross-variable dependency
that cleared the threshold passed to \code{gg_udependent}. The
Fruchterman-Reingold layout (the default) places mutually connected
variables near each other, so the picture tends to show hubs and
the clusters around them rather than a tidy ring. The eye usually
goes first to the largest blue node: a variable that is both in
the signal set and connects to many others is a hub of the
dependency structure. Edges with wider, more opaque strokes are
stronger dependencies; thin, faint edges sit near the threshold and
are the ones that would disappear first if you raised it.

Grey, low-degree nodes are the ones UVarPro thinks are not
contributing much to the structure. (Truly isolated nodes are
dropped by \code{gg_udependent()} before the graph is drawn; what you
see is the connected component.) A cluster of mutually
connected variables is worth checking for redundancy; they may be
several views of the same underlying quantity.
}

\section{What this tells you}{

Use the figure to pick a working set of variables: the hubs and
their immediate neighbours are the candidates UVarPro flags as
carrying structure. If a cluster of high-degree variables looks
like it might be measuring the same thing, that is a cue to look at
their pairwise correlations or fit them as a block rather than
individually. The threshold and layout are recorded in the caption
so a different choice is easy to spot in a later figure.
}

\examples{
\donttest{
if (requireNamespace("ggraph", quietly = TRUE)) {
  set.seed(42)
  uv <- varPro::uvarpro(iris[, -5], ntree = 50)
  plot(gg_udependent(uv))
}
}

}
\seealso{
\code{\link{gg_udependent}}
}
