6.6.5.1.5. statsmodels.sandbox.panel.sandwich_covariance_generic.aggregate_cov

statsmodels.sandbox.panel.sandwich_covariance_generic.aggregate_cov(x, d, r=None, weights=None)[source]

sum of outer procuct over groups and time selected by r

This is for a generic reference implementation, it uses a nobs-nobs double loop.

Parameters:

x : ndarray, (nobs,) or (nobs, k_vars)

data, for robust standard error calculation, this is array of x_i * u_i

d : ndarray, (nobs, n_groups)

integer group labels, each column contains group (or time) indices

r : ndarray, (n_groups,)

indicator for which groups to include. If r[i] is zero, then this group is ignored. If r[i] is not zero, then the cluster robust standard errors include this group.

weights : ndarray

weights if the first group dimension uses a HAC kernel

Returns:

cov : ndarray (k_vars, k_vars) or scalar

covariance matrix aggregates over group kernels

count : int

number of terms added in sum, mainly returned for cross-checking

Notes

This uses kernel to calculate the weighted distance between two observations.