def cov_cluster_2groups(results, group, group2=None, use_correction=True):
 if (group2 is None):
  if ((group.ndim != 2) or (group.shape[1] != 2)):
   raise ValueError(('if group2 is not given, then groups needs to be ' + 'an array with two columns'))
  group0 = group[:, 0]
  group1 = group[:, 1]
 else:
  group0 = group
  group1 = group2
  group = (group0, group1)
 cov0 = cov_cluster(results, group0, use_correction=use_correction)
 cov1 = cov_cluster(results, group1, use_correction=use_correction)
 group_intersection = Group(group)
 cov01 = cov_cluster(results, group_intersection.group_int, use_correction=use_correction)
 cov_both = ((cov0 + cov1) - cov01)
 return (cov_both, cov0, cov1)

def cov_cluster_2groups ( results , group , group2 = None , use_correction = True ) : if ( group2 is None ) : if ( ( group . ndim != 2 ) or ( group . shape [ 1 ] != 2 ) ) : raise ValueError ( ( 'if group2 is not given, then groups needs to be ' + 'an array with two columns' ) ) group0 = group [ : , 0 ] group1 = group [ : , 1 ] else : group0 = group group1 = group2 group = ( group0 , group1 ) cov0 = cov_cluster ( results , group0 , use_correction = use_correction ) cov1 = cov_cluster ( results , group1 , use_correction = use_correction ) group_intersection = Group ( group ) cov01 = cov_cluster ( results , group_intersection . group_int , use_correction = use_correction ) cov_both = ( ( cov0 + cov1 ) - cov01 ) return ( cov_both , cov0 , cov1 )
cluster robust covariance matrix for two groups/clusters parameters results : result instance result of a regression .