Graphical Models MLE is a package for algebraic statistics that broadens the functionalities of GraphicalModels. It computes the maximum likelihood estimates (MLE) of the covariance matrix of Gaussian graphical models associated to loopless mixed graphs(LMG).
The main features of the package are the computation of the sampleCovarianceMatrix of sample data, the ideal generated by scoreEquations of log-likelihood functions of Gaussian graphical model, the MLdegree of such models and the MLE for the covariance or concentration matrix via solverMLE.
For more details on the type of graphical models that are accepted see gaussianRing. In particular, for further information about LMG with undirected, directed and bidirected edges, check partitionLMG.
References:
An introduction to key notions such as MLE and ML-degree can be found in the books:
Seth Sullivant, Algebraic statistics, American Mathematical Society, Vol 194, 2018.
Mathias Drton, Bernd Sturmfels and Seth Sullivant, Lectures on Algebraic Statistics, Oberwolfach Seminars, Vol 40, Birkhauser, Basel, 2009.
The definition and classification of loopless mixed graphs (LMG) can be found in the paper:
Kayvan Sadeghi and Steffen Lauritzen, Markov properties for mixed graphs, Bernoulli, 20 (2014), no 2, 676-696.
Examples:
Computation of a sample covariance matrix from sample data:
i1 : U= matrix{{1,2,1,-1},{2,1,3,0},{-1, 0, 1, 1},{-5, 3, 4, -6}}; 4 4 o1 : Matrix ZZ <--- ZZ |
i2 : sampleCovarianceMatrix(U) o2 = | 115/16 -13/8 -29/16 47/8 | | -13/8 5/4 7/8 -11/4 | | -29/16 7/8 27/16 -21/8 | | 47/8 -11/4 -21/8 29/4 | 4 4 o2 : Matrix QQ <--- QQ |
The ideal generated by the score equations of the log-likelihood function of the graphical model associated to the graph $1\rightarrow 2,1\rightarrow 3,2\rightarrow 3,3\rightarrow 4,3<-> 4$ is computed as follows:
i3 : G = mixedGraph(digraph {{1,2},{1,3},{2,3},{3,4}},bigraph{{3,4}}); |
i4 : R = gaussianRing(G); |
i5 : U = matrix{{6, 10, 1/3, 1}, {3/5, 3, 1/2, 1}, {4/5, 3/2, 9/8, 3/10}, {10/7, 2/3,1, 8/3}}; 4 4 o5 : Matrix QQ <--- QQ |
i6 : scoreEquations(R,U) o6 = ideal (192199680p - 99333449, 267221621760p - 849243924773, 3,4 4,4 ------------------------------------------------------------------------ 1353974896462794079472640p - 142165262245288892244817, 6898968p - 3,3 2,2 ------------------------------------------------------------------------ 11533057, 19600p - 95819, 20855l + 90447, 1,1 3,4 ------------------------------------------------------------------------ 146915678869660815915l - 4228634793402814499, 2,3 ------------------------------------------------------------------------ 58766271547864326366l + 4167005135395196717, 574914l - 896035) 1,3 1,2 o6 : Ideal of QQ[l ..l , l , l , p , p , p , p , p ] 1,2 1,3 2,3 3,4 1,1 2,2 3,3 4,4 3,4 |
Computation of the ML-degree of the 4-cycle:
i7 : G=graph{{1,2},{2,3},{3,4},{4,1}}; |
i8 : MLdegree(gaussianRing G) o8 = 5 |
Next compute the MLE for the covariance matrix of the graphical model associated to the graph $1\rightarrow 3,2\rightarrow 4,3<-> 4,1 - 2$. The input is the sample covariance instead of the sample data.
i9 : G = mixedGraph(digraph {{1,3},{2,4}},bigraph {{3,4}},graph {{1,2}}); |
i10 : V = matrix {{7/20, 13/50, -3/50, -19/100}, {13/50, 73/100, -7/100, -9/100},{-3/50, -7/100, 2/5, 3/50}, {-19/100, -9/100, 3/50, 59/100}}; 4 4 o10 : Matrix QQ <--- QQ |
i11 : solverMLE(G,V,SampleData=>false) o11 = (-.655574, {| .35 .26 -.0548792 -.19146 |}, 2) | .26 .73 -.0291359 -.101648 | | -.0548792 -.0291359 .4 .06 | | -.19146 -.101648 .06 .59 | o11 : Sequence |
As an application of solverMLE: positive definite matrix completion
Consider the following symmetric matrix with some unknown entries:
i12 : R=QQ[x,y]; |
i13 : M=matrix{{115,-13,x,47},{-13,5,7,y},{x,7,27,-21},{47,y,-21,29}} o13 = | 115 -13 x 47 | | -13 5 7 y | | x 7 27 -21 | | 47 y -21 29 | 4 4 o13 : Matrix R <--- R |
Unknown entries correspond to the non-edges of the 4-cycle. A positive definite completion of this matrix is obtained by giving values to x and y and computing the MLE for the covariance matrix in the Gaussian graphical model given by the 4-cycle. Check solverMLE for more details.
i14 : G=graph{{1,2},{2,3},{3,4},{1,4}}; |
i15 : V=matrix{{115,-13,-29,47},{-13,5,7,-11},{-29,7,27,-21},{47,-11,-21,29}}; 4 4 o15 : Matrix ZZ <--- ZZ |
i16 : (mx,MLE,ML)=solverMLE(G,V,SampleData=>false) o16 = (-15.8404, | 115 -13 .645756 -.129151 |, 1) | -13 5 .0922509 -.0184502 | | .645756 .0922509 27 -21 | | -.129151 -.0184502 -21 29 | o16 : Sequence |
GraphicalModelsMLE requires Graphs, StatGraphs and GraphicalModels. In order to use the default numerical solver, it also requires EigenSolver.
Graphs allows the user to create graphs whose vertices are labeled arbitrarily. However, several functions in GraphicalModels sort the vertices of the graph. Hence, graphs used as input to methods in GraphicalModelsMLE must have sortable vertex labels, e.g., all numbers or all letters.
StatGraphs allows the user to work with objects such as bigraphs and mixedGraphs.
GraphicalModels is used to generate gaussianRing, i.e. rings encoding graph properties.
This documentation describes version 0.3 of GraphicalModelsMLE.
The source code from which this documentation is derived is in the file GraphicalModelsMLE.m2.
The object GraphicalModelsMLE is a package.