UG: Defining an undirected graph (UG)

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

A simple way to define an undirected graph by means of a single model formula.

Usage

1
UG(f)

Arguments

f

a single model formula without response

Details

The undirected graph G = (V, E) is defined by a set of nodes V and a set of pairs E. The set of pairs is defined by the set of interactions in the formula. Interactions define complete subgraphs (not necessarily maximal) of the UG. The best way is to specify interactions that match the cliques of the undirected graph. This is the standard way to define graphical models for contingency tables. Remember that some hierarchical models are not graphical, but they imply the same graph.

The function returns the edge matrix of the graph, i.e. a square Boolean matrix of order equal to the number of nodes of the graph and a one in position (i,j) if there is an arrow from j to i and zero otherwise. By default this matrix has ones along the main diagonal. For UGs this matrix is symmetric. The dimnames of the edge matrix are the nodes of the UG.

Value

a Boolean matrix with dimnames, the adjacency matrix of the undirected graph.

Author(s)

Giovanni M. Marchetti

References

Lauritzen, S. (1996). Graphical models. Oxford: Clarendon Press.

See Also

fitConGraph, fitCovGraph, DAG

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## X independent of Y given Z
UG(~ X*Z + Y*Z)

# The saturated model
UG(~ X*Y*Z)

## The model without three-way interactions has the same graph
UG(~ X*Y + Y*Z + Z*X)
UG(~ (X + Y + Z)^2)

## Butterfly model defined from the cliques
UG(~ mec*vec*alg + alg*ana*sta)

## Some isolated nodes
UG(~x*y*z + a + b) 

Example output

Loading required package: igraph

Attaching package: 'igraph'

The following objects are masked from 'package:stats':

    decompose, spectrum

The following object is masked from 'package:base':

    union


Attaching package: 'ggm'

The following object is masked from 'package:igraph':

    pa

  X Z Y
X 0 1 0
Z 1 0 1
Y 0 1 0
  X Y Z
X 0 1 1
Y 1 0 1
Z 1 1 0
  X Y Z
X 0 1 1
Y 1 0 1
Z 1 1 0
  X Y Z
X 0 1 1
Y 1 0 1
Z 1 1 0
    mec vec alg ana sta
mec   0   1   1   0   0
vec   1   0   1   0   0
alg   1   1   0   1   1
ana   0   0   1   0   1
sta   0   0   1   1   0
  x y z a b
x 0 1 1 0 0
y 1 0 1 0 0
z 1 1 0 0 0
a 0 0 0 0 0
b 0 0 0 0 0

ggm documentation built on March 26, 2020, 7:49 p.m.

Related to UG in ggm...