def sum_outer_product_loop(x, group_iter):

    mom = 0
    for g in group_iter():
        x_g = x[g]
        #print 'x_g.shape', x_g.shape
        mom += np.outer(x_g, x_g)

    return mom
sum outerproduct dot(x_i, x_i.T) over individuals
dataset/ETHPy150Open statsmodels/statsmodels/statsmodels/sandbox/panel/panel_short.py/sum_outer_product_loop