Running e.g. cv.glmnet on a dataset gives me (by default) 100 different models. Now, if my dataset had missing data, I could do multiple imputation (say 10 imputations) and run cv.glmnet on each of the imputations.
If I disregard the actual coefficient values for each of the models, and just look at the selected features (i.e. sets of column names), some models are submodels of others.
Code like this imitates the results somewhat:
usevars<-paste("var", 1:100, sep="")
mdls<-replicate(1000, {
numVars<-sample.int(length(usevars), 1)
sample(usevars, numVars)
})
names(mdls)<-paste("mdl", 1:1000, sep="")
Now, it’s easy enough to get the parent-child relations for submodels in this respect. It is also possible to only include ‘direct parenthood’ (i.e. if model A is child of B and B is child of C, then don’t include the relation between A and C).
Finally, I come to my problem: I’ve used igraph to plot these models and their (direct) relations. I did not, however, find a layout that could group the nodes based on another variable (in this case the model size): in this setting it seems like a good idea to create this graph holding ‘bands’ of models with the same model size (number of variables in the model).
What I ended up doing, was more or less calculate the positions of each node myself through a kludge of code (that I’m too embarassed about to be posting here), but I always kept wondering if I simply missed a better / out-of-the-box solution.
My own code resulted in graphs like this one (you can ignore the colours and the labels – just know that the horizontal axis holds the model size):

Suggestions for achieving this sort of graph more elegantly than, well, doing all the hard work myself, are greatly appreciated.
The Fruchterman-Reingold layout algorithm in the development version of igraph (that is, 0.6, which is not released officially yet, but you can ask Gábor on the mailing list to send you a copy) has two hidden (i.e. yet undocumented) parameters:
minyandmaxy. They allow you to constrain the Y coordinates of nodes within a range, so you can use this to create layers.Alternatively, I’m working on an implementation of the Sugiyama layered graph layout method for igraph right now and I will merge it to the development tree in a day or two (if things go well), and then you can try that.