merged in additions from statsmodels branch