Managing complex models/formulae I'm building a logistic model on a fairly large dataset (~90 features). I have enough data to include many different features, nonlinearities and interactions between them without worrying about overfitting.
My problem is that the model specification itself is growing rather large and unwieldy as I incorporate more features, nonlinearities and interactions. I have enough data that it could eventually involve all 90 features plus interactions and nonlinearities chosen using domain expertise and exploratory analysis. As a result, the actual model formula is getting complicated and difficult to maintain or check for correctness.
I'd like a better way to keep track of where, how and why each feature was incorporated into the model specification. But right now, the specification feels like the statistical equivalent of spaghetti code written at too low a level of abstraction.
Are there tools or techniques to help me manage the complexity of large model specifications like this? I'm using python with statsmodels currently, but appreciate pointers to things in any language.
Thanks!
 A: There are two levels, on the implementation side the formula terms and eventually the columns of the design matrix are just a list of strings. In terms of what organizing components, it is a task for getting some meaningful structure into an unordered list of 90 items.
To the second: Creating a structure on top of 90 items needs to depend on how this items can be meaningfully categorized. Without knowing anything about the specific application, I would separate it into core variables which are terms that are always included, and the rest defined by a hierarchy that is potentially multidimensional. One possibility is to categorize the latter by topic, variables that reflect spatial features, variables that reflect attributes of the individuals, attributes that reflect general market situation  (just to make up a few items), and, secondly, categorize into main effects, interaction effects and non-linearities. This could also be refined, for examples for non-linearities we could sort them and include only optionally only some of them, or any additional variables could be assigned a rank in terms of importance. 
To the first item in terms of implementation, I would use something that can define a multi-index and hierarchy, for example a dictionary tree or dictionaries of list of strings, so it's easy to build the formulas and order the results by the categories.
in python string concatenation
formula = ' + '.join([i for i in core_vars + topic_A_main + topic_A_interaction
                       + topic_B_main])
with, for example, topic_A_interaction being the selection of formula terms with topic=='A' and level=='interaction'
Except for separating interactions and higher order polynomial or nonlinear terms, I don't see a way to define the categories in a way that doesn't depend on the specific subject matter.
A: Complex model can have better prediction accuracy but they lost definitive a lot in terms of interpretability. There are some techniques that can help you to understand what is happening even if this can be non trivial.
I would suggest you to look at how random forest computes the importance of the predictors. You can use a similar system to understand what are the relevant variables in your system. http://www.biomedcentral.com/1471-2105/8/25
Otherwise you can try with something like partial dependency plot or stuff like that.
If you can transform your model in a 'linear in the coefficient model' maybe introducing variables that express non linearity or interaction like $x_1^2$ or $x_1x_2$ then you can use something like Lasso to reduce the complexity and understand which variables are important.
A: Wilkinson notation may help. Example: $(x_1+x_2^2)*(x_3+x_4^3)=\beta_1x_1+\beta_2x_2+\beta_3x_2^2+\beta_4x_1*x_3\dots$
