jeffgortmaker / pyblp

BLP Demand Estimation with Python
https://pyblp.readthedocs.io
MIT License
228 stars 82 forks source link

Outside good's characteristics in specifying the micro moments #159

Closed giheungkim closed 2 weeks ago

giheungkim commented 2 weeks ago

Hi Jeff, Thank you for the amazing package.

I am curious to know the consequence of specifying the outside good's characteristics to 0 when constructing the covariance micro-moments with full sample of consumers.

For example, suppose I am interested in a subset of the residential rental market where the products of interest are large apartment buildings and the outside goods are all other "mom-and-pop" buildings.

I can sample individual renters from the ACS in a given geography-year that has both renter characteristics (income, household size) as well as their dwelling characteristics (rent paid, # of bedrooms). This sample does not condition on individuals purchasing the inside option and it includes all renters in the market.

Even though i do not have individuals' choices, I can still construct moments such as Cov(income_i, rent_j) or Cov(household size_i, bedroom_j).

If I specify the micro-moment to be computed as following, where the first element of the right-hand side of np.outer() specifies the characteristic of the outside good to be 0:

rent_part_agg = pyblp.MicroPart(
    name="E[rent_j]",
    dataset=acs,
    compute_values=lambda t, p, a: np.outer(a.demographics[:, 0],np.r_[0,-p.X2[:, 1]]),
)

inc_part_agg = pyblp.MicroPart(
        name="E[inc_i]",
        dataset=acs,
        compute_values=lambda t, p, a: np.outer(a.demographics[:, 1],np.r_[1, p.X2[:, 0]]),
    )

inc_rent_part_agg= pyblp.MicroPart(
    name="E[inc_i*rent_j]",
    dataset=acs,
    compute_values=lambda t, p, a: np.outer(a.demographics[:, 1],np.r_[0, -p.X2[:, 1]]),
)

This in theory, is not correct right? To the extent that I want to match the sample Cov(inc_i,rent_j), I need to specify the "average" rent or normalize prices and other characteristics to the observed average characteristics of the outside good in each market?

Please let me know if I am not correct. I wasn't able to find an example both in the paper of yours as well as in the tutorial for a situation like this.

jeffgortmaker commented 2 weeks ago

Right, using something like the "average" rent of those in your micro data who selected the outside option would be more correct. The idea with micro moments is to just replicate (in the population) the weights and values that would generate the observed micro data.

For those micro moments that involve product characteristics, why not define conditional covariances, that are conditional on purchasing an inside option? Alternatively, if you aren't matching anything involving the outside option, you could just define micro weights that condition on inside purchase (although then you'd be leaving out potentially useful information about which demographics tend to choose the outside option).

giheungkim commented 2 weeks ago

Thank you SO much for the quick reply. This makes perfect sense. I will try the latter since I cannot condition on purchasing an inside option as of now.