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):
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
--
Dustin Fife
PhD Student
Quantitative Psychology
University of Oklahoma
[[alternative HTML version deleted]]