cmu-phil / tetrad

Repository for the Tetrad Project, www.phil.cmu.edu/tetrad.
GNU General Public License v2.0
404 stars 110 forks source link

Choose Dag from Pag doesn't work for o-o edges #1155

Closed espinoj closed 5 years ago

espinoj commented 5 years ago

Reproduce Run an FCI algorithm until you get a graph with o-o type edges Use graph box to select dag from pattern Notice that o-o edges do not change to a directed edge

kvb2univpitt commented 5 years ago

@espinoj Looks like this requires some knowledge of edge orientation rules. @jdramsey is probably the best person for this.

kvb2univpitt commented 5 years ago

@espinoj @jdramsey Actually, no. What I said above is not true. A simple fix would be changing the following code from this:

if (Edges.isUndirectedEdge(edge) || Edges.isBidirectedEdge(edge)) {
    return edge;
}

to this:

if (Edges.isUndirectedEdge(edge) || Edges.isBidirectedEdge(edge) || Edges.isNondirectedEdge(edge)) {
    return edge;
}

I am just not sure if applying additional condition isNondirectedEdge is valid. If Joe says yes, I can go ahead and fix it.

jdramsey commented 5 years ago

Hmm... this gadget is supposed to be getting a DAG from a pattern, right, not a PAG?

jdramsey commented 5 years ago

I think the proper thing to do is to do a check right off and make sure it consists of only directed and undirected edges and contains no cycles. If not, pop up a dialog saying why it's not a pattern.

kvb2univpitt commented 5 years ago

@jdramsey I have never used this feature. Not sure what the correct behavior should be.

jdramsey commented 5 years ago

@kvb2univpitt Well, it's supposed to select a DAG from a Pattern. A pattern is an equivalence class for a DAG; it consists of directed and undirected edges and has no cycles. You can check the input graph as follows:

boolean graphOk = true;

For each edge e in the input graph: If (!(e is directed or e is undirected) { throw new IllegalArgumentException("This edge in the graph is not directed or undirected: " + e"); } }

if (graph.containsDirectedCycle) { throw new IllegalArgumentException("That graph contains a directed cycle. Please don't make me tell you what it is."); }

There are a few other conditions on patterns, but I think if it's that close it's OK.

kvb2univpitt commented 5 years ago

@jdramsey

it consists of directed and undirected edges and has no cycles.

Ok. So, we shouldn't consider nondirected edges.

"That graph contains a directed cycle. Please don't make me tell you what it is."

Hahaha!!!

espinoj commented 5 years ago

@jdramsey

Ok. What is the difference between Pattern, PAG, and MAG?

jdramsey commented 5 years ago

On Tue, Jun 18, 2019 at 3:31 PM Jeremy Espino notifications@github.com wrote:

@jdramsey https://github.com/jdramsey

Ok. What is the difference between Pattern, PAG, and MAG?

So, first of all, a pattern is the sort of graph that PC or FGES is supposed to be outputting. It represents an equivalence class of DAGs under the assumption that there are no latent confounders, and also under the assumption that you only used conditional independence testing to find the equivalence class. It can contain undirected or directed edges and obviously can't contain any cycles (since it's an equivalence class of DAGs). Undirected edges in the pattern go one way in some member of the equivalence class and the other way in some other member of the equivalence class. The directed edges are so directed in every member of the equivalence class. If you start with a pattern, you can get a DAG by orienting one of the undirected edges, applying the Meek rules, then orienting another undirected edge, applying the Meek rule again, and so on until there are no more undirected edges. This is the Pattern to DAG operation.

A MAG and a PAG are what you get in the above if you allow there to be latent confounders in the graph. A MAG may contain directed edges (same meaning), bidirected edges (implying a latent confounder), or undirected edges (implying selection bias and pretty rare). A MAG is just one graph; to show the entire equivalence class of these MAGs, the circle endpoint is introduced as meaning either arrow or tail endpoint, you don't know which. I think by choosing values for the circle endpoints in all combinations and applying the FCI final orientation rules, you can get all MAGs.

Joe

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/cmu-phil/tetrad/issues/1155?email_source=notifications&email_token=ACLFSR3WZ446XZ2E7PNYJYDP3EZXVA5CNFSM4HX5V352YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODX7WZJA#issuecomment-503278756, or mute the thread https://github.com/notifications/unsubscribe-auth/ACLFSR6MZW4UNZY2EE2FU2DP3EZXVANCNFSM4HX5V35Q .

-- Joseph D. Ramsey Special Faculty and Director of Research Computing Department of Philosophy 135 Baker Hall Carnegie Mellon University Pittsburgh, PA 15213

jsph.ramsey@gmail.com Office: (412) 268-8063 http://www.andrew.cmu.edu/user/jdramsey