min_distance_utils
module¶
Utility programs used in min_distance.py
.
MDEResults
dataclass
¶
The results from minimum-distance estimation and testing.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
int
|
the number of types of men |
required |
Y |
int
|
the number of types of women |
required |
K |
int
|
the number of bases |
required |
number_households |
int
|
the number of households in the sample |
required |
estimated_coefficients |
np.ndarray
|
the estimated coefficients |
required |
varcov_coefficients |
np.ndarray
|
their eetimated var-covar |
required |
stderrs_coefficients |
np.ndarray
|
their estimated stderrs |
required |
estimated_Phi |
np.ndarray
|
the estimated joint surplus |
required |
test_statistic |
float
|
the value of the misspecification statistic |
required |
test_pvalue |
float
|
the p-value of the test |
required |
ndf |
int
|
the number of degrees of freedom |
required |
parameterized_entropy |
bool | None
|
True if the derivative of the entropy has unknown parameters |
False
|
Source code in cupid_matching/min_distance_utils.py
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
|
check_args_mde(muhat, phi_bases)
¶
check that the arguments to the MDE are consistent
Source code in cupid_matching/min_distance_utils.py
19 20 21 22 23 24 25 26 27 28 29 30 31 |
|
check_indep_phi_no_singles(D2_phi, X, Y)
¶
check that the double difference of the phi matrix has full column rank; if so, return it
Parameters:
Name | Type | Description | Default |
---|---|---|---|
D2_phi |
np.ndarray
|
an \((X*Y, K)\) matrix of double differences |
required |
X |
int
|
number of types of men |
required |
Y |
int
|
number of types of women |
required |
Returns:
Type | Description |
---|---|
None
|
nothing |
Source code in cupid_matching/min_distance_utils.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
|
compute_estimates(M, S_mat, d)
¶
Returns the QGLS estimates and their variance-covariance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
M |
np.ndarray
|
an (XY,p) matrix |
required |
S_mat |
np.ndarray
|
an (XY, XY) weighting matrix |
required |
d |
np.ndarray
|
an XY-vector |
required |
Returns:
Type | Description |
---|---|
tuple[np.ndarray, np.ndarray]
|
the p-vector of estimates and their estimated (p,p) variance |
Source code in cupid_matching/min_distance_utils.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
|
get_initial_weighting_matrix(parameterized_entropy, initial_weighting_matrix, XY)
¶
returns the initial weighting matrix for the MDE when the entropy is parameterized
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parameterized_entropy |
bool
|
if |
required |
initial_weighting_matrix |
np.ndarray | None
|
the initial weighting matrix, if provided |
required |
XY |
int
|
= X*Y |
required |
Returns:
Type | Description |
---|---|
np.ndarray | None
|
the initial_weighting_matrix, or None if the entropy is not parameterized. |
Source code in cupid_matching/min_distance_utils.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
|
get_optimal_weighting_matrix(muhat, hessians_both, no_singles=False, D2_mat=None)
¶
compute the \(S^st\) matrix used in the second step of the MDE
Parameters:
Name | Type | Description | Default |
---|---|---|---|
muhat |
Matching
|
the observed |
required |
hessians_both |
np.ndarray
|
the Hessian of the entropy function |
required |
Source code in cupid_matching/min_distance_utils.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
|
make_D2_matrix(X, Y)
¶
create the double difference matrix for use w/o singles
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
int
|
number of types of men |
required |
Y |
int
|
number of types of women |
required |
Returns:
Type | Description |
---|---|
tuple[np.ndarray, int]
|
an (r, XY) matrix and its rank r |
Source code in cupid_matching/min_distance_utils.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
|
make_hessian_mde(hessian_components_mumu, hessian_components_mur)
¶
reconstitute the Hessian of the entropy function from its components
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hessian_components_mumu |
ThreeArrays
|
the components of the Hesssian wrt \((\mu,\mu)\) |
required |
hessian_components_mur |
TwoArrays
|
the components of the Hesssian wrt \((\mu,r)\) |
required |
Returns:
Type | Description |
---|---|
np.ndarray
|
np.ndarray: description |
Source code in cupid_matching/min_distance_utils.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
|