[R] Intransitive DAG
David Winsemius
dwinsemius at comcast.net
Tue Jul 12 01:38:25 CEST 2011
On Jul 11, 2011, at 7:25 PM, Thomas S. Dye wrote:
> David Winsemius <dwinsemius at comcast.net> writes:
>
>> On Jul 11, 2011, at 3:28 PM, Thomas S. Dye wrote:
>>
>>> Aloha all,
>>>
>>> I have an adjacency matrix for an acyclic digraph that contains
>>> transitive relations, e.g. (u,v), (v,w), (u,w). I want a DAG with
>>> only
>>> intransitive relations. Can someone point me to an R function that
>>> will
>>> take my adjacency matrix and give me back one with only intransitive
>>> relations? In the example, I'd like to get rid of (u,w) and keep
>>> (u,v)
>>> and (v,w).
>>
>> I'm needing to guess at what sort of code you are using but assuming
>> this is a square matrix:
>>
>> require(ggm)
>> dag <- DAG(y ~ x, x ~ z, u~z)
>>> which(dag != t(dag), arr.ind=TRUE)
>> row col
>> x 2 1
>> y 1 2
>> z 3 2
>> x 2 3
>> u 4 3
>> z 3 4
>>
>
> Aloha David,
>
> Thanks for this suggestion. I don't think it does what I want. Sorry
> if I wasn't precise. The graph theory language is new to me.
It appears to me to be new as well. I imagined that w ~ u and u~w
would be the definition of "transitive" when directed was a modifier,
but apparently there are mathematical constructions that are more
complex than I imagined.
>
> What I'm looking for is a function that gets rid of transitive
> relations, like so:
>
> tdye> dag <- DAG(v ~ u, w ~ v, w ~ u)
> tdye> dag
> v u w
> v 0 0 1
> u 1 0 1
> w 0 0 0
> tdye> dag[2,3] <- 0
> tdye> dag
> v u w
> v 0 0 1
> u 1 0 0
> w 0 0 0
>
> All the best,
> Tom
>
>>> All the best,
>>> Tom
>>> --
>>> Thomas S. Dye
>>> http://www.tsdye.com
>>>
>>> ______________________________________________
>>> R-help at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>
>> David Winsemius, MD
>> West Hartford, CT
>>
>
> --
> Thomas S. Dye
> http://www.tsdye.com
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list