jeffgortmaker / pyblp

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

extending the feature of aggregate elasticities #113

Closed khayashidaX closed 2 years ago

khayashidaX commented 2 years ago

Could you consider adding or guiding on how to edit the compute_aggregate_elasticities function to achieve the following feature?

I have been trying to extend the original function to calculate the aggregated elasticity by product category. Currently, it only supports the own elasticity by increasing all the products' prices/features.

Instead, I am interested in seeing how the category A's and B's shares change if all the category A's prices increased. The same for category B's price increase. This would return the 2*2 matrix for each market, rather than a scalar for each market.

Although the idea is simple, I stumbled upon editing the original python codes mainly due to the confusion of multiple classes. So, I really appreciate your input on this.

Thank you!

jeffgortmaker commented 2 years ago

I think you should be able to do this with ProblemResults.compute_shares by passing it a vector of prices with category A's prices increased. It will return changed shares for all products, including those in categories A and B.

khayashidaX commented 2 years ago

Thank you, it worked as expected!