Gaussian Graphical Models
Gaussian graphical model types are parametrized as GaussianGraphicalModel{T, L} where T represents the type of graph and L represents the labelings of the graph. The parameters T and L are determined by the graph used to construct the model.
gaussian_graphical_model — Function
gaussian_graphical_model(G::Graph{Directed}; s_varname::VarName="s", l_varname::VarName="l", w_varname::VarName=:w)
gaussian_graphical_model(G::MixedGraph; s_varname::VarName="s", l_varname::VarName="l", w_varname::VarName="w")
gaussian_graphical_model(G::Graph{Undirected}; s_varname::VarName="s", k_varname::VarName="k")Given a graph G construct a gaussian graphical model for G. Optionally one can set the letter used for the variable of the covariance matrix by setting s_varname.
Examples
julia> G = graph_from_edges(Directed, [[1, 2], [2, 3]])
Directed graph with 3 nodes and the following edges:
(1, 2)(2, 3)
julia> GM = gaussian_graphical_model(G)
Gaussian Graphical Model on a Directed graph with 3 nodes and 2 edges
julia> typeof(GM)
GaussianGraphicalModel{Graph{Directed}, Nothing}
julia> CG = graph_from_labeled_edges(Dict((1, 2) => "red", (2, 3) => "green"); name=:color)
Undirected graph with 3 nodes and the following labeling(s):
label: color
(2, 1) -> red
(3, 2) -> green
julia> GM = gaussian_graphical_model(CG)
Gaussian Graphical Model on a Undirected graph with 3 nodes and 2 edges with labeling(s) [:color]This function is part of the experimental code in Oscar. Please read here for more details.
Directed Gaussian Graphical Model
The parametrization for a directed Gaussian graphical model on a DAG $G$ is built from the weighted adjacency matrix $\Lambda$ and the covariance matrix $\Omega$ of the error terms. The model is then the set of all covariance matrices $\Sigma = (Id - \Lambda)^{-T} \Omega (Id - \Lambda)^{-1}$. $\Lambda$ and $\Omega$ can be built with the following functions:
directed_edges_matrix — Function
directed_edges_matrix(M::GaussianGraphicalModel{<:AbstractGraph{T}}) where {T <: Union{Mixed, Directed}}Create the weighted adjacency matrix $\Lambda$ of a directed graph G whose entries are the parameter ring of the graphical model M.
Examples
julia> GM = gaussian_graphical_model(graph_from_edges(Directed, [[1,2], [2,3]]))
Gaussian Graphical Model on a Directed graph with 3 nodes and 2 edges
julia> directed_edges_matrix(GM)
[0 l[1, 2] 0]
[0 0 l[2, 3]]
[0 0 0]This function is part of the experimental code in Oscar. Please read here for more details.
error_covariance_matrix — Function
error_covariance_matrix(M::GaussianGraphicalModel{Graph{Directed}, L}) where LCreate the covariance matrix $ \Omega $ of the independent error terms in a directed Gaussian graphical model M
Examples
julia> M = gaussian_graphical_model(graph_from_edges(Directed, [[1,2], [2,3]]))
Gaussian Graphical Model on a Directed graph with 3 nodes and 2 edges
julia> error_covariance_matrix(M)
[w[1] 0 0]
[ 0 w[2] 0]
[ 0 0 w[3]]
This function is part of the experimental code in Oscar. Please read here for more details.
error_covariance_matrix(M::GaussianGraphicalModel{Graphh{Directed}, L}) where LCreate the covariance matrix $ \Omega $ of the independent error terms in a directed Gaussian graphical model M
Examples
julia> M = gaussian_graphical_model(graph_from_edges(Directed, [[1,2], [2,3]]))
Gaussian Graphical Model on a Directed graph with 3 nodes and 2 edges
julia> error_covariance_matrix(M)
[w[1] 0 0]
[ 0 w[2] 0]
[ 0 0 w[3]]
This function is part of the experimental code in Oscar. Please read here for more details.
Undirected Gaussian Graphical Model
As with their directed counterpart, it is very easy to create new subtypes of graphical models by overloading the function concentration_matrix below. Unlike most other types of graphical models though, the vanishing ideal computation of an undirected graphical model is done by eliminating all concentration variables $k_{ij}$ from the ideal given by the equations $\Sigma K - Id$ after saturating by $\det(K)$.
concentration_matrix — Function
concentration_matrix(M::GaussianGraphicalModel{Graph{Undirected}, T}) where TCreate the concentration matrix K of an undirected Gaussian graphical model which is a symmetric positive definite matrix whose nonzero entries correspond to the edges of the associated graph.
Examples
julia> M = gaussian_graphical_model(graph_from_edges([[1,2], [2,3]]))
Gaussian Graphical Model on a Undirected graph with 3 nodes and 2 edges
julia> concentration_matrix(M)
[k[1, 1] k[2, 1] 0]
[k[2, 1] k[2, 2] k[3, 2]]
[ 0 k[3, 2] k[3, 3]]
This function is part of the experimental code in Oscar. Please read here for more details.
Gaussian Rings
gaussian_ring — Function
gaussian_ring(F::Field, n::Int; s_var_name::VarName=:s, cached=false)
gaussian_ring(n::Int; s_var_name::VarName=:s, cached=false)
gaussian_ring(GM::GaussianGraphicalmodel)A polynomial ring whose variables correspond to the entries of a covariance matrix of n Gaussian random variables. It is a multivariate polynomial ring whose variables are named s[i,j]and whose coefficient field is QQ by default or one can specify the field F by passing it as the first argument.
If cached is true, the internally generated polynomial ring will be cached.
Examples
julia> R = gaussian_ring(3)
GaussianRing over Rational field in 6 variables
s[1, 1], s[1, 2], s[1, 3], s[2, 2], s[2, 3], s[3, 3]
julia> M = gaussian_graphical_model(graph_from_edges([[1,2], [2,3]]))
Gaussian Graphical Model on a Undirected graph with 3 nodes and 2 edges
julia> gaussian_ring(M)
GaussianRing over Rational field in 6 variables
s[1, 1], s[1, 2], s[1, 3], s[2, 2], s[2, 3], s[3, 3]
This function is part of the experimental code in Oscar. Please read here for more details.
covariance_matrix — Function
covariance_matrix(GM::GaussianGraphicalModel)Return the covariance matrix associated to the graphical model GM as a matrix over the underlying model ring of GM, see model_ring
Examples
julia> GM = gaussian_graphical_model(graph_from_edges(Directed, [[1,2], [2,3]]))
Gaussian Graphical Model on a Directed graph with 3 nodes and 2 edges
julia> covariance_matrix(GM)
[s[1, 1] s[1, 2] s[1, 3]]
[s[1, 2] s[2, 2] s[2, 3]]
[s[1, 3] s[2, 3] s[3, 3]]
This function is part of the experimental code in Oscar. Please read here for more details.