Title: | Identifiability of Linear Structural Equation Models |
---|---|
Description: | Provides routines to check identifiability or non-identifiability of linear structural equation models as described in Drton, Foygel, and Sullivant (2011) <doi:10.1214/10-AOS859>, Foygel, Draisma, and Drton (2012) <doi:10.1214/12-AOS1012>, and other works. The routines are based on the graphical representation of structural equation models. |
Authors: | Rina Foygel Barber [aut], Mathias Drton [aut], Luca Weihs [aut], Nils Sturma [cre, aut] |
Maintainer: | Nils Sturma <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.4.1 |
Built: | 2025-02-14 05:12:05 UTC |
Source: | https://github.com/lucaweihs/semid |
SEMID provides a number of methods for testing the global/generic identifiability of mixed graphs and latent-factor graphs.
The only functions you're likely to need from SEMID are
semID
and lfhtcID
. A complete description of all package features, along
with examples, can be found at https://github.com/Lucaweihs/SEMID.
### # Checking the generic identifiability of parameters in a mixed graph. ### # Mixed graphs are specified by their directed adjacency matrix L and # bidirected adjacency matrix O. L = t(matrix( c(0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0), 5, 5)) O = t(matrix( c(0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), 5, 5)); O=O+t(O) # Create a mixed graph object graph = MixedGraph(L, O) # We can plot what this mixed graph looks like, blue edges are directed # red edges are bidirected. plot(graph) # Without using decomposition techniques we can't identify all nodes # just using the half-trek criterion htcID(graph, tianDecompose = FALSE) # The edgewiseTSID function can show that all edges are generically # identifiable without proprocessing with decomposition techniques edgewiseTSID(graph, tianDecompose = FALSE) # The above shows that all edges in the graph are generically identifiable. # See the help of edgewiseTSID to find out more information about what # else is returned by edgewiseTSID. ### # Checking generic parameter identifiability using the generalGenericID # function ### L = t(matrix( c(0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0), 5, 5)) O = t(matrix( c(0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), 5, 5)); O=O+t(O) # Create a mixed graph object graph = MixedGraph(L, O) # Now lets define an "identification step" function corresponding to # using the edgewise identification algorithm but with subsets # controlled by 1. restrictedEdgewiseIdentifyStep <- function(mixedGraph, unsolvedParents, solvedParents, identifier) { return(edgewiseIdentifyStep(mixedGraph, unsolvedParents, solvedParents, identifier, subsetSizeControl = 1)) } # Now we run an identification algorithm that iterates between the # htc and the "restricted" edgewise identification algorithm generalGenericID(graph, list(htcIdentifyStep, restrictedEdgewiseIdentifyStep), tianDecompose = FALSE) # We can do better (fewer unsolved parents) if we don't restrict the edgewise # identifier algorithm as much generalGenericID(graph, list(htcIdentifyStep, edgewiseIdentifyStep), tianDecompose = FALSE) ### # Checking the generic identifiability of parameters in a latent-factor graph. ### # Latent digraphs are specified by their directed adjacency matrix L library(SEMID) L = matrix(c(0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0), 6, 6, byrow=TRUE) observedNodes = seq(1,5) latentNodes = c(6) # Create the latent digraph object corresponding to L g = LatentDigraph(L, observedNodes, latentNodes) # Plot latent digraph plot(g) # We can identify all nodes by the latent-factor half-trek criterion lfhtcID(g)
### # Checking the generic identifiability of parameters in a mixed graph. ### # Mixed graphs are specified by their directed adjacency matrix L and # bidirected adjacency matrix O. L = t(matrix( c(0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0), 5, 5)) O = t(matrix( c(0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), 5, 5)); O=O+t(O) # Create a mixed graph object graph = MixedGraph(L, O) # We can plot what this mixed graph looks like, blue edges are directed # red edges are bidirected. plot(graph) # Without using decomposition techniques we can't identify all nodes # just using the half-trek criterion htcID(graph, tianDecompose = FALSE) # The edgewiseTSID function can show that all edges are generically # identifiable without proprocessing with decomposition techniques edgewiseTSID(graph, tianDecompose = FALSE) # The above shows that all edges in the graph are generically identifiable. # See the help of edgewiseTSID to find out more information about what # else is returned by edgewiseTSID. ### # Checking generic parameter identifiability using the generalGenericID # function ### L = t(matrix( c(0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0), 5, 5)) O = t(matrix( c(0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), 5, 5)); O=O+t(O) # Create a mixed graph object graph = MixedGraph(L, O) # Now lets define an "identification step" function corresponding to # using the edgewise identification algorithm but with subsets # controlled by 1. restrictedEdgewiseIdentifyStep <- function(mixedGraph, unsolvedParents, solvedParents, identifier) { return(edgewiseIdentifyStep(mixedGraph, unsolvedParents, solvedParents, identifier, subsetSizeControl = 1)) } # Now we run an identification algorithm that iterates between the # htc and the "restricted" edgewise identification algorithm generalGenericID(graph, list(htcIdentifyStep, restrictedEdgewiseIdentifyStep), tianDecompose = FALSE) # We can do better (fewer unsolved parents) if we don't restrict the edgewise # identifier algorithm as much generalGenericID(graph, list(htcIdentifyStep, edgewiseIdentifyStep), tianDecompose = FALSE) ### # Checking the generic identifiability of parameters in a latent-factor graph. ### # Latent digraphs are specified by their directed adjacency matrix L library(SEMID) L = matrix(c(0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0), 6, 6, byrow=TRUE) observedNodes = seq(1,5) latentNodes = c(6) # Create the latent digraph object corresponding to L g = LatentDigraph(L, observedNodes, latentNodes) # Plot latent digraph plot(g) # We can identify all nodes by the latent-factor half-trek criterion lfhtcID(g)
Finds all the ancestors of a collection of nodes. These ancestors DO include the nodes themselves (every node is considered an ancestor of itself).
ancestors(this, nodes, ...) ## S3 method for class 'LatentDigraphFixedOrder' ancestors(this, nodes, includeObserved = T, includeLatents = T, ...) ## S3 method for class 'LatentDigraph' ancestors(this, nodes, includeObserved = T, includeLatents = T, ...) ## S3 method for class 'MixedGraph' ancestors(this, nodes, ...)
ancestors(this, nodes, ...) ## S3 method for class 'LatentDigraphFixedOrder' ancestors(this, nodes, includeObserved = T, includeLatents = T, ...) ## S3 method for class 'LatentDigraph' ancestors(this, nodes, includeObserved = T, includeLatents = T, ...) ## S3 method for class 'MixedGraph' ancestors(this, nodes, ...)
this |
the graph object |
nodes |
the nodes from which to find all ancestors |
... |
ignored. |
includeObserved |
if TRUE includes observed nodes in the returned set. |
includeLatents |
if TRUE includes latent nodes in the returned set. |
the ancestors of the nodes in the observed part of the graph.
Uses the an identification criterion of Drton and Weihs (2015); this version
of the algorithm is somewhat different from Drton and Weihs (2015) in that it
also works on cyclic graphs. The original version of the algorithm can be
found in the function graphID.ancestralID
.
ancestralID(mixedGraph, tianDecompose = T)
ancestralID(mixedGraph, tianDecompose = T)
mixedGraph |
a |
tianDecompose |
TRUE or FALSE determining whether or not the Tian decomposition should be used before running the current generic identification algorithm. In general letting this be TRUE will make the algorithm faster and more powerful. |
see the return of generalGenericID
.
A function that does one step through all the nodes in a mixed graph and tries to determine if directed edge coefficients are generically identifiable by leveraging decomposition by ancestral subsets. See Algorithm 1 of Drton and Weihs (2015); this version of the algorithm is somewhat different from Drton and Weihs (2015) in that it also works on cyclic graphs.
ancestralIdentifyStep(mixedGraph, unsolvedParents, solvedParents, identifier)
ancestralIdentifyStep(mixedGraph, unsolvedParents, solvedParents, identifier)
mixedGraph |
a |
unsolvedParents |
a list whose ith index is a vector of all the parents j of i in G which for which the edge j->i is not yet known to be generically identifiable. |
solvedParents |
the complement of |
identifier |
an identification function that must produce the
identifications corresponding to those in solved parents. That is
such that if j is in |
a list with four components:
identifiedEdges
a matrix rx2 matrix where r is the number
of edges that where identified by this function call and
identifiedEdges[i,1] -> identifiedEdges[i,2]
was the ith edge
identified
unsolvedParents
as the input argument but updated with any newly identified edges
solvedParents
as the input argument but updated with any newly identified edges
identifier
as the input argument but updated with any newly identified edges
Drton, M. and Weihs, L. (2015) Generic Identifiability of Linear Structural Equation Models by Ancestor Decomposition. arXiv 1504.02992
Returns induced subgraphs of connected bidirected components with more than 1 node.
bidirectedComponents(graph)
bidirectedComponents(graph)
graph |
a |
list, where each object is a MixedGraph with at least two nodes.
Returns all children of the collection (does not necessarily include the input nodes themselves unless they are parents of one another).
children(this, nodes, ...) ## S3 method for class 'LatentDigraphFixedOrder' children(this, nodes, includeObserved = T, includeLatents = T, ...) ## S3 method for class 'LatentDigraph' children(this, nodes, includeObserved = T, includeLatents = T, ...) ## S3 method for class 'MixedGraph' children(this, nodes, ...)
children(this, nodes, ...) ## S3 method for class 'LatentDigraphFixedOrder' children(this, nodes, includeObserved = T, includeLatents = T, ...) ## S3 method for class 'LatentDigraph' children(this, nodes, includeObserved = T, includeLatents = T, ...) ## S3 method for class 'MixedGraph' children(this, nodes, ...)
this |
the graph object. |
nodes |
nodes the nodes of which to find the children |
... |
ignored. |
includeObserved |
if TRUE includes observed nodes in the returned set. |
includeLatents |
if TRUE includes latent nodes in the returned set. |
the observed children
A helper function for ancestralIdentifyStep
, creates an identifier function
based on its given parameters. This created identifier function will
identify the directed edges from 'targets' to 'node.'
createAncestralIdentifier( idFunc, sources, targets, node, htrSources, ancestralSubset, cComponent )
createAncestralIdentifier( idFunc, sources, targets, node, htrSources, ancestralSubset, cComponent )
idFunc |
identification of edge coefficients often requires that other edge coefficients already be identified. This argument should be a function that produces all such identifications. The newly created identifier function will return these identifications along with its own. |
sources |
the sources of the half-trek system. |
targets |
the targets of the half-trek system (these should be the
parents of |
node |
the node for which all incoming edges are to be identified (the tails of which are targets). |
htrSources |
the nodes in sources which are half-trek reachable from
|
ancestralSubset |
an ancestral subset of the graph containing |
cComponent |
a list corresponding to the connected component containing |
an identification function
A helper function for edgewiseIdentifyStep
, creates an
identifier function based on its given parameters. This created identifier
function will identify the directed edges from 'targets' to 'node.'
createEdgewiseIdentifier( idFunc, sources, targets, node, solvedNodeParents, sourceParentsToRemove )
createEdgewiseIdentifier( idFunc, sources, targets, node, solvedNodeParents, sourceParentsToRemove )
idFunc |
identification of edge coefficients often requires that other edge coefficients already be identified. This argument should be a function that produces all such identifications. The newly created identifier function will return these identifications along with its own. |
sources |
the sources of the half-trek system. |
targets |
the targets of the half-trek system (these should be the
parents of |
node |
the node for which all incoming edges are to be identified (the tails of which are targets). |
solvedNodeParents |
the parents of node that have been solved |
sourceParentsToRemove |
a list of the parents of the sources that should have their edge to their respect source removed. |
an identification function
A helper function for htcIdentifyStep
, creates an identifier
function based on its given parameters. This created identifier function will
identify the directed edges from 'targets' to 'node.'
createHtcIdentifier(idFunc, sources, targets, node, htrSources)
createHtcIdentifier(idFunc, sources, targets, node, htrSources)
idFunc |
identification of edge coefficients often requires that other edge coefficients already be identified. This argument should be a function that produces all such identifications. The newly created identifier function will return these identifications along with its own. |
sources |
the sources of the half-trek system. |
targets |
the targets of the half-trek system (these should be the
parents of |
node |
the node for which all incoming edges are to be identified (the tails of which are targets). |
htrSources |
the nodes in sources which are half-trek reachable from
|
an identification function
Foygel, R., Draisma, J., and Drton, M. (2012) Half-trek criterion for generic identifiability of linear structural equation models. Ann. Statist. 40(3): 1682-1713.
Identifiers are functions that take as input a covariance matrix Sigma
corresponding to some mixed graph G
and, from that covariance matrix,
identify some subset of the coefficients in the mixed graph G
. This function
takes as input the matrices, L
and O
, defining G
and creates an identifier
that does not identify any of the coefficients of G
. This is useful as a
base case when building more complex identification functions.
createIdentifierBaseCase(L, O)
createIdentifierBaseCase(L, O)
L |
Adjacency matrix for the directed part of the path diagram/mixed graph; an edge pointing from i to j is encoded as L[i,j]=1 and the lack of an edge between i and j is encoded as L[i,j]=0. There should be no directed self loops, i.e. no i such that L[i,i]=1. |
O |
Adjacency matrix for the bidirected part of the path diagram/mixed graph. Edges are encoded as for the L parameter. Again there should be no self loops. Also this matrix will be coerced to be symmetric so it is only necessary to specify an edge once, i.e. if O[i,j]=1 you may, but are not required to, also have O[j,i]=1. |
a function that takes as input a covariance matrix compatible with
the mixed graph defined by L
/O
and returns a list with two
named components:
Lambda
a matrix equal to L
but with NA
values instead of 1
s
Omega
a matrix equal to O
but with NA
values instead of 1
s
When building more complex identifiers these NAs will be replaced by the value that can be identified from Sigma.
A helper function for lfhtcIdentifyStep
, creates an identifier
function based on its given parameters. This created identifier function will
identify the directed edges from 'targets' to 'node.'
createLFHtcIdentifier(idFunc, v, Y, Z, parents, reachableY)
createLFHtcIdentifier(idFunc, v, Y, Z, parents, reachableY)
idFunc |
identification of edge coefficients often requires that other edge coefficients already be identified. This argument should be a function that produces all such identifications. The newly created identifier function will return these identifications along with its own. |
v |
the node for which all incoming edges are to be identified (the tails of which are targets). |
Y |
the sources of the latent-factor half-trek system. |
Z |
the nodes that are reached from Y via an latent-factor half-trek of the form
|
parents |
the parents of node v. |
reachableY |
the nodes in Y which are latent-factor half-trek reachable from Z or v by avoiding the nodes in L. All incoming edges to these nodes should be identified by idFunc the newly created identification function to work. |
an identification function
Barber, R. F., Drton, M., Sturma, N., and Weihs L. (2022). Half-Trek Criterion for Identifiability of Latent Variable Models. arXiv preprint arXiv:2201.04457
Identifiers are functions that take as input a covariance matrix Sigma
corresponding to some latent digraph G
and, from that covariance matrix,
identify some subset of the coefficients coresponding to the direct causal effects
in the latent digraph G
. This function
takes as input the digraph G
and creates an identifier
that does not identify any of the direct causal effects. This is useful as a
base case when building more complex identification functions.
createLFIdentifierBaseCase(graph)
createLFIdentifierBaseCase(graph)
graph |
a |
a function that takes as input a covariance matrix compatible with
the latent digraph defined by L
and returns a list with two
named components:
Lambda
a matrix equal to the observed part of graph$L()
but with NA
values
instead of 1s
Omega
a matrix equal to graph$O()
but with NA
values for coefficients
not equal to zero.
When building more complex identifiers these NAs will be replaced
by the value that can be identified from the covariance matrix corresponding to G
.
Creates an identifier function that assumes that all directed edges have already been identified and then is able to identify all bidirected edges simultaneously.
createSimpleBiDirIdentifier(idFunc)
createSimpleBiDirIdentifier(idFunc)
idFunc |
an identifier function that identifies all directed edges |
a new identifier function that identifies everything.
Helper function to create a flow graph.
createTrekFlowGraph(this, ...) ## S3 method for class 'LatentDigraphFixedOrder' createTrekFlowGraph(this, ...)
createTrekFlowGraph(this, ...) ## S3 method for class 'LatentDigraphFixedOrder' createTrekFlowGraph(this, ...)
this |
the graph object |
... |
ignored |
A helper function for trekSeparationIdentifyStep
, creates an
identifier function based on its given parameters. This created identifier
function will identify the directed edge from 'parent' to 'node.'
createTrekSeparationIdentifier( idFunc, sources, targets, node, parent, solvedParents )
createTrekSeparationIdentifier( idFunc, sources, targets, node, parent, solvedParents )
idFunc |
identification of edge coefficients often requires that other edge coefficients already be identified. This argument should be a function that produces all such identifications. The newly created identifier function will return these identifications along with its own. |
sources |
the sources of the half-trek system. |
targets |
the targets of the half-trek system (these should be the
parents of |
node |
the node for which all incoming edges are to be identified (the tails of which are targets). |
parent |
the parent of node for which the edge node -> parent should be generically identified. |
solvedParents |
the parents of node that have been solved |
an identification function
Helper function to create a graph encoding trek reachable relationships.
createTrGraph(this, ...) ## S3 method for class 'LatentDigraphFixedOrder' createTrGraph(this, ...)
createTrGraph(this, ...) ## S3 method for class 'LatentDigraphFixedOrder' createTrGraph(this, ...)
this |
the graph object |
... |
ignored |
Finds all descendants of a collection of nodes, this DOES include the nodes themselves (every node is considered a descendant of itself).
descendants(this, nodes, ...) ## S3 method for class 'LatentDigraphFixedOrder' descendants(this, nodes, includeObserved = T, includeLatents = T, ...) ## S3 method for class 'LatentDigraph' descendants(this, nodes, includeObserved = T, includeLatents = T, ...) ## S3 method for class 'MixedGraph' descendants(this, nodes, ...)
descendants(this, nodes, ...) ## S3 method for class 'LatentDigraphFixedOrder' descendants(this, nodes, includeObserved = T, includeLatents = T, ...) ## S3 method for class 'LatentDigraph' descendants(this, nodes, includeObserved = T, includeLatents = T, ...) ## S3 method for class 'MixedGraph' descendants(this, nodes, ...)
this |
the graph object |
nodes |
the nodes from which to get the descendants. |
... |
ignored. |
includeObserved |
if TRUE includes observed nodes in the returned set. |
includeLatents |
if TRUE includes latent nodes in the returned set. |
Uses the edgewise identification criterion of Weihs, Robeva, Robinson, et al. (2017) to determine which edges in a mixed graph are generically identifiable.
edgewiseID(mixedGraph, tianDecompose = T, subsetSizeControl = 3)
edgewiseID(mixedGraph, tianDecompose = T, subsetSizeControl = 3)
mixedGraph |
a |
tianDecompose |
TRUE or FALSE determining whether or not the Tian decomposition should be used before running the current generic identification algorithm. In general letting this be TRUE will make the algorithm faster and more powerful. |
subsetSizeControl |
a positive integer (Inf allowed) which controls the size of edgesets searched in the edgewiseID algorithm. Suppose, for example, this has value 3. Then if a node i has n parents, this will restrict the algorithm to only look at subsets of the parents of size 1,2,3 and n-2, n-1, n. Making this parameter smaller means the algorithm will be faster but less exhaustive (and hence less powerful). |
see the return of generalGenericID
.
A function that does one step through all the nodes in a mixed graph and tries to identify new edge coefficients using the existence of half-trek systems as described in Weihs, Robeva, Robinson, et al. (2017).
edgewiseIdentifyStep( mixedGraph, unsolvedParents, solvedParents, identifier, subsetSizeControl = Inf )
edgewiseIdentifyStep( mixedGraph, unsolvedParents, solvedParents, identifier, subsetSizeControl = Inf )
mixedGraph |
a |
unsolvedParents |
a list whose ith index is a vector of all the parents j of i in G which for which the edge j->i is not yet known to be generically identifiable. |
solvedParents |
the complement of |
identifier |
an identification function that must produce the
identifications corresponding to those in solved parents. That is
such that if j is in |
subsetSizeControl |
a positive integer (Inf allowed) which controls the size of edgesets searched in the edgewiseID algorithm. Suppose, for example, this has value 3. Then if a node i has n parents, this will restrict the algorithm to only look at subsets of the parents of size 1,2,3 and n-2, n-1, n. Making this parameter smaller means the algorithm will be faster but less exhaustive (and hence less powerful). |
see the return of htcIdentifyStep
.
Uses the edgewise+TS identification criterion of Weihs, Robeva, Robinson, et al. (2017) to determine which edges in a mixed graph are generically identifiable. In particular this algorithm iterates between the half-trek, edgewise, and trek-separation identification algorithms in an attempt to identify as many edges as possible, this may be very slow.
edgewiseTSID( mixedGraph, tianDecompose = T, subsetSizeControl = 3, maxSubsetSize = 3 )
edgewiseTSID( mixedGraph, tianDecompose = T, subsetSizeControl = 3, maxSubsetSize = 3 )
mixedGraph |
a |
tianDecompose |
TRUE or FALSE determining whether or not the Tian decomposition should be used before running the current generic identification algorithm. In general letting this be TRUE will make the algorithm faster and more powerful. |
subsetSizeControl |
a positive integer (Inf allowed) which controls the size of edgesets searched in the edgewiseID algorithm. Suppose, for example, this has value 3. Then if a node i has n parents, this will restrict the algorithm to only look at subsets of the parents of size 1,2,3 and n-2, n-1, n. Making this parameter smaller means the algorithm will be faster but less exhaustive (and hence less powerful). |
maxSubsetSize |
a positive integer which controls the maximum subset size considered in the trek-separation identification algorithm. Making this parameter smaller means the algorithm will be faster but less exhaustive (and hence less powerful). |
see the return of generalGenericID
.
Flow from one set of nodes to another.
flowBetween(this, sources, sinks) ## S3 method for class 'FlowGraph' flowBetween(this, sources, sinks)
flowBetween(this, sources, sinks) ## S3 method for class 'FlowGraph' flowBetween(this, sources, sinks)
this |
the flow graph object |
sources |
the nodes from which flow should start. |
sinks |
the nodes at which the flow should end. |
a list with two named components, value
(the size of the
computed flow) and activeSources
(a vector representing the
subset of sources which have non-zero flow out of them for the found
max-flow).
Creates an object representing a flow graph.
FlowGraph(L = matrix(0,1,1), vertexCaps = 1, edgeCaps = matrix(1,1,1))
FlowGraph(L = matrix(0,1,1), vertexCaps = 1, edgeCaps = matrix(1,1,1))
L |
the adjacency matrix for the flow graph. The (i,j)th of L should be a 1 if there is an edge from i to j and 0 otherwise. |
vertexCaps |
the capacity of the vertices in the flow graph, should either be a single number or a vector whose ith entry is the capacity of vertex i. |
edgeCaps |
the capacities of the edges in the the flow graph, should be a matrix of the same dimensions as L with (i,j)th entry the capacity of the i->j edge. |
An object representing the FlowGraph.
A function that encapsulates the general structure of our algorithms for
testing generic identifiability. Allows for various identification algorithms
to be used in concert, in particular it will use the identifier functions
in the list idStepFunctions
sequentially until it can find no more
identifications. The step functions that are currently available for use
in idStepFunctions
are
htcIdentifyStep,
ancestralIdentifyStep,
edgewiseIdentifyStep,
trekSeparationIdentifyStep.
generalGenericID(mixedGraph, idStepFunctions, tianDecompose = T)
generalGenericID(mixedGraph, idStepFunctions, tianDecompose = T)
mixedGraph |
a |
idStepFunctions |
a list of identification step functions |
tianDecompose |
TRUE or FALSE determining whether or not the Tian decomposition should be used before running the current generic identification algorithm. In general letting this be TRUE will make the algorithm faster and more powerful. |
returns an object of class 'GenericIDResult
,' this
object is just a list with 9 components:
solvedParents
a list whose ith element contains a vector containing the subsets of parents of node i for which the edge j->i could be shown to be generically identifiable.
unsolvedParents
as for solvedParents
but for the
unsolved parents.
solvedSiblings
as for solvedParents
but for the
siblings of node i (i.e. the bidirected neighbors of i).
unsolvedSiblings
as for solvedSilbings
but for the
unsolved siblings of node i (i.e. the bidirected neighbors of i).
identifier
a function that takes a (generic) covariance
matrix corresponding to the graph and identifies the edges parameters
from solvedParents and solvedSiblings. See htcIdentifyStep
for a more in-depth discussion of identifier functions.
mixedGraph
a mixed graph object of the graph.
idStepFunctions
a list of functions used to generically
identify parameters. For instance, htcID uses the function
htcIdentifyStep
to identify edges.
tianDecompose
the argument tianDecompose.
call
the call made to this function.
Get the getAncestors of a collection of nodes in a graph g, the getAncestors DO include the the nodes themselves.
getAncestors(g, nodes)
getAncestors(g, nodes)
g |
the graph (as an igraph). |
nodes |
the nodes in the graph of which to get the getAncestors. |
a sorted vector of all ancestor nodes.
Gets the descendants of a collection of nodes in a graph (all nodes that can be reached by following directed edges from those nodes). Descendants DO include the nodes themselves.
getDescendants(g, nodes)
getDescendants(g, nodes)
g |
the graph (as an igraph). |
nodes |
the nodes in the graph of which to get the descendants. |
a sorted vector of all descendants of nodes.
Determines if a half-trek system exists in the mixed graph.
getHalfTrekSystem(this, fromNodes, toNodes, ...) ## S3 method for class 'MixedGraph' getHalfTrekSystem( this, fromNodes, toNodes, avoidLeftNodes = integer(0), avoidRightNodes = integer(0), avoidRightEdges = integer(0), ... ) ## S3 method for class 'MixedGraph' getTrekSystem( this, fromNodes, toNodes, avoidLeftNodes = integer(0), avoidRightNodes = integer(0), avoidLeftEdges = integer(0), avoidRightEdges = integer(0), ... )
getHalfTrekSystem(this, fromNodes, toNodes, ...) ## S3 method for class 'MixedGraph' getHalfTrekSystem( this, fromNodes, toNodes, avoidLeftNodes = integer(0), avoidRightNodes = integer(0), avoidRightEdges = integer(0), ... ) ## S3 method for class 'MixedGraph' getTrekSystem( this, fromNodes, toNodes, avoidLeftNodes = integer(0), avoidRightNodes = integer(0), avoidLeftEdges = integer(0), avoidRightEdges = integer(0), ... )
this |
the mixed graph object |
fromNodes |
the nodes from which the half-trek system should start. If length(fromNodes) > length(toNodes) will find if there exists any half-trek system from any subset of fromNodes of size length(toNodes) to toNodes. |
toNodes |
the nodes where the half-trek system should end. |
... |
ignored. |
avoidLeftNodes |
a collection of nodes to avoid on the left |
avoidRightNodes |
a collection of nodes to avoid on the right |
avoidRightEdges |
a collection of edges between observed noes in the graph that should not be used on any right hand side of any trek in the trek system. |
avoidLeftEdges |
a collection of edges between observed nodes in the graph that should not be used on any right hand side of any trek in the trek system. |
a list with two named components, systemExists
(TRUE if a
system exists, FALSE otherwise) and activeFrom
(the subset
of fromNodes from which the maximal half-trek system was started).
For an input mixed graph H, constructs the Gflow graph as described in Foygel et al. (2012) for a subgraph G of H. A max flow algorithm is then run on Gflow to determine the largest half-trek system in G to a particular node's getParents given a set of allowed nodes. Here G should consist of a bidirected part and nodes which are not in the bidirected part but are a parent of some node in the bidirected part. G should contain the node for which to compute the max flow.
getMaxFlow(L, O, allowedNodes, biNodes, inNodes, node)
getMaxFlow(L, O, allowedNodes, biNodes, inNodes, node)
L |
Adjacency matrix for the directed part of the path diagram/mixed graph; an edge pointing from i to j is encoded as L[i,j]=1 and the lack of an edge between i and j is encoded as L[i,j]=0. There should be no directed self loops, i.e. no i such that L[i,i]=1. |
O |
Adjacency matrix for the bidirected part of the path diagram/mixed graph. Edges are encoded as for the L parameter. Again there should be no self loops. Also this matrix will be coerced to be symmetric so it is only necessary to specify an edge once, i.e. if O[i,j]=1 you may, but are not required to, also have O[j,i]=1. |
allowedNodes |
the set of allowed nodes. |
biNodes |
the set of nodes in the subgraph G which are part of the bidirected part. |
inNodes |
the nodes of the subgraph G which are not in the bidirected part but are a parent of some node in the bidirected component. |
node |
the node (as an integer) for which the maxflow the largest half trek system |
See title.
Foygel, R., Draisma, J., and Drton, M. (2012) Half-trek criterion for generic identifiability of linear structural equation models. Ann. Statist. 40(3): 1682-1713.
For an input mixed graph H and set of nodes A, let GA be the subgraph of H on the nodes A. This function returns the mixed component of GA containing a specified node.
getMixedCompForNode(dG, bG, subNodes, node)
getMixedCompForNode(dG, bG, subNodes, node)
dG |
a directed graph representing the directed part of the mixed graph. |
bG |
an undirected graph representing the undirected part of the mixed graph. |
subNodes |
an ancestral set of nodes in the mixed graph, this set should include the node for which the mixed component sould be found. |
node |
the node for which the mixed component is found. |
a list with two named elements: biNodes - the nodes of the mixed graph in the biDirected component containing nodeName w.r.t the ancestral set of nodes inNodes - the nodes in the graph which are not part of biNodes but which are a parent of some node in biNodes.
Only works for graphs where the latent nodes are source nodes
getMixedGraph(this, ...) ## S3 method for class 'LatentDigraph' getMixedGraph(this, ...)
getMixedGraph(this, ...) ## S3 method for class 'LatentDigraph' getMixedGraph(this, ...)
this |
the LatentDigraph object |
... |
ignored |
Get the getParents of a collection of nodes in a graph g, the getParents DO include the input nodes themselves.
getParents(g, nodes)
getParents(g, nodes)
g |
the graph (as an igraph). |
nodes |
the nodes in the graph of which to get the getParents. |
a sorted vector of all parent nodes.
Get the getSiblings of a collection of nodes in a graph g, the getSiblings DO include the input nodes themselves.
getSiblings(g, nodes)
getSiblings(g, nodes)
g |
the graph (as an igraph). |
nodes |
the nodes in the graph of which to get the getSiblings. |
a sorted vector of all getSiblings of nodes.
Determines if a trek system exists in the mixed graph.
getTrekSystem( this, fromNodes, toNodes, avoidLeftNodes = integer(0), avoidRightNodes = integer(0), avoidLeftEdges = integer(0), avoidRightEdges = integer(0), ... ) ## S3 method for class 'LatentDigraphFixedOrder' getTrekSystem( this, fromNodes, toNodes, avoidLeftNodes = integer(0), avoidRightNodes = integer(0), avoidLeftEdges = integer(0), avoidRightEdges = integer(0), ... ) ## S3 method for class 'LatentDigraph' getTrekSystem( this, fromNodes, toNodes, avoidLeftNodes = integer(0), avoidRightNodes = integer(0), avoidLeftEdges = integer(0), avoidRightEdges = integer(0), ... )
getTrekSystem( this, fromNodes, toNodes, avoidLeftNodes = integer(0), avoidRightNodes = integer(0), avoidLeftEdges = integer(0), avoidRightEdges = integer(0), ... ) ## S3 method for class 'LatentDigraphFixedOrder' getTrekSystem( this, fromNodes, toNodes, avoidLeftNodes = integer(0), avoidRightNodes = integer(0), avoidLeftEdges = integer(0), avoidRightEdges = integer(0), ... ) ## S3 method for class 'LatentDigraph' getTrekSystem( this, fromNodes, toNodes, avoidLeftNodes = integer(0), avoidRightNodes = integer(0), avoidLeftEdges = integer(0), avoidRightEdges = integer(0), ... )
this |
the graph object |
fromNodes |
the start nodes |
toNodes |
the end nodes |
avoidLeftNodes |
a collection of nodes to avoid on the left |
avoidRightNodes |
a collection of nodes to avoid on the right |
avoidLeftEdges |
a collection of edges between observed nodes in the graph that should not be used on any right hand side of any trek in the trek system. |
avoidRightEdges |
a collection of edges between observed noes in the graph that should not be used on any right hand side of any trek in the trek system. |
... |
ignored |
Uses the criterion in Theorem 2 of the paper by Drton, Foygel and Sullivant (2011) to determine whether a mixed graph is globally identifiable.
globalID(graph)
globalID(graph)
graph |
a |
TRUE if the graph is globally identifiable, FALSE otherwise.
Drton, M., Barber, R. F., and Sullivant S. (2011). Half-Trek Criterion for Identifiability of Latent Variable Models. Ann. Statist. 39 (2011), no. 2, 865–886 <doi:10.1214/10-AOS859>.
NOTE: graphID
has been deprecated, use semID
instead.
This function checks global and generic identifiability of linear structural equation models. For generic identifiability the function checks a sufficient criterion as well as a necessary criterion but this check may be inconclusive.
graphID( L, O, output.type = "matrix", file.name = NULL, decomp.if.acyclic = TRUE, test.globalID = TRUE, test.genericID = TRUE, test.nonID = TRUE )
graphID( L, O, output.type = "matrix", file.name = NULL, decomp.if.acyclic = TRUE, test.globalID = TRUE, test.genericID = TRUE, test.nonID = TRUE )
L |
Adjacency matrix for the directed part of the path diagram/mixed graph; an edge pointing from i to j is encoded as L[i,j]=1 and the lack of an edge between i and j is encoded as L[i,j]=0. There should be no directed self loops, i.e. no i such that L[i,i]=1. |
O |
Adjacency matrix for the bidirected part of the path diagram/mixed graph. Edges are encoded as for the L parameter. Again there should be no self loops. Also this matrix will be coerced to be symmetric so it is only necessary to specify an edge once, i.e. if O[i,j]=1 you may, but are not required to, also have O[j,i]=1. |
output.type |
A character string indicating whether output is printed ('matrix'), saved to a file ('file'), or returned as a list ('list') for further processing in R. |
file.name |
A character string naming the output file. |
decomp.if.acyclic |
A logical value indicating whether an input graph that is acyclic is to be decomposed before applying identifiability criteria. |
test.globalID |
A logical value indicating whether or not global identifiability is checked. |
test.genericID |
A logical value indicating whether or not a sufficient condition for generic identifiability is checked. |
test.nonID |
A logical value indicating whether or not a condition implying generic non-identifiability is checked. |
A list or printed matrix indicating the identifiability status of the linear SEM given by the input graph. Optionally the graph's components are listed.
With output.type = 'list', the function returns a list of components for the graph. Each list entry is again a list that indicates first which nodes form the component and second whether the component forms a mixed graph that is acyclic. The next entries in the list show HTC-identifiable nodes, meaning nodes v for which the coefficients for all the directed edges pointing to v can be identified using the methods from Foygel et al. (2012). The HTC-identifiable nodes are listed in the order in which they are found by the recursive identification algorithm. The last three list entries are logical values that indicate whether or not the graph component is generically identifiable, globally identifiable or not identifiable; compare Drton et al. (2011) and Foygel et al. (2012). In the latter case the Jacobian of the parametrization does not have full rank.
With output.type = 'matrix', a summary of the above information is printed.
Drton, M., Foygel, R., and Sullivant, S. (2011) Global identifiability of linear structural equation models. Ann. Statist. 39(2): 865-886.
Foygel, R., Draisma, J., and Drton, M. (2012) Half-trek criterion for generic identifiability of linear structural equation models. Ann. Statist. 40(3): 1682-1713.
## Not run: L = t(matrix( c(0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0), 5, 5)) O = t(matrix( c(0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), 5, 5)) O=O+t(O) graphID(L,O) ## Examples from Foygel, Draisma & Drton (2012) demo(SEMID) ## End(Not run)
## Not run: L = t(matrix( c(0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0), 5, 5)) O = t(matrix( c(0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), 5, 5)) O=O+t(O) graphID(L,O) ## Examples from Foygel, Draisma & Drton (2012) demo(SEMID) ## End(Not run)
For an input, acyclic, mixed graph attempts to determine if the graph is generically identifiable using decomposition by ancestral subsets. See algorithm 1 of Drton and Weihs (2015).
graphID.ancestralID(L, O)
graphID.ancestralID(L, O)
L |
Adjacency matrix for the directed part of the path diagram/mixed graph; an edge pointing from i to j is encoded as L[i,j]=1 and the lack of an edge between i and j is encoded as L[i,j]=0. There should be no directed self loops, i.e. no i such that L[i,i]=1. |
O |
Adjacency matrix for the bidirected part of the path diagram/mixed graph. Edges are encoded as for the L parameter. Again there should be no self loops. Also this matrix will be coerced to be symmetric so it is only necessary to specify an edge once, i.e. if O[i,j]=1 you may, but are not required to, also have O[j,i]=1. |
The vector of nodes that could be determined to be generically identifiable using the above algorithm.
Drton, M. and Weihs, L. (2015) Generic Identifiability of Linear Structural Equation Models by Ancestor Decomposition. arXiv 1504.02992
Split a graph into mixed Tian components and solve each separately using the HTC.
graphID.decompose( L, O, decomp.if.acyclic = TRUE, test.globalID = TRUE, test.genericID = TRUE, test.nonID = TRUE )
graphID.decompose( L, O, decomp.if.acyclic = TRUE, test.globalID = TRUE, test.genericID = TRUE, test.nonID = TRUE )
L |
Adjacency matrix for the directed part of the path diagram/mixed graph; an edge pointing from i to j is encoded as L[i,j]=1 and the lack of an edge between i and j is encoded as L[i,j]=0. There should be no directed self loops, i.e. no i such that L[i,i]=1. |
O |
Adjacency matrix for the bidirected part of the path diagram/mixed graph. Edges are encoded as for the L parameter. Again there should be no self loops. Also this matrix will be coerced to be symmetric so it is only necessary to specify an edge once, i.e. if O[i,j]=1 you may, but are not required to, also have O[j,i]=1. |
decomp.if.acyclic |
A logical value indicating whether an input graph that is acyclic is to be decomposed before applying identifiability criteria. |
test.globalID |
A logical value indicating whether or not global identifiability is checked. |
test.genericID |
A logical value indicating whether or not a sufficient condition for generic identifiability is checked. |
test.nonID |
A logical value indicating whether or not a condition implying generic non-identifiability is checked. |
A list with two named components:
1. Components - a list of lists. Each list represents one mixed Tian component of the graph. Each list contains named components corresponding to which nodes are in the component and results of various tests of identifiability on the component (see the parameter descriptions).
2. Decomp - true if a decomposition occured, false if not.
If the directed part of input graph is cyclic then will check for generic identifiability using the half-trek criterion. Otherwise will use the a slightly stronger version of the half-trek criterion using ancestor decompositions.
graphID.genericID(L, O)
graphID.genericID(L, O)
L |
Adjacency matrix for the directed part of the path diagram/mixed graph; an edge pointing from i to j is encoded as L[i,j]=1 and the lack of an edge between i and j is encoded as L[i,j]=0. There should be no directed self loops, i.e. no i such that L[i,i]=1. |
O |
Adjacency matrix for the bidirected part of the path diagram/mixed graph. Edges are encoded as for the L parameter. Again there should be no self loops. Also this matrix will be coerced to be symmetric so it is only necessary to specify an edge once, i.e. if O[i,j]=1 you may, but are not required to, also have O[j,i]=1. |
The vector of nodes that could be determined to be generically identifiable.
Foygel, R., Draisma, J., and Drton, M. (2012) Half-trek criterion for generic identifiability of linear structural equation models. Ann. Statist. 40(3): 1682-1713.
Drton, M. and Weihs, L. (2015) Generic Identifiability of Linear Structural Equation Models by Ancestor Decomposition. arXiv 1504.02992
Uses the half-trek criterion of Foygel, Draisma, and Drton (2013) to check if an input mixed graph is generically identifiable.
graphID.htcID(L, O)
graphID.htcID(L, O)
L |
Adjacency matrix for the directed part of the path diagram/mixed graph; an edge pointing from i to j is encoded as L[i,j]=1 and the lack of an edge between i and j is encoded as L[i,j]=0. There should be no directed self loops, i.e. no i such that L[i,i]=1. |
O |
Adjacency matrix for the bidirected part of the path diagram/mixed graph. Edges are encoded as for the L parameter. Again there should be no self loops. Also this matrix will be coerced to be symmetric so it is only necessary to specify an edge once, i.e. if O[i,j]=1 you may, but are not required to, also have O[j,i]=1. |
The vector of HTC-identifiable nodes.
Foygel, R., Draisma, J., and Drton, M. (2012) Half-trek criterion for generic identifiability of linear structural equation models. Ann. Statist. 40(3): 1682-1713.
Calls the other functions that determine identifiability status.
graphID.main( L, O, test.globalID = TRUE, test.genericID = TRUE, test.nonID = TRUE )
graphID.main( L, O, test.globalID = TRUE, test.genericID = TRUE, test.nonID = TRUE )
L |
Adjacency matrix for the directed part of the path diagram/mixed graph; an edge pointing from i to j is encoded as L[i,j]=1 and the lack of an edge between i and j is encoded as L[i,j]=0. There should be no directed self loops, i.e. no i such that L[i,i]=1. |
O |
Adjacency matrix for the bidirected part of the path diagram/mixed graph. Edges are encoded as for the L parameter. Again there should be no self loops. Also this matrix will be coerced to be symmetric so it is only necessary to specify an edge once, i.e. if O[i,j]=1 you may, but are not required to, also have O[j,i]=1. |
test.globalID |
A logical value indicating whether or not global identifiability is checked. |
test.genericID |
A logical value indicating whether or not a sufficient condition for generic identifiability is checked. |
test.nonID |
A logical value indicating whether or not a condition implying generic non-identifiability is checked. |
A list containing named components of the results of various tests desired based on the input parameters.
Checks if a mixed graph is infinite-to-one using the half-trek criterion presented by Foygel, Draisma, and Drton (2012).
graphID.nonHtcID(L, O)
graphID.nonHtcID(L, O)
L |
Adjacency matrix for the directed part of the path diagram/mixed graph; an edge pointing from i to j is encoded as L[i,j]=1 and the lack of an edge between i and j is encoded as L[i,j]=0. There should be no directed self loops, i.e. no i such that L[i,i]=1. |
O |
Adjacency matrix for the bidirected part of the path diagram/mixed graph. Edges are encoded as for the L parameter. Again there should be no self loops. Also this matrix will be coerced to be symmetric so it is only necessary to specify an edge once, i.e. if O[i,j]=1 you may, but are not required to, also have O[j,i]=1. |
TRUE if the graph could be determined to be generically non-identifiable, FALSE if this test was inconclusive.
Foygel, R., Draisma, J., and Drton, M. (2012) Half-trek criterion for generic identifiability of linear structural equation models. Ann. Statist. 40(3): 1682-1713.
Uses the half-trek criterion of Foygel, Draisma, and Drton (2012) determine
which edges in a mixed graph are generically identifiable. Depending on your
application it faster to use the graphID.htcID
function
instead of this one, this function has the advantage of returning additional
information.
htcID(mixedGraph, tianDecompose = T)
htcID(mixedGraph, tianDecompose = T)
mixedGraph |
a |
tianDecompose |
TRUE or FALSE determining whether or not the Tian decomposition should be used before running the current generic identification algorithm. In general letting this be TRUE will make the algorithm faster and more powerful. |
see the return value of generalGenericID
.
Foygel, R., Draisma, J., and Drton, M. (2012) Half-trek criterion for generic identifiability of linear structural equation models. Ann. Statist. 40(3): 1682-1713.
Jin Tian. 2005. Identifying direct causal effects in linear models. In Proceedings of the 20th national conference on Artificial intelligence - Volume 1 (AAAI'05), Anthony Cohn (Ed.), Vol. 1. AAAI Press 346-352.
A function that does one step through all the nodes in a mixed graph and tries to identify new edge coefficients using the existence of half-trek systems as described in Foygel, Draisma, Drton (2012).
htcIdentifyStep(mixedGraph, unsolvedParents, solvedParents, identifier)
htcIdentifyStep(mixedGraph, unsolvedParents, solvedParents, identifier)
mixedGraph |
a |
unsolvedParents |
a list whose ith index is a vector of all the parents j of i in G which for which the edge j->i is not yet known to be generically identifiable. |
solvedParents |
the complement of |
identifier |
an identification function that must produce the
identifications corresponding to those in solved parents. That is
such that if j is in |
a list with four components:
identifiedEdges
a matrix rx2 matrix where r is the number
of edges that where identified by this function call and
identifiedEdges[i,1] -> identifiedEdges[i,2]
was the ith edge
identified
unsolvedParents
as the input argument but updated with any newly identified edges
solvedParents
as the input argument but updated with any newly identified edges
identifier
as the input argument but updated with any newly identified edges
Foygel, R., Draisma, J., and Drton, M. (2012) Half-trek criterion for generic identifiability of linear structural equation models. Ann. Statist. 40(3): 1682-1713
Gets all vertices in a graph that are half-trek reachable from a set of nodes. WARNING: Often the half-trek reachable nodes from a vertex v are defined to not include the vertex v or its getSiblings. We DO NOT follow this convention, the returned set will include input nodes and their getSiblings.
htr(dG, bG, nodes)
htr(dG, bG, nodes)
dG |
a directed graph representing the directed part of the mixed graph. |
bG |
an undirected graph representing the undirected part of the mixed graph. |
nodes |
the nodes in the graph of which to get the HTR nodes. |
a sorted list of all half-trek reachable nodes.
Half trek reachable nodes.
htrFrom(this, nodes, ...) ## S3 method for class 'MixedGraph' htrFrom( this, nodes, avoidLeftNodes = integer(0), avoidRightNodes = integer(0), ... )
htrFrom(this, nodes, ...) ## S3 method for class 'MixedGraph' htrFrom( this, nodes, avoidLeftNodes = integer(0), avoidRightNodes = integer(0), ... )
this |
the mixed graph object |
nodes |
the nodes from which to get all half-trek reachable nodes. |
... |
ignored. |
avoidLeftNodes |
a collection of nodes to avoid on the left |
avoidRightNodes |
a collection of nodes to avoid on the right |
a vector of all nodes half-trek reachable from node.
Get the induced subgraph on a collection of nodes
inducedSubgraph(this, nodes, ...) ## S3 method for class 'LatentDigraph' inducedSubgraph(this, nodes, ...) ## S3 method for class 'MixedGraph' inducedSubgraph(this, nodes, ...)
inducedSubgraph(this, nodes, ...) ## S3 method for class 'LatentDigraph' inducedSubgraph(this, nodes, ...) ## S3 method for class 'MixedGraph' inducedSubgraph(this, nodes, ...)
this |
the graph object |
nodes |
the nodes on which to create the induced subgraph. |
... |
ignored. |
Are two nodes siblings?
isSibling(this, node1, node2, ...) ## S3 method for class 'MixedGraph' isSibling(this, node1, node2, ...)
isSibling(this, node1, node2, ...) ## S3 method for class 'MixedGraph' isSibling(this, node1, node2, ...)
this |
the mixed graph object |
node1 |
a node |
node2 |
a second node |
... |
ignored. |
TRUE if the nodes are siblings in the graph, FALSE otherwise
Get directed adjacency matrix.
L(this, ...) ## S3 method for class 'LatentDigraphFixedOrder' L(this, ...) ## S3 method for class 'LatentDigraph' L(this, ...) ## S3 method for class 'MixedGraph' L(this, ...)
L(this, ...) ## S3 method for class 'LatentDigraphFixedOrder' L(this, ...) ## S3 method for class 'LatentDigraph' L(this, ...) ## S3 method for class 'MixedGraph' L(this, ...)
this |
the graph object |
... |
ignored. |
Creates an object representing a latent factor graph. The methods that are currently available to be used on the latent factor graph include
numObserved
numLatents
numNodes
toIn
toEx
L
observedNodes
latentNodes
parents
children
ancestors
descendants
trFrom
getTrekSystem
inducedSubgraph
stronglyConnectedComponent
plot
observedParents
getMixedGraph
see the individual function documentation for more information.
LatentDigraph(L = matrix(0,1,1), observedNodes = seq(1, length = nrow(L)), latentNodes = integer(0))
LatentDigraph(L = matrix(0,1,1), observedNodes = seq(1, length = nrow(L)), latentNodes = integer(0))
L |
see |
observedNodes |
a vector of positive integers representing the vertex numbers of the observed nodes. These will correspond, in order, to the first length(observedNodes) rows of L. |
latentNodes |
a vector of positive integers representing the vertex numbers of the latent nodes. These will correspond, in order, to the last length(latentNodes) rows of L. |
An object representing the LatentDigraph
Creates an object representing a directed graph with some number of nodes which are latent (unobserved).
LatentDigraphFixedOrder(L = matrix(0,1,1), numObserved = nrow(L))
LatentDigraphFixedOrder(L = matrix(0,1,1), numObserved = nrow(L))
L |
see |
numObserved |
a non-negative integer representing the number of observed nodes in the graph. |
An object representing the LatentDigraphFixedOrder
Checks that the input latent digraph has nodes numbered from 1 to latentDigraph$numObserved()+latentDigraph$numLatents(). The first latentDigraph$numObserved() nodes correspond to the observed nodes in the graph, all other nodes are considered unobserved. Throws an error if this is not true.
latentDigraphHasSimpleNumbering(graph)
latentDigraphHasSimpleNumbering(graph)
graph |
a |
Get all latent nodes in the graph.
latentNodes(this, ...) ## S3 method for class 'LatentDigraph' latentNodes(this, ...)
latentNodes(this, ...) ## S3 method for class 'LatentDigraph' latentNodes(this, ...)
this |
the graph object |
... |
ignored |
Uses the latent-factor half-trek criterion to determine which edges in a latent digraph are generically identifiable.
lfhtcID(graph)
lfhtcID(graph)
graph |
a |
returns a list with 8 components:
solvedParents
a list whose ith element contains a vector containing the subsets of parents of node i for which the edge j->i could be shown to be generically identifiable.
unsolvedParents
as for solvedParents
but for the
unsolved parents.
identifier
a function that takes a (generic) covariance
matrix corresponding to the graph and identifies the edges parameters
from solvedParents and solvedSiblings. See htcIdentifyStep
for a more in-depth discussion of identifier functions.
graph
a latent digraph object of the graph.
call
the call made to this function.
activeFroms
list. If node i is solved then the ith index is a vector containing the nodes Y otherwise it is empty.
Zs
list. If node i is solved then the ith index is a vector containing the nodes Z otherwise it is empty.
Ls
list. If node i is solved then the ith index is a vector containing the nodes L otherwise it is empty.
Barber, R. F., Drton, M., Sturma, N., and Weihs L. (2022). Half-Trek Criterion for Identifiability of Latent Variable Models. Ann. Statist. 50(6):3174–3196. <doi:10.1214/22-AOS2221>.
A function that does one step through all the nodes in a latent-factor graph and tries to identify new edge coefficients using the existence of latent-factor half-trek systems.
lfhtcIdentifyStep( graph, unsolvedParents, solvedParents, activeFroms, Zs, Ls, identifier, subsetSizeControl = Inf )
lfhtcIdentifyStep( graph, unsolvedParents, solvedParents, activeFroms, Zs, Ls, identifier, subsetSizeControl = Inf )
graph |
a |
unsolvedParents |
a list whose ith index is a vector of all the parents j of i in the graph which for which the edge j->i is not yet known to be generically identifiable. |
solvedParents |
the complement of |
activeFroms |
list. If node i is solved then the ith index is a vector containing the nodes Y otherwise it is empty. |
Zs |
list. If node i is solved then the ith index is a vector containing the nodes Z otherwise it is empty. |
Ls |
list. If node i is solved then the ith index is a vector containing the nodes Z otherwise it is empty. |
identifier |
an identification function that must produce the
identifications corresponding to those in solved parents. That is
|
subsetSizeControl |
the largest subset of latent nodes to consider. |
a list with four components:
identifiedEdges
a matrix rx2 matrix where r is the number
of edges that where identified by this function call and
identifiedEdges[i,1] -> identifiedEdges[i,2]
was the ith edge
identified
unsolvedParents
as the input argument but updated with any newly identified edges
solvedParents
as the input argument but updated with any newly identified edges
identifier
as the input argument but updated with any newly identified edges
activeFroms
as the input argument but updated with any newly solved node
Zs
as the input argument but updated with any newly solved node
Ls
as the input argument but updated with any newly solved node
Barber, R. F., Drton, M., Sturma, N., and Weihs L. (2022). Half-Trek Criterion for Identifiability of Latent Variable Models. arXiv preprint arXiv:2201.04457
Creates an object representing a mixed graph. The methods that are currently available to be used on the mixed graph include
ancestors
descendants
parents
siblings
isSibling
htrFrom
trFrom
getHalfTrekSystem
getTrekSystem
inducedSubgraph
L
O
nodes
numNodes
stronglyConnectedComponent
tianComponent
tianDecompose
see the individual function documentation for more information.
MixedGraph( L = matrix(0, 1, 1), O = matrix(0, 1, 1), vertexNums = seq(1, length = nrow(L)) )
MixedGraph( L = matrix(0, 1, 1), O = matrix(0, 1, 1), vertexNums = seq(1, length = nrow(L)) )
L |
see |
O |
as for L. |
vertexNums |
the labeling of the vertices in the graph in the order of the rows of L and O. Labels must be positive integers. |
An object representing the MixedGraph
Checks that the input mixed graph has vertices are numbered from 1 to mixedGraph$numNodes(). Throws an error if they are not.
mixedGraphHasSimpleNumbering(mixedGraph)
mixedGraphHasSimpleNumbering(mixedGraph)
mixedGraph |
the mixed graph object |
Get all nodes in the graph.
nodes(this, ...) ## S3 method for class 'MixedGraph' nodes(this, ...)
nodes(this, ...) ## S3 method for class 'MixedGraph' nodes(this, ...)
this |
the mixed graph object |
... |
ignored. |
Number of latent nodes in the graph.
numLatents(this, ...) ## S3 method for class 'LatentDigraphFixedOrder' numLatents(this, ...) ## S3 method for class 'LatentDigraph' numLatents(this, ...)
numLatents(this, ...) ## S3 method for class 'LatentDigraphFixedOrder' numLatents(this, ...) ## S3 method for class 'LatentDigraph' numLatents(this, ...)
this |
the graph object |
... |
ignored |
Number of nodes in the graph.
numNodes(this, ...) ## S3 method for class 'LatentDigraphFixedOrder' numNodes(this, ...) ## S3 method for class 'LatentDigraph' numNodes(this, ...) ## S3 method for class 'MixedGraph' numNodes(this, ...)
numNodes(this, ...) ## S3 method for class 'LatentDigraphFixedOrder' numNodes(this, ...) ## S3 method for class 'LatentDigraph' numNodes(this, ...) ## S3 method for class 'MixedGraph' numNodes(this, ...)
this |
the graph object |
... |
ignored. |
Number of observed nodes in the graph.
numObserved(this, ...) ## S3 method for class 'LatentDigraphFixedOrder' numObserved(this, ...) ## S3 method for class 'LatentDigraph' numObserved(this, ...)
numObserved(this, ...) ## S3 method for class 'LatentDigraphFixedOrder' numObserved(this, ...) ## S3 method for class 'LatentDigraph' numObserved(this, ...)
this |
the graph object |
... |
ignored |
Get adjacency matrix for bidirected part.
O(this, ...) ## S3 method for class 'MixedGraph' O(this, ...)
O(this, ...) ## S3 method for class 'MixedGraph' O(this, ...)
this |
the mixed graph object |
... |
ignored. |
Get all observed nodes in the graph.
observedNodes(this, ...) ## S3 method for class 'LatentDigraph' observedNodes(this, ...)
observedNodes(this, ...) ## S3 method for class 'LatentDigraph' observedNodes(this, ...)
this |
the graph object |
... |
ignored |
Get the observed parents on a collection of nodes
observedParents(this, nodes, ...) ## S3 method for class 'LatentDigraph' observedParents(this, nodes, ...)
observedParents(this, nodes, ...) ## S3 method for class 'LatentDigraph' observedParents(this, nodes, ...)
this |
the graph object |
nodes |
the nodes on which to get the observed parents |
... |
ignored |
Returns all parents of the collection (does not necessarily include the input nodes themselves unless they are parents of one another).
parents(this, nodes, ...) ## S3 method for class 'LatentDigraphFixedOrder' parents(this, nodes, includeObserved = T, includeLatents = T, ...) ## S3 method for class 'LatentDigraph' parents(this, nodes, includeObserved = T, includeLatents = T, ...) ## S3 method for class 'MixedGraph' parents(this, nodes, ...)
parents(this, nodes, ...) ## S3 method for class 'LatentDigraphFixedOrder' parents(this, nodes, includeObserved = T, includeLatents = T, ...) ## S3 method for class 'LatentDigraph' parents(this, nodes, includeObserved = T, includeLatents = T, ...) ## S3 method for class 'MixedGraph' parents(this, nodes, ...)
this |
the graph object. |
nodes |
nodes the nodes of which to find the parents. |
... |
ignored. |
includeObserved |
if TRUE includes observed nodes in the returned set. |
includeLatents |
if TRUE includes latent nodes in the returned set. |
the observed parents.
Plots the latent digraph
Plots the mixed graph
## S3 method for class 'LatentDigraph' plot(x, ...) ## S3 method for class 'MixedGraph' plot(x, ...)
## S3 method for class 'LatentDigraph' plot(x, ...) ## S3 method for class 'MixedGraph' plot(x, ...)
x |
the mixed graph object |
... |
additional plotting arguments. Currently ignored. |
Given an adjacency matrix representing the directed edges in a latent factor graph, plots a representation of the graph. The latent nodes should come last in L and the vertex labels should only be given for the observed nodes.
plotLatentDigraph(L, observedNodes, latentNodes, main = "")
plotLatentDigraph(L, observedNodes, latentNodes, main = "")
L |
Adjacency matrix for the directed part of the path diagram/mixed graph; an edge pointing from i to j is encoded as L[i,j]=1 and the lack of an edge between i and j is encoded as L[i,j]=0. There should be no directed self loops, i.e. no i such that L[i,i]=1. |
observedNodes |
a vector of positive integers representing the vertex numbers of the observed nodes. These will correspond, in order, to the first length(observedNodes) rows of L. |
latentNodes |
a vector of positive integers representing the vertex numbers of the latent nodes. These will correspond, in order, to the last length(latentNodes) rows of L. |
main |
the plot title. |
An object representing the LatentDigraph
Given adjacency matrices representing the directed and bidirected portions of a mixed graph, plots a representation of the graph.
plotMixedGraph(L, O, main = "", vertexLabels = 1:nrow(L))
plotMixedGraph(L, O, main = "", vertexLabels = 1:nrow(L))
L |
Adjacency matrix for the directed part of the path diagram/mixed graph; an edge pointing from i to j is encoded as L[i,j]=1 and the lack of an edge between i and j is encoded as L[i,j]=0. There should be no directed self loops, i.e. no i such that L[i,i]=1. |
O |
Adjacency matrix for the bidirected part of the path diagram/mixed graph. Edges are encoded as for the L parameter. Again there should be no self loops. Also this matrix will be coerced to be symmetric so it is only necessary to specify an edge once, i.e. if O[i,j]=1 you may, but are not required to, also have O[j,i]=1. |
main |
the plot title. |
vertexLabels |
labels to use for the vertices. |
Prints a GenericIDResult object as returned by
generalGenericID
. Invisibly returns its argument via
invisible(x)
as most print functions do.
## S3 method for class 'GenericIDResult' print(x, ...)
## S3 method for class 'GenericIDResult' print(x, ...)
x |
the GenericIDResult object |
... |
optional parameters, currently unused. |
Prints a LfhtcIDResult object as returned by
lfhtcID
. Invisibly returns its argument via
invisible(x)
as most print functions do.
## S3 method for class 'LfhtcIDResult' print(x, ...)
## S3 method for class 'LfhtcIDResult' print(x, ...)
x |
the LfhtcIDResult object |
... |
optional parameters, currently unused. |
Prints a SEMIDResult object as returned by
semID
. Invisibly returns its argument via
invisible(x)
as most print functions do.
## S3 method for class 'SEMIDResult' print(x, ...)
## S3 method for class 'SEMIDResult' print(x, ...)
x |
the SEMIDResult object |
... |
optional parameters, currently unused. |
This function can be used to check global and generic identifiability of
linear structural equation models (L-SEMs). In particular, this function
takes a MixedGraph
object corresponding to the L-SEM and
checks different conditions known for global and generic identifiability.
semID( mixedGraph, testGlobalID = TRUE, testGenericNonID = TRUE, genericIdStepFunctions = list(htcIdentifyStep), tianDecompose = TRUE )
semID( mixedGraph, testGlobalID = TRUE, testGenericNonID = TRUE, genericIdStepFunctions = list(htcIdentifyStep), tianDecompose = TRUE )
mixedGraph |
a |
testGlobalID |
TRUE or FALSE if the graph should be tested for global
identifiability. This uses the |
testGenericNonID |
TRUE of FALSE if the graph should be tested for
generic non-identifiability, that is, if for every generic choice
of parameters for the L-SEM there are infinitely many
other choices that lead to the same covariance matrix. This currently
uses the |
genericIdStepFunctions |
a list of the generic identifier step functions
that should be used for testing generic identifiability. See
|
tianDecompose |
TRUE or FALSE if the mixed graph should be Tian decomposed before running the identification algorithms (when appropriate). In general letting this be TRUE will make the algorithm faster and more powerful. Note that this is a version of the Tian decomposition that works also with cyclic graphs. |
returns an object of class 'SEMIDResult
,' this
object is just a list with 6 components:
isGlobalID
If testGlobalID == TRUE, then TRUE or FALSE if the graph is globally identifiable. If testGlobalID == FALSE then NA.
isGenericNonID
If testGenericNonID == TRUE, then TRUE if the graph is generically non-identifiable or FALSE the test is inconclusive. If testGenericNonID == FALSE then NA.
genericIDResult
If length(genericIdStepFunctions) != 0 then
a GenericIDResult
object as returned by
generalGenericID
. Otherwise a list of length 0.
mixedGraph
the inputted mixed graph object.
tianDecompose
the argument tianDecompose.
call
the call made to this function.
## Not run: L = t(matrix( c(0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0), 5, 5)) O = t(matrix( c(0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), 5, 5)) O = O + t(O) graph = MixedGraph(L,O) semID(graph) ## Examples from Foygel, Draisma & Drton (2012) demo(SEMID) ## End(Not run)
## Not run: L = t(matrix( c(0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0), 5, 5)) O = t(matrix( c(0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), 5, 5)) O = O + t(O) graph = MixedGraph(L,O) semID(graph) ## Examples from Foygel, Draisma & Drton (2012) demo(SEMID) ## End(Not run)
All siblings of a collection of nodes
siblings(this, nodes, ...) ## S3 method for class 'MixedGraph' siblings(this, nodes, ...)
siblings(this, nodes, ...) ## S3 method for class 'MixedGraph' siblings(this, nodes, ...)
this |
the mixed graph object |
nodes |
a vector of nodes of which to find the siblings. |
... |
ignored. |
a vector of all of the siblings.
Get the strongly connected component for a node i in the graph the graph.
stronglyConnectedComponent(this, node, ...) ## S3 method for class 'LatentDigraphFixedOrder' stronglyConnectedComponent(this, node, ...) ## S3 method for class 'LatentDigraph' stronglyConnectedComponent(this, node, ...) ## S3 method for class 'MixedGraph' stronglyConnectedComponent(this, node, ...)
stronglyConnectedComponent(this, node, ...) ## S3 method for class 'LatentDigraphFixedOrder' stronglyConnectedComponent(this, node, ...) ## S3 method for class 'LatentDigraph' stronglyConnectedComponent(this, node, ...) ## S3 method for class 'MixedGraph' stronglyConnectedComponent(this, node, ...)
this |
the graph object |
node |
the node for which to get the strongly connected component. |
... |
ignored. |
For an input vector x, returns in a list, the collection of all subsets of x of size k.
subsetsOfSize(x, k)
subsetsOfSize(x, k)
x |
a vector from which to get subsets |
k |
the size of the subsets returned |
a list of all subsets of x of a given size k
Returns the Tian c-component of a node
tianComponent(this, node) ## S3 method for class 'MixedGraph' tianComponent(this, node)
tianComponent(this, node) ## S3 method for class 'MixedGraph' tianComponent(this, node)
this |
the mixed graph object |
node |
the node for which to return its c-component |
Uses the Tian decomposition to break the mixed graph into c-components. These c-components are slightly different than those from Tian (2005) in that if they graph is not acyclic the bidirected components are combined whenever they are connected by a directed loop.
tianDecompose(this) ## S3 method for class 'MixedGraph' tianDecompose(this)
tianDecompose(this) ## S3 method for class 'MixedGraph' tianDecompose(this)
this |
the mixed graph object |
Jin Tian. 2005. Identifying direct causal effects in linear models. In Proceedings of the 20th national conference on Artificial intelligence - Volume 1 (AAAI'05), Anthony Cohn (Ed.), Vol. 1. AAAI Press 346-352.
Creates an identification function which combines the identification functions created on a collection of c-components into a identification for the full mixed graph.
tianIdentifier(idFuncs, cComponents)
tianIdentifier(idFuncs, cComponents)
idFuncs |
a list of identifier functions for the c-components |
cComponents |
the c-components of the mixed graph as returned by
|
a new identifier function
The Tian decomposition of a mixed graph G allows one to globally identify the covariance matrices Sigma' of special subgraphs of G called c-components. This function takes the covariance matrix Sigma corresponding to G and a collection of node sets which specify the c-component, and returns the Sigma' corresponding to the c-component.
tianSigmaForComponent(Sigma, internal, incoming, topOrder)
tianSigmaForComponent(Sigma, internal, incoming, topOrder)
Sigma |
the covariance matrix for the mixed graph G |
internal |
an integer vector corresponding to the vertices of the C-component that are in the bidirected equivalence classes (if the graph is not-acyclic then these equivalence classes must be enlarged by combining two bidirected components if there are two vertices, one in each component, that are simultaneously on the same directed cycle). |
incoming |
the parents of vertices in internal that are not in the set internal themselves |
topOrder |
a topological ordering of c(internal, incoming) with respect to the graph G. For vertices in a strongly connected component the ordering is allowed to be arbitrary. |
the new Sigma corresponding to the c-component
Transforms a vector of node indices in the internal rep. into external numbering
toEx(this, nodes, ...) ## S3 method for class 'LatentDigraph' toEx(this, nodes, ...) ## S3 method for class 'MixedGraph' toEx(this, nodes, ...)
toEx(this, nodes, ...) ## S3 method for class 'LatentDigraph' toEx(this, nodes, ...) ## S3 method for class 'MixedGraph' toEx(this, nodes, ...)
this |
the graph object |
nodes |
the nodes to transform |
... |
ignored |
Transforms a vector of given node indices into their internal numbering
toIn(this, nodes, ...) ## S3 method for class 'LatentDigraph' toIn(this, nodes, ...) ## S3 method for class 'MixedGraph' toIn(this, nodes, ...)
toIn(this, nodes, ...) ## S3 method for class 'LatentDigraph' toIn(this, nodes, ...) ## S3 method for class 'MixedGraph' toIn(this, nodes, ...)
this |
the graph object |
nodes |
the nodes to transform |
... |
ignored |
A function that does one step through all the nodes in a mixed graph and tries to identify new edge coefficients using trek-separation as described in Weihs, Robeva, Robinson, et al. (2017).
trekSeparationIdentifyStep( mixedGraph, unsolvedParents, solvedParents, identifier, maxSubsetSize = 3 )
trekSeparationIdentifyStep( mixedGraph, unsolvedParents, solvedParents, identifier, maxSubsetSize = 3 )
mixedGraph |
a |
unsolvedParents |
a list whose ith index is a vector of all the parents j of i in G which for which the edge j->i is not yet known to be generically identifiable. |
solvedParents |
the complement of |
identifier |
an identification function that must produce the
identifications corresponding to those in solved parents. That is
such that if j is in |
maxSubsetSize |
a positive integer which controls the maximum subset size considered in the trek-separation identification algorithm. Making this parameter smaller means the algorithm will be faster but less exhaustive (and hence less powerful). |
see the return of htcIdentifyStep
.
Gets all nodes that are trek reachable from a collection of nodes.
trFrom(this, nodes, ...) ## S3 method for class 'LatentDigraphFixedOrder' trFrom( this, nodes, avoidLeftNodes = integer(0), avoidRightNodes = integer(0), includeObserved = T, includeLatents = T, ... ) ## S3 method for class 'LatentDigraph' trFrom( this, nodes, avoidLeftNodes = integer(0), avoidRightNodes = integer(0), includeObserved = T, includeLatents = T, ... ) ## S3 method for class 'MixedGraph' trFrom( this, nodes, avoidLeftNodes = integer(0), avoidRightNodes = integer(0), ... )
trFrom(this, nodes, ...) ## S3 method for class 'LatentDigraphFixedOrder' trFrom( this, nodes, avoidLeftNodes = integer(0), avoidRightNodes = integer(0), includeObserved = T, includeLatents = T, ... ) ## S3 method for class 'LatentDigraph' trFrom( this, nodes, avoidLeftNodes = integer(0), avoidRightNodes = integer(0), includeObserved = T, includeLatents = T, ... ) ## S3 method for class 'MixedGraph' trFrom( this, nodes, avoidLeftNodes = integer(0), avoidRightNodes = integer(0), ... )
this |
the graph object |
nodes |
the nodes from which to find trek-reachable nodes. |
... |
ignored. |
avoidLeftNodes |
a collection of nodes to avoid on the left |
avoidRightNodes |
a collection of nodes to avoid on the right |
includeObserved |
if TRUE includes observed nodes in the returned set. |
includeLatents |
if TRUE includes latent nodes in the returned set. |
Update edge capacities.
updateEdgeCapacities(this, edges, newCaps) ## S3 method for class 'FlowGraph' updateEdgeCapacities(this, edges, newCaps)
updateEdgeCapacities(this, edges, newCaps) ## S3 method for class 'FlowGraph' updateEdgeCapacities(this, edges, newCaps)
this |
the flow graph object |
edges |
the vertices to update (as a 2xr matrix with ith row corresponding to the edge edges[1,i]->edges[2,i]. |
newCaps |
the new capacities for the edges |
Update vertex capacities.
updateVertexCapacities(this, vertices, newCaps) ## S3 method for class 'FlowGraph' updateVertexCapacities(this, vertices, newCaps)
updateVertexCapacities(this, vertices, newCaps) ## S3 method for class 'FlowGraph' updateVertexCapacities(this, vertices, newCaps)
this |
the flow graph object |
vertices |
the vertices to update. |
newCaps |
the new capacities for the vertices. |
Produces an error if not all latent nodes are sources.
validateLatentNodesAreSources(graph)
validateLatentNodesAreSources(graph)
graph |
the LatentDigraph |
This helper function validates that the two input matrices, L and O, are of the appropriate form to be interpreted by the other functions. In particular they should be square matrices of 1's and 0's with all 0's along their diagonals. We do not require O to be symmetric here.
validateMatrices(L, O)
validateMatrices(L, O)
L |
See above description. |
O |
See above description. |
This function has no return value.
This helper function validates that an input matrix, L, is of the the appropriate form to be interpreted by the other functions. In particular it should be square matrix of 1's and 0's with all 0's along its diagonal. If any of the above conditions is not met, this function will throw an error.
validateMatrix(L)
validateMatrix(L)
L |
See above description. |
No return value
Produces an error if outside bounds.
validateNodes(nodes, numNodes)
validateNodes(nodes, numNodes)
nodes |
the input nodes, expected to be from the collection 1:(number of nodes in the graph) |
numNodes |
the number of observed nodes in the graph. |
Produces an error if there are variable arguments.
validateVarArgsEmpty(...)
validateVarArgsEmpty(...)
... |
the variable arguments |