[R] identify non-recursive models

William Dunlap wdunlap at tibco.com
Tue Jan 29 18:03:20 CET 2013


is.dag()?

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf
> Of Dustin Fife
> Sent: Tuesday, January 29, 2013 8:52 AM
> To: Duncan Murdoch
> Cc: r-help
> Subject: Re: [R] identify non-recursive models
> 
> Thanks for the response. That doesn't seem to do it. It's able to identify
> if one edge connects back into itself, but isn't able to identify whether
> an edge eventually connects back into itself (after passing through
> multiple variables). For example, the following should fail, because the
> path goes from 1-2-3, then back into 1:
> 
> is.simple(graph(c(1,2,2,3,3,1,3,4)))
> 
> But, it returns TRUE.
> 
> On Tue, Jan 29, 2013 at 10:21 AM, Duncan Murdoch
> <murdoch.duncan at gmail.com>wrote:
> 
> > On 29/01/2013 11:12 AM, Dustin Fife wrote:
> >
> >> Hi,
> >>
> >> I'm working on a project that will generate RAM matrices at random. What I
> >> want to do is to be able to automatically identify if the model is
> >> non-recursive. For example, the following RAM matrix has a non-recursive
> >> loop (going from A to B to C to A):
> >>
> >
> > I'm not familiar with your terms, but your description sounds like you
> > want a test for a simple graph.  I believe the igraph package has that in
> > the "is.simple" function (and a lot of other tests of graph properties in
> > case that's not the one you want).
> >
> > Duncan Murdoch
> >
> >
> >> n.recursive <- data.frame(matrix(c("A", "B", 1,
> >>                          "B", "C", 1,
> >>                          "C", "A", 1,
> >>                          "B", "D", 1), nrow=4, byrow=TRUE))
> >> names(n.recursive) <- c("From", "To", "Arrows")
> >>
> >> What I want to be able to do is have a function that automatically checks
> >> whether there is a non-recursive path. Here's what I've thought of so far:
> >>
> >> 1. Find all variables that both send and receive an arrow. (in this case,
> >> A
> >> and B both fit that criteria).
> >>
> >> vars <- LETTERS[1:5]
> >> double.arrow.vars <- vars[which(vars %in% n.recursive$From & vars %in%
> >> n.recursive$To)]
> >>
> >> 2. For all variables found in #1, follow all paths exiting that variable
> >> to
> >> other variables, then follow all paths exiting that next variable
> >> variable,
> >> etc. and continue tracing the path.
> >>
> >> ##### insert complicated code here
> >>
> >> 3. If a variable is repeated, identify it as non-recursive.
> >>
> >> The problem with #2 is that, for large models, the number of paths to be
> >> traced could be really large. (Also, I'm having trouble thinking of how to
> >> code it so it's not really awkward).
> >>
> >> So, my question is this: is there a better way to approach the problem? Is
> >> there a more efficient way?
> >>
> >> I know that I could probably identify which models are non-recursive after
> >> estimation (via convergence failures or negative parameter estimates). But
> >> I want to be able to identify them before estimation. Any help would be
> >> appreciated.
> >>
> >> Dustin
> >>
> >>
> >>
> >>
> >>
> >
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> 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.



More information about the R-help mailing list