def _xx_time_effects(x, y):
 xx = np.dot(x.values.T, x.values)
 xt = x.sum(level=0).values
 count = y.unstack().count(1).values
 selector = (count > 0)
 xt = xt[selector]
 count = count[selector]
 return (xx - np.dot((xt.T / count), xt))

def _xx_time_effects ( x , y ) : xx = np . dot ( x . values . T , x . values ) xt = x . sum ( level = 0 ) . values count = y . unstack ( ) . count ( 1 ) . values selector = ( count > 0 ) xt = xt [ selector ] count = count [ selector ] return ( xx - np . dot ( ( xt . T / count ) , xt ) )
returns xx - ^-1 .