frac_expansions module¶
Small-sigma expansion of the BLP inversion xi_j(S, X; sigma, c, s, kappa).
Model: beta_i = b + sigma * eps_i, with eps_{il} independent across l, E eps_l = 0, E eps_l^2 = sigma^2_l, E eps_l^3 = sigma_l^3 * s_l, E eps_l^4 = sigma_l^4 * (3 + kappa_l).
for the logit share function s(delta),
s_j(delta + X t) / s_j(delta) = exp(t'X_j - K(t)),
where K is the cumulant generating function of the characteristics X under the distribution of shares on {0, ..., J} (with X_0 = 0). Hence ln(S_j / S_0) = delta_j + L_j - L_0, L_j = ln E exp(sigma eps'y_j - [K(sigma eps) - sigma eps'e]), with y_j = X_j - e (e = (e_1, ..., e_k)). A cumulant expansion of L_j, followed by replacing the logit shares s(delta) by the observed S, gives xi_j to order sigma^4.
The result is written in raw share-weighted moments of X over the inside goods (the outside good has X_0 = 0, so it contributes nothing), evaluated at the observed S: e_l = sum_j S_j X_jl, e_2l = sum_j S_j X_jl^2, e_3l = sum_j S_j X_jl^3, v_lm = sum_j S_j X_jl X_jm - e_l e_m.
xi_terms(S, X)
¶
Return the successive terms of the expansion of xi on all markets.
xi = y - X*b - term2 * sigmas^2 - term3 * s * sigmas^3 - (sigmas^2)' * term4_gaussian * sigmas^2 - term4_kappa * sigmas^4 + O(sigmas^5)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
S
|
ndarray
|
Inside shares, a (T, J) matrix with one row per market. |
required |
X
|
ndarray
|
Characteristics with random coefficients, a (T, J, K) array. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]: |
ndarray
|
array of order 2 terms; |
ndarray
|
|
ndarray
|
|
Source code in frac_blp/frac_expansions.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |