6.8.2.1.7. statsmodels.sandbox.stats.contrast_tools.dummy_limits

statsmodels.sandbox.stats.contrast_tools.dummy_limits(d)[source]

start and endpoints of groups in a sorted dummy variable array

helper function for nested categories

Examples

>>> d1 = np.array([[1, 0, 0],
                   [1, 0, 0],
                   [1, 0, 0],
                   [1, 0, 0],
                   [0, 1, 0],
                   [0, 1, 0],
                   [0, 1, 0],
                   [0, 1, 0],
                   [0, 0, 1],
                   [0, 0, 1],
                   [0, 0, 1],
                   [0, 0, 1]])
>>> dummy_limits(d1)
(array([0, 4, 8]), array([ 4,  8, 12]))

get group slices from an array

>>> [np.arange(d1.shape[0])[b:e] for b,e in zip(*dummy_limits(d1))]
[array([0, 1, 2, 3]), array([4, 5, 6, 7]), array([ 8,  9, 10, 11])]
>>> [np.arange(d1.shape[0])[b:e] for b,e in zip(*dummy_limits(d1))]
[array([0, 1, 2, 3]), array([4, 5, 6, 7]), array([ 8,  9, 10, 11])]